DEV Community

Nilotpal Choudhury
Nilotpal Choudhury

Posted on

Answer: create list from pandas dataframe column values

Pandas DataFrame columns are Pandas Series when you pull them out, which you can then call x.tolist() on to turn them into a Python list. Alternatively you cast it with list(x).

import pandas as pd

data_dict = {'one': pd.Series([1, 2, 3], index=['a', 'b', 'c']),
             'two': pd.Series([1, 2, 3, 4],

Top comments (0)