I'm trying to parse dates using pendulum
. I have a TimeStamp
date, so I did the following:
df['aux']=df['Date'].dt.date
df['p_date']=df.aux.apply(lambda x: pendulum.parse(x))
Which brings the following error:
AttributeError: 'DateTime' object has no attribute 'nanosecond'
But if I do, something like:
pendulum.parse(df.aux[0])
It gets parsed no problem. I thought apply(lambda x:)
applied the same function to all rows of the Series
, but now it isn't working. What's happening?
Sample code:
dates=pd.Series(['2018-03-20','2019-03-21'])
dates.apply(lambda x: pendulum.parse(x)) #Doesn't work
pendulum.parse(dates[0]) #Works