我有一个CSV文件客户:
-------------------------------------------
index | age_group | female | male | total |
-------------------------------------------
0 16-20 23 5 28 |
1 20-26 66 12 78 |
2 26-32 12 3 15 |
... ... .. ... .. |
-------------------------------------------
我想制作一个图表以显示年龄组与总数之间的关系,并制作一个图表以显示不同性别与总数之间的关系。
我用大熊猫作画。
import pandas as pd
# Barchart to show the relationship between age group and total
df.plot.bar(x='age_group', y='total', rot=0)
# Barchart to show the relationship between different gender and total
df.plot.bar(x='age_group', y=['female', 'male'], rot=0)