python - 使用来自 YouTube 的数据的堆积条形图
问题描述
我正在从YouTube
API获取数据以进行绘图VideoCategories
,并country
在堆叠的绘图栏中 chart
:
我正在尝试:
country_category4 = df_AnzahlTag[['channelCountry', 'videoCategoryName']]
test5 = country_category4.set_index('channelCountry')['videoCategoryName'].value_counts()
test5.plot(kind='bar', stacked=True)
plt.show()
编辑:找到一个解决方案,只需使用 unstack()
df.groupby('channelCountry')['videoCategoryName'].value_counts().unstack().plot(kind="bar", stacked="True")
按类别
df.groupby('videoCategoryName')['channelCountry'].value_counts().unstack().plot(kind="bar", stacked="True")
也许没有我希望的那么有意义,但至少如果用语言表现出来的话,就清楚地表明了英语在音乐方面的主导地位
df.groupby('videoCategoryName')['videoTitleLanguage'].value_counts().unstack().plot(kind="bar", stacked="True")
解决方案
推荐阅读
- python - 将 scipy.signal.stft 数据传递给 librosa.feature.melspectrogram
- postgresql - PostgreSQL。存储函数或查询改进
- java - 我有一个 Java 程序,上面写着“索引 1 超出长度 1 的范围”
- git - Kubernetes 集群上的 Gitlab - 无法使用 git 克隆或推送
- cython - 编写 cython 库的性能不佳
- python - Spyder Python 3.7 为什么有些方法在点后没有显示?
- python - 如何使用python中的where子句从firestore中的数组中删除元素
- laravel - 如果验证码不是来自请求,我应该把它放在哪里?
- c# - 如何在 JetBrains Rider 中允许不安全的代码?
- amazon-web-services - AWS TCO 计算器是否不再活动?