-
Notifications
You must be signed in to change notification settings - Fork 0
/
graphActivity.py
47 lines (34 loc) · 1.41 KB
/
graphActivity.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates
import math
def favoritesOverTime(df):
plt.figure()
df['visdata'] = matplotlib.dates.date2num(df.loc[:,"Date"].loc[::-1])
plt.plot_date(df['visdata'], list(range(df.shape[0])))
plt.title("Length of Favorites Playlist Over Time")
plt.xlabel("Date")
plt.ylabel("# Of Songs")
def favoritesOverDuration(df):
plt.figure()
df['roundedDuration'] = round(df.loc[:,"duration"]/10000)*10
durationFreq = df.loc[:,'roundedDuration'].value_counts()
plt.scatter(durationFreq.keys(), durationFreq[:])
plt.title("Frequency to Song Length (rounded to 10s of seconds)")
plt.xlabel("Song length in seconds")
plt.ylabel("Frequency in Favorites")
plt.figtext(0.99, 0, "mean duration: " + str(df.loc[:,'roundedDuration'].mean()), horizontalalignment='right')
def favoritesTenpo(df):
plt.figure()
df['roundedTempo'] = (round(df.loc[:,'tempo']/8)*8)
tempoFreq = df.loc[:,'roundedTempo'].value_counts()
plt.scatter(tempoFreq.keys(),tempoFreq[:])
plt.title("Frequency to Tempo (divided by 8)")
plt.xlabel("Tempo")
plt.ylabel("# of Songs")
plt.figtext(0.99, 0.01, "mean tempo: " + str(df.loc[:,'roundedTempo'].mean()), horizontalalignment='right')
favDF = pd.read_csv('localdata/favorites.csv')
favoritesOverTime(favDF)
favoritesOverDuration(favDF)
favoritesTenpo(favDF)
plt.show()