Basically I need to convert a column I got a from a csv using pandas and put it into a list. It's currently a pandas object and I tried doing list(pandaObject) but that doesn't work. Does anybody have any ideas?
df = pandas.read_csv(csv_file)
years=df[['1987']] #Gets a a column
###Now I need something to convert years to a list###
years = df[['1987']]
returns a dataframe with only that column. Instead, you should first get a Series out of the column and then convert to a list:
years = df['1987'] #return a Series
years_list = years.tolist() #coverts Series to list
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments