Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Devide Pandas dataframe into list of rows containing all columns

I need to devide Pandas dataframe into list of rows with all columns. That means that if there’s a dataframe with n rows and m columns I need to make a list of n elements and each element should be 1 x m row.

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

It looks like you want:

df.values.tolist()

example:

df = pd.DataFrame([['A', 'B', 'C'],
                   ['D', 'E', 'F']])

df.values.tolist()

output:

[['A', 'B', 'C'],
 ['D', 'E', 'F']]
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading