Reputation: 5234
I have a pandas dataframe consisting of only one column of data. I want to convert the column of data into a list. The column has float datatype.
For example:
ColA
341321432
132184900
173840143
1432473928
Desired: 341321432, 132184900, 173840143, 1432473928
Below is my Python code:
df_gearME = pd.read_excel('Gear M&Es.xlsx')
df_gearME['ColA'].to_list()
But the error I get is as follows:
AttributeError: 'Series' object has no attribute 'to_list'
Upvotes: 2
Views: 27102
Reputation: 85442
Just do:
>>> list(df_gearME.ColA)
[341321432, 132184900, 173840143, 1432473928]
Or print it for horizontal output:
>>> print(list(f_gearME.ColA))
[341321432, 132184900, 173840143, 1432473928]
Upvotes: 8