SHARE
TWEET

Untitled

a guest Apr 18th, 2019 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import pandas as pd
  2. df = pd.read_csv('music_log_upd.csv')
  3.  
  4. genre_grouping = df.groupby('user_id')['genre_name']
  5.  
  6. def user_genres(group):
  7.   for col in group:
  8.     if len(col[1]) > 50:
  9.       user = col[0]
  10.       return user
  11.  
  12. search_id = user_genres(genre_grouping)
  13. music_user = df[(df['user_id'] == search_id) & (df['total_play_seconds'] > 0)]
  14. sum_music_user = music_user.groupby('genre_name')['total_play_seconds'].sum()
  15. # print(sum_music_user)
  16. count_music_user = music_user.groupby('genre_name')['total_play_seconds'].count()
  17. print(count_music_user)
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top