import pandas as pd
df = pd.DataFrame({'a':[1,3,5,7,4,5,6,4,7,8,9], 'b':[3,5,6,2,4,6,7,8,7,8,9]})
df['a'].values.tolist()
[1, 3, 5, 7, 4, 5, 6, 4, 7, 8, 9]
or you can just use
df['a'].tolist()
[1, 3, 5, 7, 4, 5, 6, 4, 7, 8, 9]
To drop duplicates you can do one of the following:
df['a'].drop_duplicates().values.tolist()
[1, 3, 5, 7, 4, 6, 8, 9]
list(set(df[‘a’])) # as pointed out by EdChum
[1, 3, 4, 5, 6, 7, 8, 9]
convert df to list[list]
df.values.tolist()
conver series to list
Series.tolist()
本文介绍了使用Python的Pandas库进行数据操作的方法,包括DataFrame的创建、列数据的转换为列表、去除重复数据以及将DataFrame和Series转换为列表的过程。通过示例展示了如何高效地处理和分析数据。
7150

被折叠的 条评论
为什么被折叠?



