Weekly Challenges

Solve the challenge, share your solution and summit the ranks of our Community!

Also available in | Français | Português | Español | 日本語
IDEAS WANTED

Want to get involved? We're always looking for ideas and content for Weekly Challenges.

SUBMIT YOUR IDEA

Challenge #2: Preparing Delimited Data

nktw
5 - Atom

Solved

dipin
6 - Meteoroid
 
ramesh_neel
11 - Bolide
11 - Bolide
 
Alteryx ACE | Sydney Alteryx User Group Lead | SparkED Contributor and Mentor
JanetteJohnston
7 - Meteor

My practice 🙂

Ferdy
6 - Meteoroid

Here is my solution to challenge #2

Key Tool : Text to Columns

Spoiler
challenge_2.png
andyjohnstone2
7 - Meteor

Quite likely to be more efficient methods but a) Text to Columns, b) Data Cleansing, c) DateTime, d) Select.

NicoleJohnson
ACE Emeritus
ACE Emeritus

My alternative Python-based solution! #SnakingMyWayThruChallenges cc: @SeanAdams 

 

Spoiler
Things I learned in this exercise:
1. Pleasantly surprised at the familiarity of the datetime formatting options between Python & Alteryx
2. I am now wistfully recalling how easy it is to do basic data prep in Alteryx with things like Data Cleansing and Formula or Multi-Field tools when compared to Python...

2_py1.JPG2_py2.JPG

 

PYTHON SCRIPT:

#################################
# Read in various packages + Alteryx start data from input 1

from ayx import Alteryx
import pandas
import numpy
import datetime as dt

poems = Alteryx.read("#1").values.tolist()


#################################
# Split poems array into a list.
result = list()

for i in range(len(poems)):

a = str(poems[i][0]).split(',')
result.append(a)

 

#################################
# Replace double quotes and then reformat datetime.

for lst in result:
for j, item in enumerate(lst):
lst[j] = item.replace('"', '')

if j == 2:
lst[j] = (dt.datetime.strptime(lst[j],"'%y-%b-%d'")).strftime("%Y-%m-%d")
else:
pass


#################################
output = pandas.DataFrame(result)
output = output.rename(columns={0: "Poem", 1: "Poem_ID", 2: "Poem_Read_Date"})

Alteryx.write(output,1)


#################################

output = pandas.DataFrame(result)
output = output.rename(columns={0: "Poem", 1: "Poem_ID", 2: "Poem_Read_Date"})

Alteryx.write(output,1)

Spoiler
NOTE: When I first build these Python scripts, they are way longer, way messier, and way less efficient... but part of my learning process is to figure out how to do things in fewer/cleaner steps, so it's actually been a great learning tool so far to figure out the long/messay way first, and then go through and find ways to clean it up & make it simpler as I expand my knowledge and discover new patterns. 🙂 Also, it's helpful that I have my original Alteryx solutions to look back on so that I already know roughly what needs to be done! Eventually I will get to the point where I try to solve a problem from scratch before I already have a process in mind from my Alteryx solution 😉

Cheers!

NJ

hayakh
5 - Atom

hayakh_1-1583927135220.png

 

 

alozano
8 - Asteroid

Here is my solution.

 

I made my life difficult by using Regex but I need some practice with tthat tool.

 

Spoiler
challenge_2_alozano.jpg
makaylaurogers
7 - Meteor
Spoiler
solution_image_2.PNG