这一节,我们将前面分析的数据,以图的形式展示出来,也就是“数据可视化”。
代码如下:
graph_data=pd.pivot_table(join_data,index="payment_month",columns="item_name",values="price",aggfunc="sum") graph_data.head()
解释一下代码:
和上一节的代码相似,这里我们去掉了“quantity”。
点击"运行",执行效果如下图所示。
接下来,我们导入 matplotlib 这个python的数据可视化软件包,将数据可视化。
代码如下:
import matplotlib.pyplot as plt %matplotlib inline plt.plot(list(graph_data.index),graph_data["PC-A"],label="PC-A") plt.plot(list(graph_data.index),graph_data["PC-B"],label="PC-B") plt.plot(list(graph_data.index)