Advertisement
Vitaliy_Novichikhin

11.5.1/3 5.Яндекс.Музыка: группировка данных

Mar 8th, 2022
1,423
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. import pandas as pd
  2. df = pd.read_csv('music_log_upd.csv')
  3. #группирую данные вокруг 'genre_name', отсеиваю по 'user_id'
  4. genre_grouping = df.groupby('user_id')['genre_name'].count()
  5. #print(genre_grouping) - проверка работоспобоности genre_grouping
  6.  
  7. # посчитаем количество жанров
  8. genre_counting = df.groupby('user_id')['genre_name'].sum()
  9. print(genre_counting.head(30))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement