Advertisement
Guest User

Untitled

a guest
Dec 8th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. ## here is the answer to problem 2 in '2 lines'
  2. csvFile = pd.read_csv('RollingStoneAlbumList.csv')
  3. csvFile["Genre"]= csvFile["Genre"].str.split(",", n = 1, expand = True) #source: https://www.geeksforgeeks.org/python-pandas-split-strings-into-two-list-columns-using-str-split/
  4. csvFile.groupby("Genre").count().sort_values('Number',ascending=False)[['Number']]
  5.  
  6. ## here it is without the method we haven't learned yet in only '1' line
  7. csvFile = pd.read_csv('RollingStoneAlbumList.csv')
  8. csvFile.groupby("Genre").count().sort_values('Number',ascending=False)[['Number']]
  9. #however, this is not the full solution as it does not sort by primary genre
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement