Weekly Challenge

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

We're actively looking for ideas on how to improve Weekly Challenges and would love to hear what you think!

Submit Feedback
We've recently made an accessibility improvement to the community and therefore posts without any content are no longer allowed. Please use the spoiler feature or add a short message in the message body in order to submit your weekly challenge.

Challenge #2: Preparing Delimited Data

Highlighted
5 - Atom

Solved

Highlighted
6 - Meteoroid
 
Highlighted
11 - Bolide
 
Highlighted
7 - Meteor

My practice

Highlighted
6 - Meteoroid

Here is my solution to challenge #2

Key Tool : Text to Columns

Spoiler
challenge_2.png
Highlighted
7 - Meteor

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

Highlighted
14 - Magnetar
14 - Magnetar

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

Highlighted
5 - Atom

hayakh_1-1583927135220.png

 

 

Highlighted
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
Highlighted
5 - Atom
Spoiler
solution_image_2.PNG