Skip to content
Advertisement

Pandas coverting columns of several dataframes to datetime doesn’t work in a loop

For some reason I cannot convert columns of different dataframes:

JavaScript

although str can be converted to datetime.

But it works ok if I write

JavaScript

And if I call

JavaScript

it returns a Timestamp. Is this the point?

Advertisement

Answer

pd.to_datetime returns a new Series and you assigned that series to i, which you never used after the conversion.

You need to refer to the original dataframe and column:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement