I have this dataframe:
d = {'col1': [1, 2,3,4,5], 'col2': [6,7,8,9,10]}
df = pd.DataFrame(data=d)
print(df)
which looks like this:
col1 col2
0 1 6
1 2 7
2 3 8
3 4 9
4 5 10
I then transform the col1 into a list:
a = df['col1'].values
print(a)
which looks like this:
[1 2 3 4 5]
I'd like to get the elements in list a
to look like this:
[1,2,3,4,5]
How can I do that in pandas?
CodePudding user response:
Just make it a list :)
list(df['col1'])
CodePudding user response:
Simply turn it to a list:
a = list(df['col1'].values)