問題
從http://www.digitalanalytics.id.au/static/files/artists-spotify-clean.csv中讀取資料,
從統計和可視化上描述變數popularity和followers。
從統計和可視化上分析popularity和followers之間的關系。
問題原文是
Read data from http://www.digitalanalytics.id.au/static/files/artists-spotify-clean.csv
Describe the variables popularity and followers, both statistically and visually. Summarize your findings/interpretation of the result in # a comment.
Analyse the relationship between popularity and followers, both statistically and visually. Summarize your findings/interpretation of the result in # a comment.
現在寫成這樣,18行報錯
import pandas as pd
import researchpy as rp
import matplotlib.pyplot as plt
df = pd.read_csv('http://www.digitalanalytics.id.au/static/files/artists-spotify-clean.csv',sep=';')
print(df['popularity'].describe())
plt.hist(df['popularity'],bins=100)
plt.ticklabel_format(style='plain')
plt.xticks(rotation='vertical')
plt.tight_layout()
plt.savefig('histo.pdf')
plt.clf()
print(df['followers'].describe())
plt.hist(df['followers'],bins=100)
plt.ticklabel_format(style='plain')
plt.xticks(rotation='vertical')
plt.tight_layout()
plt.savefig('histo.pdf')
plt.clf()
print(rp.correlation.corr_pair(df[['popularity', 'followers']]))
plt.scatter(df['popularity'], df['followers'])
plt.xlabel('popularity')
plt.ylabel('Number of followers')
plt.ticklabel_format(style='plain')
plt.xticks(rotation='vertical')
plt.tight_layout()
plt.savefig('scatterplot.pdf')
plt.clf()
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/283665.html
下一篇:幫忙解一道陣列題
