I have a csv file that has data looks similar to this:
Year Age
2001 58
2006 52
2006 12
2001 50
2012 59
2017 46
So I want to extract these two rows into two different list.
with open('age.csv', 'r') as files:
next(files) # skip header
for row in file_path:
years = row[0]
return years, average_age
But this will only give me 20, 20, 20, something that I didn't want it to show.
So that I can have like:
years = [2001, 2006, 2006, 2001, blabla]
However, for age, I am planning to get the average age for each year. But I don't know how in this case.