In [ ]:
import MySQLdb
import netrc
import pandas
import datetime
import lastfmDb as lf
from plotly import __version__
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)
login = netrc.netrc().authenticators('lastfm.mysql')
if not login:
raise netrc.NetrcParseError('No authenticators for lastfm.mysql')
mysql = MySQLdb.connect(user=login[0],passwd=login[2],db=login[1], charset='utf8')
cursor = mysql.cursor()
In [ ]:
today = datetime.datetime.now()
print today.strftime('Generated on the %d %b %Y at %H:%M:%S')
In [ ]:
df = lf.retrieve_play_count_by_month_as_dataframe(cursor)
df.head()
In [ ]:
nbDays = '7'
df = lf.retrieve_top_tracks_as_dataframe(cursor, nbDays, 10)
iplot(lf.create_figure(df.Track, df.ArtistAlbumTrack, df.PlayCount, 'tracks', nbDays))
In [ ]:
nbDays = '30'
df = lf.retrieve_top_tracks_as_dataframe(cursor, nbDays, 10)
iplot(lf.create_figure(df.Track, df.ArtistAlbumTrack, df.PlayCount, 'tracks', nbDays))
In [ ]:
nbDays = '90'
df = lf.retrieve_top_tracks_as_dataframe(cursor, nbDays, 10)
iplot(lf.create_figure(df.Track, df.ArtistAlbumTrack, df.PlayCount, 'tracks', nbDays))
In [ ]:
nbDays = '120'
df = lf.retrieve_top_tracks_as_dataframe(cursor, nbDays, 10)
iplot(lf.create_figure(df.Track, df.ArtistAlbumTrack, df.PlayCount, 'tracks', nbDays))
In [ ]:
nbDays = '180'
df = lf.retrieve_top_tracks_as_dataframe(cursor, nbDays, 10)
iplot(lf.create_figure(df.Track, df.ArtistAlbumTrack, df.PlayCount, 'tracks', nbDays))
In [ ]:
nbDays = '365'
df = lf.retrieve_top_tracks_as_dataframe(cursor, nbDays, 10)
iplot(lf.create_figure(df.Track, df.ArtistAlbumTrack, df.PlayCount, 'tracks', nbDays))
In [ ]:
nbDays = 'null'
df = lf.retrieve_top_tracks_as_dataframe(cursor, nbDays, 10)
iplot(lf.create_figure(df.Track, df.ArtistAlbumTrack, df.PlayCount, 'tracks', nbDays))