Community Spring Cleaning week is here! Join your fellow Maveryx in digging through your old posts and marking comments on them as solved. Learn more here!

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 #58: An Odd String to Date Conversion

mulvihi11
8 - Asteroid

This challenge is the fraternal twin brother to #46

Spoiler
mulvihi11_0-1591200072589.png

 

Oren_Soloman
8 - Asteroid

My solution

Mine Solution.

FMaldo
6 - Meteoroid

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

CKP
10 - Fireball

My solution

 

Spoiler
challenge_58_mysolution.jpg
Skrupczak
7 - Meteor

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

cc000072
8 - Asteroid

Here is my solution, it was easy stuff!

Spoiler
WeeklyChallenge_Ryohei_58.JPG
Sylvana
8 - Asteroid

Quick and easy 🙂

jarrod
ACE Emeritus
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)

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)
Guillaume_G
8 - Asteroid

Here you go !!