Skip to content
Advertisement

python pandas extract unique dates from time series

I have a DataFrame which contains a lot of intraday data, the DataFrame has several days of data, dates are not continuous.

JavaScript

How can I extract the unique date in the datetime format from the above DataFrame? To have result like [2012-10-08, 2012-10-10]

Advertisement

Answer

If you have a Series like:

JavaScript

where each object is a Timestamp:

JavaScript

you can get only the date by calling .date():

JavaScript

and Series have a .unique() method. So you can use map and a lambda:

JavaScript

or use the Timestamp.date method:

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