Ash W
Ash W

Reputation: 30

Datetime Automatically Converted to Int

I have a series that contains datetime data.

When I want to use Series.unique().tolist(), it seems that the datetime was automatically converted to an int.

Please see the example below. I now realized that it is not necessary as I can iterate over Series.unique(), but just out of curiosity does anyone know why?

enter image description here

Thank you 🙂

Upvotes: 0

Views: 492

Answers (1)

Evgeny Brandenburg
Evgeny Brandenburg

Reputation: 36

I guess you may find the answer here.

Long story short: you are trying to convert from numpy.datetime64 type (output of .unique()), which is not present in vanilla python, so it is being cast to int.

Workaround is using list():

list(sch['Datetime_sch'].unique())

Upvotes: 1

Related Questions