Want to get involved? We're always looking for ideas and content for Weekly Challenges.
SUBMIT YOUR IDEAThis challenge is the fraternal twin brother to #46
Here is my solution, it was easy stuff!
I just really love the way Python handles dates, so easy. Although this one wasn't too difficult using a formula tool in Alteryx.
First DateTimeOut formula:
iif(left([date],1)='0','19','20')+right(date,6)
Follow up DateTimeOut formula:
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
df = Alteryx.read('#1')
# 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)