Dreamer Dreamer - 21 days ago 7
Python Question

Convert series to other format using pandas

I have a data frame df with a column

"Name"
, which is a series of values like:

0 Brian
1 Natasha
2 Mike
3 Anthony
4 Steve


I want to convert this in below format:

["Brian","Natasha","Mike","Anthony","Steve"]


How do I perform this task using pandas?

Answer

Pandas Series have a tolist method.

df["Name"].tolist()