I want to create a parse function with lambda able to recognize two different formats
"2014-01-06 15:23:00"
and
"2014-01-06"
The idea is to use this function to create a pandas dataframe but in some of the values the hour is missing
This is my first idea
parse = lambda x: pd.datetime.strptime(x, '%Y-%m-%d %H:%M:%S') if x is True else pd.datetime.strptime(x, '%Y-%m-%d')
it seems that x is True is not correct
Any idea??
Aucun commentaire:
Enregistrer un commentaire