Pandas 打印中表格的格式索引

Pandas 打印中表格的格式索引,pandas,matplotlib,Pandas,Matplotlib,我试图用数据帧的一部分对我的绘图进行注释。但是,时间00:00:00显示在所有行标签中。由于我的数据每天都在使用,是否有一种干净的方法来删除它们?我尝试了normalize函数,但这并没有消除时间;它只是将时间归零 下面是问题的外观以及重现问题的示例代码。 只需访问DateTimeIndex的属性,就可以用datetime.date格式表示索引中的每个元素 默认的DateTimeIndex格式是datetime.datetime,即使之前没有明确定义索引,也会自动定义该格式 import pa

我试图用数据帧的一部分对我的绘图进行注释。但是,时间00:00:00显示在所有行标签中。由于我的数据每天都在使用,是否有一种干净的方法来删除它们?我尝试了normalize函数,但这并没有消除时间;它只是将时间归零

下面是问题的外观以及重现问题的示例代码。

只需访问
DateTimeIndex
的属性,就可以用
datetime.date
格式表示索引中的每个元素

默认的
DateTimeIndex
格式是
datetime.datetime
,即使之前没有明确定义索引,也会自动定义该格式

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pandas.tools.plotting import table   

np.random.seed(42)
# Setup of mock data
date_range = pd.date_range('2014-01-01', '2015-01-01', freq='MS')
df = pd.DataFrame({'Values': np.random.rand(len(date_range))}, date_range)
df.index = df.index.date                                   # <------  only change here

# The plotting of the table
fig7 = plt.figure()
ax10 = plt.subplot2grid((1, 1), (0, 0))
table(ax10, np.round(df.tail(5), 2), loc='center', colWidths=[0.1] * 2)
fig7.show()
将熊猫作为pd导入
将numpy作为np导入
将matplotlib.pyplot作为plt导入
从pandas.tools.plotting导入表
np.随机种子(42)
#模拟数据的设置
日期范围=局部放电日期范围('2014-01-01','2015-01-01',频率='MS')
df=pd.DataFrame({'Values':np.random.rand(len(日期范围))},日期范围)
df.index=df.index.date#
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from pandas.tools.plotting import table   

np.random.seed(42)
# Setup of mock data
date_range = pd.date_range('2014-01-01', '2015-01-01', freq='MS')
df = pd.DataFrame({'Values': np.random.rand(len(date_range))}, date_range)
df.index = df.index.date                                   # <------  only change here

# The plotting of the table
fig7 = plt.figure()
ax10 = plt.subplot2grid((1, 1), (0, 0))
table(ax10, np.round(df.tail(5), 2), loc='center', colWidths=[0.1] * 2)
fig7.show()