SHARE
TWEET

Untitled

a guest Dec 8th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top