I am currently doing a project with baby name data. I am looking at the most popular male and female baby names in each decade starting with the 1950s. I am trying to create a function that will print out the top name for the data set that I input.
So far I have successfully created two datasets for each decade (one male and the other female)
This is the code that I have for the function but I can't seem to figure out how to make it work...
def getTopName(data):
(data
.drop(columns =['sex', 'prop'])
.pivot(index = 'name', columns = 'year', values = 'n')
.sum(axis=1) = data['decade']
.sort_values(by = 'decade', ascending = False))
print data[0:1]
Any suggestions on how to accomplish this?
Its currently in longform. Can i create a middle function that converts it to wide form and builds a new column where the totals from each year (1960, 1961, ... 1969) can be added together?

