目录
1.代码讲解
import pandas as pd
import matplotlib.pyplot as plt
df = pd.DataFrame({'A': [0, 2, 4, 6], 'B': [2, 2.5, 5, 8], 'C': [1, 2, 3, 4]},
index=['2020-1-1', '2020-1-2', '2020-1-3', '2020-1-4'])
for col in df:
plt.plot(df[col], label=col)
for name, value in df.max().items(): # df按列求最大值
plt.text(3.05, value, name, size=10, ha='left', va='center') # 标记A、B、C
2.过程数据
df
Out[13]:
A B C
2020-1-1 0 2.0 1
2020-1-2 2 2.5 2
2020-1-3 4 5.0 3
2020-1-4 6 8.0 4
df.max()
Out[14]:
A 6.0
B 8.0
C 4.0
dtype: float64