How to specify date format when using pandas.to_csv?

前端 未结 3 767
囚心锁ツ
囚心锁ツ 2020-11-29 00:57

The default output format of to_csv() is:

12/14/2012  12:00:00 AM

I cannot figure out how to output only the date part with sp

3条回答
  •  执念已碎
    2020-11-29 01:31

    Since version v0.13.0 (January 3, 2014) of Pandas you can use the date_format parameter of the to_csv method:

    df.to_csv(filename, date_format='%Y%m%d')
    

提交回复
热议问题