import pandas as pd
import matplotlib.pyplot as plt
%matplotlib inline
/Users/alex/anaconda/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment. warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
features = pd.read_csv('./features.csv')
genres = features.pivot_table(index=['genre'])
genres
acousticness | danceability | duration_ms | energy | instrumentalness | key | liveness | loudness | mode | speechiness | tempo | time_signature | valence | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
genre | |||||||||||||
afrobeat | 0.193625 | 0.657720 | 325293.000000 | 0.764620 | 0.362610 | 4.280000 | 0.156580 | -8.248540 | 0.560000 | 0.064238 | 118.003660 | 3.960000 | 0.819140 |
ambient | 0.808006 | 0.313802 | 356026.600000 | 0.207660 | 0.896420 | 5.340000 | 0.128308 | -21.637880 | 0.520000 | 0.043848 | 104.529680 | 3.800000 | 0.154952 |
anime | 0.070591 | 0.567731 | 247769.961538 | 0.796692 | 0.037501 | 6.653846 | 0.218781 | -5.788577 | 0.538462 | 0.067327 | 128.222308 | 3.961538 | 0.543692 |
black-metal | 0.007900 | 0.267830 | 323244.980000 | 0.905980 | 0.450004 | 5.920000 | 0.248532 | -5.556940 | 0.500000 | 0.093300 | 123.503000 | 3.880000 | 0.142944 |
bluegrass | 0.656116 | 0.532480 | 214257.920000 | 0.500400 | 0.136489 | 4.760000 | 0.194482 | -10.648180 | 0.820000 | 0.035348 | 126.398900 | 3.980000 | 0.672560 |
blues | 0.538235 | 0.577940 | 232840.840000 | 0.486584 | 0.069761 | 6.060000 | 0.163476 | -10.790300 | 0.720000 | 0.062364 | 122.100680 | 3.800000 | 0.592994 |
bossanova | 0.646898 | 0.589300 | 228599.100000 | 0.441520 | 0.126728 | 5.240000 | 0.142324 | -12.119740 | 0.580000 | 0.064948 | 110.122200 | 3.900000 | 0.527140 |
breakbeat | 0.031182 | 0.657440 | 287303.860000 | 0.843440 | 0.385736 | 5.260000 | 0.290980 | -6.964620 | 0.580000 | 0.072158 | 132.304260 | 4.000000 | 0.483398 |
cantopop | 0.493778 | 0.568660 | 241340.420000 | 0.515040 | 0.000492 | 6.340000 | 0.165238 | -8.253980 | 0.800000 | 0.038944 | 123.476660 | 3.940000 | 0.402206 |
chicago-house | 0.034824 | 0.769000 | 346635.220000 | 0.761440 | 0.473907 | 5.920000 | 0.153958 | -9.518620 | 0.520000 | 0.081138 | 123.828960 | 3.980000 | 0.650290 |
classical | 0.928780 | 0.239826 | 397199.560000 | 0.105617 | 0.601574 | 5.540000 | 0.143718 | -24.030660 | 0.620000 | 0.047418 | 106.843580 | 3.520000 | 0.138680 |
comedy | 0.820660 | 0.537400 | 300982.840000 | 0.816520 | 0.000004 | 4.200000 | 0.799180 | -9.137940 | 0.780000 | 0.925240 | 92.867960 | 3.820000 | 0.335318 |
country | 0.209323 | 0.590700 | 217475.800000 | 0.711500 | 0.000413 | 4.760000 | 0.160952 | -6.290360 | 0.820000 | 0.034496 | 128.916640 | 3.980000 | 0.569840 |
dancehall | 0.141600 | 0.759240 | 238936.040000 | 0.635860 | 0.002520 | 5.520000 | 0.171078 | -7.704940 | 0.500000 | 0.174044 | 112.976920 | 4.000000 | 0.716240 |
death-metal | 0.000783 | 0.317240 | 271566.920000 | 0.948380 | 0.469871 | 5.620000 | 0.217542 | -5.361820 | 0.660000 | 0.117028 | 124.371980 | 3.900000 | 0.213648 |
deep-house | 0.062936 | 0.760000 | 343482.280000 | 0.680840 | 0.470242 | 6.260000 | 0.137702 | -9.324120 | 0.440000 | 0.071152 | 119.821120 | 4.000000 | 0.633920 |
detroit-techno | 0.055120 | 0.721720 | 334325.620000 | 0.710220 | 0.748006 | 5.360000 | 0.118352 | -11.125700 | 0.620000 | 0.070080 | 127.446380 | 3.960000 | 0.470436 |
disco | 0.171312 | 0.698040 | 288692.240000 | 0.673020 | 0.041529 | 5.500000 | 0.182584 | -10.180900 | 0.560000 | 0.059892 | 115.165620 | 4.000000 | 0.714380 |
drum-and-bass | 0.020532 | 0.538180 | 315946.220000 | 0.880240 | 0.470460 | 5.240000 | 0.256452 | -5.388340 | 0.580000 | 0.085210 | 156.773660 | 4.020000 | 0.409440 |
dub | 0.118665 | 0.784040 | 241208.560000 | 0.530360 | 0.269762 | 6.200000 | 0.143410 | -10.176920 | 0.580000 | 0.114904 | 116.066840 | 4.000000 | 0.692100 |
dubstep | 0.037162 | 0.654660 | 301627.520000 | 0.688440 | 0.492688 | 5.900000 | 0.239718 | -8.379800 | 0.480000 | 0.094790 | 133.109380 | 3.980000 | 0.363178 |
edm | 0.032340 | 0.637840 | 236900.180000 | 0.837620 | 0.172695 | 5.440000 | 0.231862 | -4.589680 | 0.480000 | 0.083580 | 124.919060 | 4.000000 | 0.381696 |
electro | 0.050363 | 0.819820 | 303212.000000 | 0.708160 | 0.274639 | 5.740000 | 0.174462 | -9.659440 | 0.440000 | 0.139188 | 114.880180 | 4.000000 | 0.593146 |
electronic | 0.081570 | 0.616100 | 308078.880000 | 0.737980 | 0.483505 | 6.160000 | 0.227694 | -8.577940 | 0.500000 | 0.059900 | 123.574580 | 3.980000 | 0.436876 |
emo | 0.035916 | 0.421180 | 218001.180000 | 0.868860 | 0.004963 | 5.600000 | 0.214354 | -4.888620 | 0.720000 | 0.067970 | 136.535080 | 4.000000 | 0.456526 |
folk | 0.556774 | 0.544520 | 230853.580000 | 0.405122 | 0.018474 | 5.300000 | 0.152604 | -11.653160 | 0.840000 | 0.037260 | 113.190800 | 3.900000 | 0.464636 |
forro | 0.411410 | 0.632975 | 218626.075000 | 0.702650 | 0.000756 | 5.700000 | 0.246755 | -7.983700 | 0.700000 | 0.073927 | 121.888250 | 4.000000 | 0.741850 |
funk | 0.266844 | 0.677560 | 275462.160000 | 0.621080 | 0.024031 | 5.700000 | 0.172622 | -10.034280 | 0.480000 | 0.069694 | 114.166060 | 3.980000 | 0.711120 |
gospel | 0.244075 | 0.474780 | 333288.260000 | 0.682880 | 0.000059 | 4.880000 | 0.360328 | -6.464720 | 0.720000 | 0.085462 | 114.108880 | 3.900000 | 0.382234 |
grindcore | 0.007348 | 0.308920 | 204903.080000 | 0.944960 | 0.506760 | 4.800000 | 0.250684 | -5.909440 | 0.660000 | 0.138680 | 118.991140 | 3.900000 | 0.193340 |
... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
mandopop | 0.466924 | 0.566240 | 253581.620000 | 0.533520 | 0.001517 | 5.760000 | 0.205558 | -7.981760 | 0.600000 | 0.040550 | 122.169860 | 3.900000 | 0.409370 |
metal | 0.006389 | 0.383640 | 284546.380000 | 0.905560 | 0.153897 | 4.880000 | 0.203288 | -6.575800 | 0.600000 | 0.084044 | 131.482100 | 3.960000 | 0.360216 |
metalcore | 0.001694 | 0.391260 | 240952.640000 | 0.938640 | 0.064720 | 5.760000 | 0.278136 | -4.078360 | 0.420000 | 0.109646 | 132.195120 | 3.900000 | 0.320750 |
minimal-techno | 0.062119 | 0.757180 | 405807.960000 | 0.615920 | 0.801182 | 5.600000 | 0.110960 | -10.545540 | 0.500000 | 0.070916 | 124.131900 | 3.960000 | 0.403188 |
mpb | 0.508788 | 0.628460 | 221105.180000 | 0.527840 | 0.021115 | 5.880000 | 0.194190 | -9.955520 | 0.680000 | 0.073070 | 113.383720 | 3.960000 | 0.579980 |
new-age | 0.784296 | 0.343794 | 275228.700000 | 0.251992 | 0.769855 | 4.340000 | 0.124146 | -16.822280 | 0.520000 | 0.036828 | 107.089100 | 3.760000 | 0.169904 |
opera | 0.961920 | 0.299240 | 287407.640000 | 0.149158 | 0.056603 | 4.500000 | 0.188350 | -18.766360 | 0.780000 | 0.051992 | 100.087620 | 3.720000 | 0.120082 |
pagode | 0.400796 | 0.639360 | 220024.760000 | 0.716640 | 0.000893 | 5.880000 | 0.319220 | -7.604140 | 0.720000 | 0.069288 | 121.445040 | 3.980000 | 0.717540 |
pop | 0.086014 | 0.630100 | 219789.980000 | 0.756760 | 0.001674 | 5.100000 | 0.238754 | -5.300780 | 0.560000 | 0.075096 | 121.125820 | 4.040000 | 0.574008 |
power-pop | 0.054280 | 0.473220 | 214361.820000 | 0.794640 | 0.024120 | 4.720000 | 0.218406 | -7.419700 | 0.820000 | 0.051680 | 135.484100 | 4.000000 | 0.635972 |
progressive-house | 0.026135 | 0.644660 | 301828.560000 | 0.773160 | 0.371732 | 5.260000 | 0.220550 | -6.655120 | 0.460000 | 0.051572 | 128.326080 | 3.960000 | 0.362622 |
punk | 0.024797 | 0.423840 | 187779.160000 | 0.926620 | 0.041636 | 5.200000 | 0.238742 | -5.110820 | 0.840000 | 0.084058 | 135.192720 | 3.980000 | 0.568150 |
reggae | 0.196730 | 0.771840 | 235826.420000 | 0.546260 | 0.096074 | 6.160000 | 0.140354 | -9.074840 | 0.580000 | 0.125372 | 117.858920 | 4.000000 | 0.737720 |
reggaeton | 0.162510 | 0.753160 | 229178.680000 | 0.794100 | 0.006527 | 4.800000 | 0.180474 | -5.714360 | 0.540000 | 0.100150 | 117.349640 | 3.980000 | 0.723340 |
rock | 0.111992 | 0.505820 | 254411.540000 | 0.739220 | 0.027947 | 5.020000 | 0.163194 | -7.826220 | 0.780000 | 0.044692 | 124.289160 | 3.980000 | 0.587600 |
rockabilly | 0.379045 | 0.557880 | 177943.440000 | 0.719900 | 0.013891 | 4.520000 | 0.280162 | -8.682020 | 0.720000 | 0.057298 | 129.380560 | 3.940000 | 0.750640 |
salsa | 0.478400 | 0.671300 | 291714.180000 | 0.730180 | 0.019830 | 5.180000 | 0.188084 | -6.784400 | 0.580000 | 0.052146 | 114.876260 | 4.000000 | 0.804180 |
samba | 0.525652 | 0.619060 | 208988.440000 | 0.518260 | 0.017577 | 5.540000 | 0.169942 | -10.270080 | 0.680000 | 0.073428 | 108.171380 | 3.960000 | 0.652080 |
sertanejo | 0.454796 | 0.623600 | 195895.100000 | 0.713980 | 0.000453 | 4.860000 | 0.310446 | -5.386840 | 0.880000 | 0.055912 | 133.122060 | 3.920000 | 0.673640 |
show-tunes | 0.788200 | 0.413960 | 224214.300000 | 0.341008 | 0.001015 | 6.060000 | 0.187220 | -11.522420 | 0.820000 | 0.079528 | 120.701340 | 3.820000 | 0.346584 |
singer-songwriter | 0.385641 | 0.557680 | 250249.780000 | 0.501360 | 0.006865 | 5.540000 | 0.155638 | -10.541160 | 0.880000 | 0.040616 | 113.393080 | 3.960000 | 0.533196 |
ska | 0.090876 | 0.563240 | 199140.700000 | 0.827180 | 0.001259 | 4.540000 | 0.201826 | -5.797040 | 0.740000 | 0.077078 | 136.221700 | 3.980000 | 0.759160 |
sleep | 0.747766 | 0.215716 | 1239096.320000 | 0.409629 | 0.832520 | 4.520000 | 0.288544 | -23.095400 | 0.600000 | 0.073678 | 98.982740 | 3.700000 | 0.056940 |
soul | 0.363049 | 0.638000 | 238602.620000 | 0.579460 | 0.034669 | 5.960000 | 0.172014 | -9.918420 | 0.560000 | 0.049062 | 110.639260 | 3.940000 | 0.683700 |
synth-pop | 0.073841 | 0.630240 | 242056.980000 | 0.769820 | 0.043683 | 5.000000 | 0.210124 | -7.229760 | 0.640000 | 0.047606 | 125.175580 | 4.000000 | 0.614140 |
tango | 0.738560 | 0.536560 | 220321.360000 | 0.380108 | 0.223064 | 5.420000 | 0.191322 | -9.994480 | 0.500000 | 0.069454 | 116.285080 | 3.880000 | 0.527880 |
techno | 0.038643 | 0.731100 | 364225.720000 | 0.696600 | 0.777018 | 5.160000 | 0.123194 | -10.597580 | 0.500000 | 0.072574 | 127.426260 | 3.960000 | 0.441222 |
trance | 0.014460 | 0.557800 | 297402.400000 | 0.828460 | 0.488884 | 5.600000 | 0.227018 | -7.714040 | 0.380000 | 0.051678 | 132.449940 | 3.980000 | 0.310742 |
trip-hop | 0.188699 | 0.645580 | 280112.040000 | 0.631780 | 0.469606 | 5.480000 | 0.163460 | -8.225180 | 0.460000 | 0.054512 | 116.069180 | 3.960000 | 0.449468 |
work-out | 0.081505 | 0.701900 | 243401.780000 | 0.765120 | 0.196047 | 5.520000 | 0.207500 | -8.328400 | 0.540000 | 0.070756 | 126.851600 | 4.000000 | 0.583880 |
76 rows × 13 columns
fig, ax = plt.subplots(figsize=(20, 20))
for k, v in genres.iterrows():
ax.annotate(k, (v['valence'], v['energy']))
ax.set_xlabel('Valence (musical positiveness conveyed by a track)')
_ = ax.set_ylabel('Energy (perceptual measure of intensity and activity)')
fig, ax = plt.subplots(figsize=(20, 20))
for k, v in genres.iterrows():
ax.annotate(k, (v['valence'], v['danceability']))
ax.set_xlabel('valence')
_ = ax.set_ylabel('danceability')
fig, ax = plt.subplots(figsize=(20, 20))
genres.plot.scatter('tempo', 'loudness', ax=ax)
for k, v in genres.iterrows():
ax.annotate(k, (v['tempo'], v['loudness']))