格式化日期格式为 pandas 风格 [英] format Date in pandas style render
本文介绍了格式化日期格式为 pandas 风格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个熊猫数据框,其中有三列,第一列是日期.为了产生一个html输出,我使用了这个:
I have a pandas dataframe with three columns of which the first is the Date. To produce a html output I use this:
html_string = df.style.format({'second': "{:0,.0f}",third: "{:0,.0f}"}).set_table_styles(styles).render()
如何也可以指定日期的格式...类似
how is it possible to specifiy the format of the Date as well...something like:
html_string = df.style.format({'Date': "%Y.%m",'second': "{:0,.0f}",third: "{:0,.0f}"}).set_table_styles(styles).render()
推荐答案
您可以这样做:
html_string = df.style.format({'Date': "{:%Y.%m}",
'second': "{:0,.0f}",
'third': "{:0,.0f}"}).set_table_styles(styles).render()
这篇关于格式化日期格式为 pandas 风格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文