The 6 AI Engineering Patterns, come build with Greg live:Β Starts Jan 6th, 2025
Leverage
Pandas functions

Convert DataFrame To List – pd.df.values.tolist()

Convert Pandas DataFrame to list of lists

So you want to change your nicely formatted DataFrame to a list of lists? Maybe you’re trying to get it ready for another Data Science package that doesn’t recognize pandas DataFrames.

pandas.DataFrame.values.tolist()

Pseudo Code: With your DataFrame’s values, change them into a list of lists.

Pandas DataFrame To List

.tolist() Parameters

None!

Now the fun part, let’s take a look at a code sample

Link to code

Official Documentation (note this is for Series.tolist())

On this page