从词云图可以看到,2019年全球最火的还是流行音乐(pop&dance pop)。鉴于其他类型的音乐我都不认识,所以下面的分析,我会直接对pop&dance pop作为主要对象,把他们归为一类。
2、2019年全球流行音乐排行
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from pyecharts import Bar,WordCloud,Pie,Line
%matplotlib inline
%config InlineBackend.figure_format = ‘svg’
df=pd.read_excel(r’C:\Users\Administrator\Desktop\top50.xlsx’)
df=df.rename(columns={‘Track.Name’:‘曲名’, ‘Artist.Name’:‘歌手’, ‘Genre’:‘类型’, ‘Beats.Per.Minute’:‘音调’, ‘Energy’:‘能量’,
‘Danceability’:‘舞蹈性’, ‘Loudness…dB…’:‘分贝’,‘Liveness’:‘现场感’, ‘Length.’:‘时长’,‘Speechiness’:‘语言’, ‘Popularity’:‘火热程度’})
df=df.replace(‘dance pop’,‘pop’)
df=df[df[‘类型’]==‘pop’].reset_index().drop(‘index’,axis=1)
df
通过上述代码,我已经把dance pop的类型全部换成pop。
#接上面的代码
df=df.replace(‘dance pop’,‘pop’)
df=df[df[‘类型’]==‘pop’].reset_index().drop(‘index’,axis=1)
df.pivot_table(df,index=‘曲名’).sort_values(by=‘火热程度’,ascending=False).reset_index()
How Do You Sleep?
这是全球最流行的15首流行歌曲。
结合前面的图我们可以知道:这些流行歌曲的口语化程度低,歌词普遍比较优美,有意境;同时时长恰当,多在3分钟左右…
3、根据流行程度对歌曲进行分类颁奖
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from pyecharts import Bar,WordCloud,Pie,Line
%matplotlib inline
%config InlineBackend.figure_format = ‘svg’
df=pd.read_excel(r’C:\Users\Administrator\Desktop\top50.xlsx’)
df=df.rename(columns={‘Track.Name’:‘曲名’, ‘Artist.Name’:‘歌手’, ‘Genre’:‘类型’, ‘Beats.Per.Minute’:‘音调’, ‘Energy’:‘能量’,
‘Danceability’:‘舞蹈性’, ‘Loudness…dB…’:‘分贝’,‘Liveness’:‘现场感’, ‘Length.’:‘时长’,‘Speechiness’:‘语言’, ‘Popularity’:‘火热程度’})
df=df.replace(‘dance pop’,‘pop’)
df=df[df[‘类型’]==‘pop’].reset_index().drop(‘index’,axis=1)
df=df.pivot_table(‘火热程度’,index=‘曲名’).sort_values(by=‘火热程度’,ascending=False).reset_index()
def grade(火热程度):
if(火热程度>=90):
return ‘年度最热’
if(火热程度>=85):
return ‘年度火热’
else:
return ‘年度流行’
df[‘授予荣誉’] = df.apply(lambda x :grade(x[‘火热程度’]), axis=1)
df
我们知道,很多媒体都喜欢搞排行榜,而且喜欢给歌曲颁奖,这些颁奖一般会根据几个标准进行打分,算出综合排名。不过这个比较复杂,这里只根据流行程度颁奖,大于90分的就是年度最热;85-89的是年度火热;84以下的就是年度流行。这个实现代码很简单,做出分类,再给数据加一列,命名为“授予荣誉”即可。
#接上面的代码
plt.rcParams[‘font.sans-serif’]=[‘SimHei’]
plt.figure(figsize=(8,4))
sns.countplot(x=“授予荣誉”,data=df, order=[‘年度最热’,‘年度火热’,‘年度流行’],palette=“muted”)
plt.title(‘2019年全球流行音乐荣誉’,loc=‘left’,size=15)
plt.xlabel(‘授予荣誉’,size=15)
plt.ylabel(‘数量’,size=15)
plt.grid(False)
sns.despine(left=False )
这是对荣誉情况的统计,适用于数量比较大的情况。
4、2019全球最火流行歌手排行榜
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns
from pyecharts import Bar,WordCloud,Pie,Line
%matplotlib inline
%config InlineBackend.figure_format = ‘svg’
df=pd.read_excel(r’C:\Users\Administrator\Desktop\top50.xlsx’)
df=df.rename(columns={‘Track.Name’:‘曲名’, ‘Artist.Name’:‘歌手’, ‘Genre’:‘类型’, ‘Beats.Per.Minute’:‘音调’, ‘Energy’:‘能量’,
‘Danceability’:‘舞蹈性’, ‘Loudness…dB…’:‘分贝’,‘Liveness’:‘现场感’, ‘Length.’:‘时长’,‘Speechiness’:‘语言’, ‘Popularity’:‘火热程度’})
df=df.replace(‘dance pop’,‘pop’)
df=df[df[‘类型’]==‘pop’].reset_index().drop(‘index’,axis=1)
df=df.pivot_table(‘火热程度’,index=‘歌手’,aggfunc=‘count’).sort_values(by=‘火热程度’,ascending=False).reset_index()
df=df.rename(columns={‘火热程度’:‘上榜次数’})
df
这是全球最火的十大流行音乐歌手的排行。当然下面的图更直观:
#Python学习群 592539176
#接上面的代码
plt.rcParams[‘font.sans-serif’]=[‘SimHei’]
x=df[‘歌手’]
y=df[‘上榜次数’]
plt.figure(figsize=(12,4))
plt.bar(x,y,width=0.5,align=‘center’)
plt.title(‘2019全球最火流行歌手排行榜’,loc=‘left’,size=15)
for a,b in zip(x,y):
plt.text(a,b,b,ha=‘center’,va=‘bottom’,fontsize=12)#显示额度标签
plt.xlabel(‘歌手’,size=15)
plt.ylabel(‘上榜次数’,size=15)
plt.xticks(x,size=12,rotation=30)
plt.yticks(size=15,)
plt.grid(False)
sns.despine(left=False )
plt.show()
从上面的分析可以看到,Ed Sheeran这个人最厉害,15首最流行的歌,他一个人唱了四首,于是我百度了一下,想知道是何方神圣。最后发现就是这个人:
虽然长得确实其貌不扬,但是才华很棒,我听了一下,还蛮好听。
Beautiful People (feat. Khalid)
百度上说,这个人出生于1991年,今年刚结婚,英国的,2012年21岁的时候就在在第32届全英音乐奖中荣获英国最佳男艺人、英国最具突破艺人;2018年,获得第60届格莱美奖最佳流行歌手、最佳流行专辑奖。2019福布斯100名人榜排名第5位。
最后
🍅 硬核资料:关注即可领取PPT模板、简历模板、行业经典书籍PDF。
🍅 技术互助:技术群大佬指点迷津,你的问题可能不是问题,求资源在群里喊一声。
🍅 面试题库:由技术群里的小伙伴们共同投稿,热乎的大厂面试真题,持续更新中。
🍅 知识体系:含编程语言、算法、大数据生态圈组件(Mysql、Hive、Spark、Flink)、数据仓库、Python、前端等等。
网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!