Sometimes, we want to convert Python Pandas DataFrame to list of lists.
In this article, we’ll look at how to convert Python Pandas DataFrame to list of lists.
How to convert Python Pandas DataFrame to list of lists?
To convert Python Pandas DataFrame to list of lists, we can use the tolist
method.
For instance, we write
df = pd.DataFrame([[1,2,3],[3,4,5]])
lol = df.values.tolist()
to call df.values.tolist
to return a nested list with the values in the df
data frame.
Conclusion
To convert Python Pandas DataFrame to list of lists, we can use the tolist
method.