我有以下代码:
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
data = pd.read_csv("Ari_atlag.txt", sep = '\t', header = 0)
#Num_array = pd.DataFrame(data).to_numpy()
print(data.head())
data.plot()
#data.columns = ['Date', 'Number_of_test', 'Avarage_of_ARI']
#print(Num_array)
plt.show()
Run Code Online (Sandbox Code Playgroud)
输出:
Date Number_of_test Avarage_of_ARI
0 2011-01 22 0.568734
1 2011-02 5 0.662637
2 2011-03 0 0.000000
3 2011-04 3 0.307692
4 2011-05 6 0.773611
Process finished with exit code 0
Run Code Online (Sandbox Code Playgroud)
和情节。
但对于图中的这段代码,x 轴是索引。但我想获取 x 轴上的日期。
如何使用 Number_of_test 绘制日期和使用 Avarage_of_ARI 绘制日期
我想,我应该以某种方式将字符串(日期)更改为日期,但不知道该怎么做。
最好的