點我下載:song_rank3.csv
import pandas as pd
with open('data/song_rank3.csv') as f:
p = pd.read_csv(f)
p
p.art2.notnull()
0 False
1 True
2 True
3 True
4 False
5 True
6 False
7 False
8 False
9 False
10 False
11 False
12 True
13 True
Name: art2, dtype: bool
a2 = p.art2.notnull()
p[a2]
print(p[a2].art1.count())
print(p[-a2].art1.count())
6
8
p[a2].art1.count() | art2非空值 | 合唱 |
---|---|---|
p[-a2].art1.count() | art2是空值 | 獨唱 |
import matplotlib.pyplot as plt
x = pd.Series(['獨唱','合唱'])
y = pd.Series([p[a2].art1.count(), p[-a2].art1.count()])
plt.bar(x,y)
plt.show()
plt.rcParams['font.family'] = 'Heiti TC' #system font --> go to your "Font Book"
plt.bar(x,y)
plt.show()
plt.rcParams['font.family'] = 'Heiti TC' #system font --> go to your "Font Book"
plt.bar(x,y, width=0.1)
plt.show()
plt.rcParams['font.family'] = 'Heiti TC' #system font --> go to your "Font Book"
plt.bar(x,y, width=0.1, align='edge')
plt.show()
plt.rcParams['font.family'] = 'Heiti TC' #system font --> go to your "Font Book"
plt.bar(x,y, width=0.1, align='edge')
plt.title('華語歌曲榜統計')
plt.show()
plt.rcParams['font.family'] = 'Heiti TC' #system font --> go to your "Font Book"
plt.bar(x,y, width=0.1, align='edge')
plt.title('華語歌曲榜統計')
plt.xlabel('歌曲分類')
plt.show()
plt.rcParams['font.family'] = 'Heiti TC' #system font --> go to your "Font Book"
plt.bar(x,y, width=0.1, align='edge')
plt.title('華語歌曲榜統計')
plt.xlabel('歌曲分類')
plt.ylabel('數量')
plt.show()
plt.rcParams['font.family'] = 'Heiti TC' #system font --> go to your "Font Book"
plt.bar(x,y, width=0.1, align='edge')
plt.title('華語歌曲榜統計')
plt.xlabel('歌曲分類')
plt.ylabel('數量', rotation=0)
plt.show()