【问题标题】:Change the tittle of labels in a dataframe using Panda Data Reader使用 Panda Data Reader 更改数据框中标签的标题
【发布时间】:2021-07-02 13:12:38
【问题描述】:

我从 PandaDataReader 获取了一些数据并将其打印在数据框中。由于我的工作是西班牙语,我想更改图形中的“日期”一词。我无法将列重命名为来自 de datareader,日期是索引,但我不想更改索引,只是索引列的名称。你知道我该怎么做吗?这是代码

y=data.DataReader('MSFT', 'yahoo', datetime.datetime(1980, 1, 1), datetime.date.today())
df=pd.DataFrame({'Precio de las acciones de Microsoft':y['Adj Close']})
df.plot()

以及生成的图形 enter image description here

【问题讨论】:

    标签: python pandas dataframe matplotlib datareader


    【解决方案1】:

    您可以像这样重命名索引:

    df.index.rename('index name', inplace=True)

    将“索引名称”替换为您喜欢的任何内容。

    【讨论】:

      猜你喜欢
      • 2016-09-20
      • 1970-01-01
      • 2019-04-01
      • 2021-01-14
      • 2017-04-22
      • 2012-12-12
      • 1970-01-01
      • 1970-01-01
      • 2023-03-08
      相关资源
      最近更新 更多