Python Pandas custom time format in Excel output

一笑奈何 提交于 2019-12-03 21:23:37

You can use the datetime_format parameter of ExcelWriter in Pandas:

import pandas as pd
from datetime import datetime


df = pd.DataFrame([datetime(2014, 9, 18, 12, 30, 5, 60000)])

writer = pd.ExcelWriter("time.xlsx",  datetime_format='hh:mm:ss.000')

df.to_excel(writer, "Sheet1")

writer.close()

Which gives the following output:

See also Working with Python Pandas and XlsxWriter.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!