We’ve extended Inspire Early Bird Pricing until March 1. Register now and enjoy 20% off conference passes and 10% off training passes. P.S. Don’t forget to bring friends! When you sign up for five or more tickets, you get an extra 20% discount on conference passes. Learn more now.
alteryx Community

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.

Challenge #58: An Odd String to Date Conversion

8 - Asteroid

This challenge is the fraternal twin brother to #46

Spoiler

8 - Asteroid

My solution

5 - Atom

Mine Solution.

6 - Meteoroid

My first thought was going with Find & Replace and so i did.

10 - Fireball

My solution

Spoiler
7 - Meteor

My solution from challenge 46 worked here too- I believe they were the same

8 - Asteroid

Here is my solution, it was easy stuff!

Spoiler
8 - Asteroid

Quick and easy 🙂

ACE Emeritus

I just really love the way Python handles dates, so easy. Although this one wasn't too difficult using a formula tool in Alteryx.

Spoiler
``````First DateTimeOut formula:
iif(left([date],1)='0','19','20')+right(date,6)

DateTimeParse([DateTimeOut],'%y%m%d')

could condense into:
DateTimeParse(iif(left([date],1)='0','19','20')+right(date,6),'%y%m%d')``````

``````from ayx import Alteryx
import dateutil.parser as dparser
import numpy as np

# use string[start: end: step] to pick apart the string within the "date" field

# if statement is "valueIfTrue if testCondition else valueIfFalse"

df['datetime'] = df['date'].apply(lambda row:
'19'+ row[1:] if row[:1]=='0' else '20' + row[1:])

df['datetime'] = df['datetime'].apply(lambda row:
dparser.parse(row,fuzzy=True))

Alteryx.write(df,3)``````
8 - Asteroid

Here you go !!