簡體   English   中英

在 y 軸上繪制多個日期時間列,在 x 軸上繪制它們對應的 id

[英]plotting multiple date-time columns on y-axis and their corresponding ids on x-axis

我有一個帶有文檔 ID 及其相應日期時間列的 csv/excel 文件。 嘗試了以下方法:

import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import datetime
import pandas as pd
xls_data = pd.read_excel(<file-path>)

x1 = xls_data["client_doc_id"].values #id column in the file
y1 = xls_data["planned_finish_ifd"].values #one of the date-time column in the file

plt.plot(x1,y1)
plt.gcf().autofmt_xdate()
plt.show()

但我無法獲得所需的輸出,而是顯示以下錯誤:

AttributeError: 'numpy.datetime64' object has no attribute 'toordinal'

如何繪制一個日期時間列以及如何在一張圖中繪制多個日期時間列?

x1 = xls_data["client_doc_id"]
y1 = xls_data["planned_finish_ifd"]

而不是.values通常將其用作系列。

由於我的matplotlib版本,即2.0.2 ,我一開始沒有得到。 然后我將其更新為最新版本。 現在它起作用了。 附上情節的圖像。 (忽略包含文檔 ID 的 x 軸)。 doc_ids 與發布日期的關系圖

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM