bokeh pandas_使用Pandas和Bokeh将Rolling Stone的500张最伟大专辑可视化
bokeh pandas
by Gautham Koorma
通过Gautham Koorma
使用Pandas和Bokeh将Rolling Stone的500张最伟大专辑可视化 (Rolling Stone’s 500 Greatest Albums Visualized Using Pandas and Bokeh)
In 2003, Rolling Stones Magazine polled musicians, producers, and industry executives about their favorite albums. The result was a special issue titled “The 500 Greatest Albums of All Time.”
2003年,《滚石杂志》(Rolling Stones Magazine)对音乐家,制作人和行业高管进行了投票,调查了他们最喜欢的专辑。 结果是一期名为“有史以来最伟大的500张专辑”的特刊。
The list — which they revised in 2012 — mainly features American and British music from the 1960s and the 1970s.
该清单在2012年进行了修订,主要包含1960年代和1970年代的美国和英国音乐。
As an ardent music fan and an aspiring music producer, I listen to a wide variety of genres. The Rolling Stones list served as an introduction to rock music for me back in the day.
作为热心的音乐迷和有抱负的音乐制作人,我喜欢听各种各样的音乐。 滚石乐队的清单在当时为我介绍了摇滚音乐。
One day I while browsing through Kaggle to pick up a simple data set and test my newly acquired data visualization skills, I stumbled upon the list uploaded as a CSV dataset. I decided to get my hands dirty by using pandas to explore the data and bokeh to visualize the results.
有一天,我在浏览Kaggle并选择一个简单的数据集并测试新获得的数据可视化技能时,偶然发现了以CSV数据集上传的列表。 我决定通过使用熊猫来探索数据并通过散景来可视化结果来弄脏我的手。
Bokeh is a Python library for interactive visualization. It features a powerful interface that supports high-level charting, intermediate-level plotting, and lower-level modeling.
Bokeh是用于交互式可视化的Python库。 它具有强大的界面,可支持高级图表,中级绘图和低级建模。
The complete code I used for reading, refining, exploring, and visualizing the data can be found on my GitHub page, and also in this notebook submitted on Kaggle.
我用于读取,精炼,探索和可视化数据的完整代码可以在我的GitHub页面上找到 ,也可以在Kaggle上提交的笔记本中找到 。
This post will describe the approaches I took, complete with my visualizations and the insight I gained from building them.
这篇文章将描述我采用的方法,并结合我的可视化效果以及从构建它们中获得的见解。
获取和构建数据 (Getting and Structuring the Data)
Getting the data was simple, since it was in a 500 x 6 excel spreadsheet. All I had to do was read it into a pandas data frame directly by using the read_excel()
function.
获取数据非常简单,因为它位于500 x 6的Excel电子表格中。 我要做的就是直接使用read_excel()
函数将其读入pandas数据框中。
The data frame had 500 rows, one for each album listing the Chart Number, Year, Album, Artist, Genre, and Subgenre. The Genre and Subgenre columns had multiple comma separated values in a string, so I had to split the string at the first comma and keep just the first value in new columns as the most relevant categorization of the album’s Genre and Subgenre.
数据框有500行,每张专辑一个,列出图表编号,年份,专辑,艺术家,流派和子流派。 “类型”和“子类型”列在字符串中具有多个逗号分隔的值,因此,我必须在第一个逗号处拆分字符串,并仅将新列中的第一个值保留为专辑的“类型”和“子类型”的最相关分类。
The master data frame became 500 x 8 after the Genres_Refined and Subgenres_Refined columns were added.
添加Genres_Refined和Subgenres_Refined列后,主数据帧变为500 x 8。
I used a Python 3.5.2 kernel (Anaconda 4.2.0 distribution) on a Jupyter notebook.
我在Jupyter笔记本上使用了Python 3.5.2内核(Anaconda 4.2.0发行版)。
探索数据并获得见解 (Exploring the Data and Gaining Insights)
I adopted the split-apply-combine strategy using pandas inbuilt groupby()
function in most cases and the reshaping strategy using pandas inbuilt pivot_table()
function for a single case. I fed the resulting data frames into bokeh charts and figures.
我采用了熊猫内置groupby()
的拆分应用组合策略 多数情况下使用“函数”,并且在单个情况下使用pandas内置的pivot_table()
函数进行重塑策略。 我将得到的数据框输入到散景图和图形中。
Here are the questions I posed and their resulting visualizations.
以下是我提出的问题及其产生的可视化效果。
名单上专辑数量最多的前10位歌手 (The top-10 artists who have the most albums on the list)
To get the top 10 artists, I used groupby()
on the artists column, took a count, and sorted the resulting data frame to get the top 10 artists having the most number of albums.
为了获得前10位艺术家,我在groupby()
列上使用了groupby()
,进行了计数,并对所得数据框进行了排序,以获取专辑数量最多的前10位艺术家。
To visualize the results, I used the a figure object from the bokeh.plotting library and drew black circles using the circle()
method.
为了使结果可视化,我使用了bokeh.plotting库中的一个Figure对象,并使用circle()
绘制了黑色圆圈 方法。
Clearly, the Beatles, Bob Dylan, and the Rolling Stones topped the list with 10 albums apiece.
显然,甲壳虫乐队,鲍勃·迪伦和滚石乐队以每张10张专辑高居榜首。
列表中的专辑数量的年度计数 (Year-wise count of the number of albums in the list)
To get this, I used groupby()
on the year column and took a count following which I sorted the data by year and plotted the resulting data frame using a line chart from bokeh.charts.
为此,我在year列上使用groupby()
并进行了计数,然后按年份对数据进行了排序,并使用了来自bokeh.charts的折线图来绘制结果数据框。
Maximum number of albums in the list were released in 1970. Albums released in the late 1960s and early 1970s were also found abundantly. The final spike is found in the early 1990s accounting for the outbreak of Pop, R&B, and Hip-Hop music.
该列表中的专辑数量最多,是1970年发行的。还发现了1960年代末和1970年代初发行的专辑。 最后一个高峰出现在1990年代初,原因是流行音乐,节奏布鲁斯音乐和嘻哈音乐的爆发。
热门流派和子流派 (Top Genres and Subgenres)
To identify the top genres and the subgenres within them, I reshaped the data using the pandas pivot_table() function in which I set the index as the Genre_Refined and Subgenre_Refine columns, and set the aggfunc
parameter to count.
为了识别顶级流派和其中的子流派,我使用pandasivot_table()函数重塑了数据,在该函数中,我将索引设置为Genre_Refined和Subgenre_Refine列,并将aggfunc
参数设置为count。
After taking a subset of the data frame using a condition that there should be more than 5 albums in a subgenre, I fed the data frame to a bokeh donut chart and set the palette to Purples9.
在子流派中应有5张以上专辑的条件下获取数据框的子集后,我将数据框馈入bokeh 甜甜圈图,并将调色板设置为Purples9。
Rock and its subgenres cover about 80% of the selection. Hip-Hop, R&B, Soul, Country, and Electronic music albums covered the remaining 20%.
岩石及其子流派覆盖了大约80%的选择。 嘻哈,R&B,灵魂,乡村和电子音乐专辑覆盖了剩余的20%。
各流派的歌曲(按年份) (Songs in each Genre by year)
To get this data, I did a groupby()
on Year and Genre_Refined, took the count, sorted the values by Year, and fed the resulting data frame to a bokeh heatmap. This time I used the Reds9 palette.
为了获得这些数据,我做了一个groupby()
在Year和Genre_Refined上,对计数进行计数,按Year对值进行排序,然后将得到的数据帧提供给bokeh 热图 。 这次我使用了Reds9调色板。
Rock music albums from the late 60s and the 70s are clearly the most numerous. Funk, Soul, and Jazz music albums reduced in numbers over the years, paving the way for Hip-Hop and Electronic albums.
60年代和70年代末的摇滚音乐专辑显然是最多的。 近年来,Funk,Soul和Jazz音乐专辑的数量有所减少,为嘻哈和电子专辑铺平了道路。
多年以来的岩石亚体 (Subgenres of Rock Over the Years)
To get this data, I did a groupby()
on the Year, Genre_Refined, and Subgenre_Refined, took a count, and subset the data frame to include just Rock in the Genre_Refined column. I then fed the resulting data frame to a bokeh heatmap.
为了获得此数据,我在Year,Genre_Refined和Subgenre_Refined上进行了一个groupby()
,进行了计数,并对数据框进行了子集处理,以在Genre_Refined列中仅包含Rock。 然后,我将得到的数据框输入到bokeh热图。
The initial few years were dominated by Rock & Roll, while Blues Rock and Pop Rock slowly increased in number by the mid 1960s. By the mid 1970s, Alternative Rock started coming into the picture, followed by Indie Rock in the mid 1980s.
最初的几年以摇滚乐为主,而布鲁斯摇滚乐和流行摇滚乐的数量在1960年代中期逐渐增加。 到1970年代中期,Alternative Rock开始出现,随后是1980年代中期的Indie Rock。
前10张专辑的摘要 (A summary of the Top 10 albums)
Finally, I summarized the top 10 albums in the list after grouping it by artist.
最后,在按艺术家分组后,我总结了列表中的前10张专辑。
The final results are not really surprising. The Rolling Stone Magazine list mostly contains songs from from Rock and its various subgenres, with a few outliers in the form of Hip-Hop, R&B, Soul, Country, and Electronic music albums.
最终结果并不令人惊讶。 《滚石杂志》列表主要包含来自Rock及其各个子流派的歌曲,以及一些以Hip-Hop,R&B,Soul,Country和Electronic音乐专辑形式出现的离群值。
If you’re like me and like to occasionally reconnect with the music of the Beatles, Bob Dylan, Rolling Stones, and the other pioneers of Rock and Roll during the 60s and 70s, I suggest you give these top albums a listen, then explore from there.
如果您像我一样,喜欢偶尔与甲壳虫乐队,鲍勃·迪伦,滚石乐队以及摇滚乐的其他先驱者重新建立联系,那么建议您试听一下这些顶级专辑,然后再进行探索从那里。
If you’re curious, you can read the full list of albums here.
如果您有好奇心,可以在此处阅读相册的完整列表。
I’m a technology consultant, data science enthusiast, and aspiring music producer. If you have writing opportunities or are interested in getting in touch for work, feel free to write to me at contact at gautham dot biz.
我是技术顾问,数据科学爱好者和有抱负的音乐制作人。 如果您有写作机会或有兴趣联系工作,请随时与gautham dot biz的联系人联系。
If you liked this article, please hit the recommend button and share it with your friends.
如果您喜欢这篇文章,请点击“推荐”按钮并与您的朋友分享。
翻译自: https://www.freecodecamp.org/news/visualising-rolling-stones-500-greatest-songs-using-bokeh-78ebc0eaff3f/
bokeh pandas
相关文章:

使用WinINet和WinHTTP实现Http訪问
使用WinINet和WinHTTP实现Http訪问 飘飘白云 l_zhaohui163.com 2007-11-30 Http訪问有两种方式,GET和POST,就编程来说GET方式相对简单点,它不用向server提交数据,在这个例程中我使用POST方式,提交数据value1与value2&a…

19-flutter的ListView 和 GridView的使用
ListView 的水平样式 和垂直样式 1 水平列表 import package:flutter/material.dart;const CITY_LIST ["北京","上海","广州","深圳","南京","郑州","武汉"];void main() > runApp(MyApp());clas…

linux下ndk编译命令行程序及配置
1.在http://developer.android.com/tools/sdk/ndk/index.html下载Android-ndk-r8e-linux-x86.tar.bz2,解压后把android-ndk-r8e添加到环境变量PATH中,例如, export PATH$PATH:/opt/studydisk/android-ndk-r8e 2.新建一个文件夹,如helloword&a…

vs2017数据可视化建模_介绍数据可视化社区调查2017
vs2017数据可视化建模by lars verspohl由拉斯韦斯波尔 介绍数据可视化社区调查2017 (Introducing the Data Visualization Community Survey 2017) Data visualization is a funny fish. It sort of stands on its own feet (or fins), but is also intimately entangled with…

20-flutter下拉刷新与上拉加载
1 RefreshIndicator 下拉刷新控件 下拉刷新的时候会回调 onRefresh 方法 RefreshIndicator(onRefresh: _handleRefresh,child: ListView(children: _buildList(),), ),2 上拉加载多 上拉加载更多的时候 override void initState() { super.initState();_scrollController.a…

PHP+redis实现超迷你全文检索
2014年10月31日 11:45:39 情景: 我们平台有好多游戏, 运营的同事在查询某一款游戏的时候, 目前使用的是html的select下拉列表的展现形式, 运营的同事得一个个去找,然后选中,耗时又费眼 效果: 输入"三国"或者"国三", 将自动列出所有包含"三国"的游…

Linux下的Shell编程(2)环境变量和局部变量
Shell Script是一种弱类型语言,使用变量的时候无需首先声明其类型。 局部变量在本地数据区分配内存进行存储,这个变量归当前的Shell所有,任何子进 程都不能访问本地变量。这些变量与环境变量不同,环境变量被存储在另一内存区&…

上拉电阻和下拉电阻_硬件基础:下拉电阻和上拉电阻如何工作
上拉电阻和下拉电阻by Taron Foxworth通过塔伦福克斯沃思(Taron Foxworth) 硬件基础:下拉电阻和上拉电阻如何工作 (Hardware fundamentals: how pull-down and pull-up resistors work) If you’ve ever wired up a button to an Arduino, you’ve come across thi…

时间序列学习笔记4
6. 重采样及频率转换 重采样(resample)表示将时间序列的频率进行转换的过程。可以分为降采样和升采样等。 pandas对象都有一个resample方法,可以进行频率转换。 In [5]: rng pd.date_range(1/1/2000, periods100, freqD)In [6]: ts Series(…

linux驱动编程入门实例
编辑 /*****hello.c*******/ #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> MODULE_LICENSE("Dual BSD/GPL"); static int hello_init() { printk("<1>hello\n"); return 0; } static void hello…

iOS UIView快速添加事件
给UIView 做一个延展 // // UIViewSKTap.h // MeiGouYouPin // // Created by coder on 2019/10/29. // Copyright © 2019 AlexanderYeah. All rights reserved. // #import <UIKit/UIKit.h> NS_ASSUME_NONNULL_BEGIN typedef void(^TapBlock)(void); interfac…

node.js中模块_在Node.js中需要模块:您需要知道的一切
node.js中模块by Samer Buna通过Samer Buna 在Node.js中需要模块:您需要知道的一切 (Requiring modules in Node.js: Everything you need to know) Update: This article is now part of my book “Node.js Beyond The Basics”.更新:这篇文章现在是我…

Sublime Text3配置Node.js开发环境
下载Nodejs插件,下载zip压缩包后解压链接: http://pan.baidu.com/s/1hsBk60k 密码: jrcv打开Sublime Text3,点击菜单“首选项(N)” >“浏览插件(B)”打开“Packages”文件夹,并将第1部的Node…

修改mysql的root密码
use msyql; update user set passwordpassword(新密码) where userroot; flush privileges; quitnet stop mysql #如果提示 发生系统错误5,就用管理员身份启动cmd.exe 转载于:https://www.cnblogs.com/walter371/p/4065904.html

iOS 开发之便捷宏定义
#define URL(A/*str*/) [NSURL URLWithString:A]// 图片 #define IMAGE(A/*str*/) [UIImage imageNamed:A]// 快速转换字符串 #define LD_STR(A/*str*/) [NSString stringWithFormat:"%ld",A] #define F2_STR(A/*str*/) [NSString stringWithFormat:"%.2f"…

rspec 测试页面元素_如何使用共享示例使您的RSpec测试干燥
rspec 测试页面元素by Parth Modi由Parth Modi 如何使用共享示例使您的RSpec测试干燥 (How to DRY out your RSpec Tests using Shared Examples) “Give me six hours to chop down a tree and I will spend the first four sharpening the axe.” — Abraham Lincoln“ 给我…

Windows搭建以太坊的私有链环境
Windows搭建以太坊的私有链环境 1、下载Geth.exe 运行文件,并安装https://github.com/ethereum/go-ethereum/releases/下载后,只有一个Geth.exe的文件2、cmd进入按章目录运行:geth -help看看是否可用geth命令3、在Geth安装目录下放置初始化创…

前50个斐波那契数
它有一个递推关系,f(1)1f(2)1f(n)f(n-1)f(n-2),其中n>23f(n)f(n2)f(n-2)-------------------------------------------- F(1) 1 F(2) 1 F(3) 2 F(4) 3 F(5) 5 F(6) 8 F(7) 13 F(8) 21 F(9) 34 F(10) 55 F(11) 89 F(12) 144 F(13) 233 F(14) 377 F(…

RAC -代替OC 中的代理
学以致用, 有的时候学习了很多理论 却还是忘了实践 OC 中代替代理 简洁编程 #import "ViewController.h" #import <ReactiveObjC.h> #import "SKView.h" interface ViewController ()endimplementation ViewController- (void)viewDidL…

深度学习 免费课程_深入学习深度学习,提供15项免费在线课程
深度学习 免费课程by David Venturi大卫文图里(David Venturi) 深入学习深度学习,提供15项免费在线课程 (Dive into Deep Learning with 15 free online courses) Every day brings new headlines for how deep learning is changing the world around us. A few e…

《音乐商店》第4集:自动生成StoreManager控制器
一、自动生成StoreManager控制器 二、查看 StoreManager 控制器的代码 现在,Store Manager 控制器中已经包含了一定数量的代码,我们从头到尾重新过一下。 1.访问数据库代码 首先,在控制器中包含了标准的 MVC 控制器的代码,为了使用…

StringUtils
/需要导入第三方jar包pinyin4j.jarimport net.sourceforge.pinyin4j.PinyinHelper;import java.util.regex.Matcher; import java.util.regex.Pattern;public class StringUtils {protected static final String TAG StringUtils.class.getSimpleName();/*** 增加空白*/public…

微信支付invalid total_fee 的报错
因为我的测试商品是0.01的 原因是微信支付的金额是不能带小数点的 直接在提交的时候 乘以 100操作 ,因为里面设置参数的时候是 以分为单位的 [packageParams setObject: price forKey:"total_fee"]; //订单金额,单位为分

帧编码 场编码_去年,我帮助举办了40场编码活动。 这是我学到的。
帧编码 场编码by Florin Nitu通过弗洛林尼图 去年,我帮助举办了40场编码活动。 这是我学到的。 (I helped host 40 coding events last year. Here’s what I learned.) Our local freeCodeCamp study group in Brasov, Romania just held its 40th event. We even…

HDU 4540 威威猫系列故事――打地鼠(DP)
D - 威威猫系列故事――打地鼠Time Limit:100MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit Status Practice HDU 4540Description 威威猫最近不务正业,每天沉迷于游戏“打地鼠”。 每当朋友们劝他别太着迷游戏,应该好好工…

iOS 在每一个cell上添加一个定时器的方案
1 首先创建一个数组,用来创建所有的定时器的时间 - (NSMutableArray *)totalLastTime {if (!_totalLastTime) {_totalLastTime [NSMutableArray array];}return _totalLastTime; }2 当从网络请求过来时间之后,循环遍历,行数和时间作为Key&a…

用字符串生成二维码
需要导入Zxing.jar包import android.graphics.Bitmap;import com.google.zxing.BarcodeFormat; import com.google.zxing.MultiFormatWriter; import com.google.zxing.WriterException; import com.google.zxing.common.BitMatrix;public class ZxingCode {/** * 用字符串生成…

在JavaScript中重复字符串的三种方法
In this article, I’ll explain how to solve freeCodeCamp’s “Repeat a string repeat a string” challenge. This involves repeating a string a certain number of times.在本文中,我将解释如何解决freeCodeCamp的“ 重复字符串重复字符串 ”挑战。 这涉及重…

杭电2099 整除的尾数
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid2099 解题思路:将a扩大100倍之后,再给它从加上i(i从0到99),一个一个的看哪一个能整除 反思:末两位是00的时候输出的是00(这种情况题目里面的测试数据给…

iOS 验证码倒计时按钮
具体使用 [SmsTimerManager sharedManager].second (int)time; [[SmsTimerManager sharedManager] resetTime]; [SmsTimerManager sharedManager].delegate self; [strongSelf updateTime];设置代理方法 更新按钮的标题 (void)updateTime { if ([SmsTimerManager sharedMan…