Pandas Convert Timestamp Column to Datetime

后端 未结 4 1018
难免孤独
难免孤独 2020-12-19 06:21

Given the following data frame and necessary wrangling:

import pandas as pd
df=pd.DataFrame({\'A\':[\'a\',\'b\',\'c\'],
        \'dates\':[\'2015-08-31 00:00         


        
4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-19 06:55

    You can use dt.date to return a datetime.date object:

    In [3]:
    set(df['dates'].dt.date)
    
    Out[3]:
    {datetime.date(2015, 8, 24),
     datetime.date(2015, 8, 25),
     datetime.date(2015, 8, 31)}
    

提交回复
热议问题