Pandas Convert Timestamp Column to Datetime

后端 未结 4 1024
难免孤独
难免孤独 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 07:02

    You can convert directly using apply:

    df.dates = df.dates.apply(lambda x: x.date())
    

    This makes an in-place conversion of the previous 'dates' (as a timestamp) to the truncated 'datetime' only portion

提交回复
热议问题