[英]How to plot a table using matplotlib
I have the following dataframe from pandas.我有来自 pandas 的以下 dataframe。 I want to create a matplotlib table, something similar to this:我想创建一个 matplotlib 表,类似于以下内容:
Zip Codes 2016 2017 2018 2019
2443 92.8 93.4 93.07 93.76
2445 94.9 94.4 95 95.13
This is the dataframe i have:这是 dataframe 我有:
Zip Codes,Year,Growth
2443,2016,92.8695652173913
2443,2017,93.3644859813084
2443,2018,93.07
2443,2019,93.76
2445,2016,94.84883720930233
2445,2017,94.43085106382979
2445,2018,94.99236641221374
2445,2019,95.13725490196079
2447,2016,94.85365853658537
2447,2017,94.4171270718232
2447,2018,93.65760869565217
2447,2019,94.12021857923497
How can i pivot the data and display it as above?我如何 pivot 数据并如上显示?
Use the pandas pivot method.使用 pandas pivot 方法。 Something like:就像是:
df.pivot(index="Zip Codes", columns="Year", values="Growth")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.