How to Convert Pandas DataFrame into a List
In this short guide, you’ll see an example of converting Pandas DataFrame into a list.
Example of Converting Pandas DataFrame into a List
Let’s say that you have the following data about products and prices:
| product | price |
| Tablet | 250 |
| Printer | 100 |
| Laptop | 1200 |
| Monitor | 300 |
You then decided to capture that data in Python using Pandas DataFrame. At a certain point, you realized that you’d like to convert that Pandas DataFrame into a list.
To accomplish this goal, you may use the following Python code to convert the DataFrame into a list, where:
- The top part of the code, contains the syntax to create a DataFrame with the above data
- The bottom part of the code converts the DataFrame into a list using: df.values.tolist()
Here is the full Python code:
And once you run the code, you’ll get the following multi-dimensional list (i.e., list of lists):
Optionally, you may further confirm that you got a list by adding print(type(products_list)) at the bottom of the code:
As you can see, the original DataFrame was indeed converted into a list (as highlighted in yellow):
Convert an Individual Column in the DataFrame into a List
Let’s say that you’d like to convert the ‘product‘ column into a list.
You can then use the following template in order to convert an individual column in the DataFrame into a list:
Here is the complete Python code to convert the ‘product’ column into a list:
Run the code, and you’ll get the following list:
What if you want to append an additional item (e.g., Keyboard) into the ‘product’ list?
In that case, simply add the following syntax:
So the complete Python code would look like this:
You’ll now see the ‘Keyboard’ at the end of the list:
An Opposite Scenario
Sometimes, you may face an opposite situation, where you’ll need to convert a list to a DataFrame. If that’s the case, you may want to check the following guide that explains how to convert a list to a DataFrame in Python.
Convert dataFrame to list
I have a pandas dataframe that I convert to numpy array as follows:
which gives the following output:
However I want to obtain the list as follows:
Any idea how to do this?
2 Answers 2
Maybe you can use iloc or loc for selecting column and then tolist :
But maybe you need flatten :
![]()
Looks like you have a dataframe with one column and several rows. Remember that this is a two dimensional array, you have to slice the first column then list the values within that column.
This should do it:
df[0] — This selects all values in the first column. For the second column you’d use df[1] third df[2] and so on.
Convert Dataframe to a List in Python
In this tutorial, we will explore different methods to convert a dataframe to a list in Python. Depending upon how you want the data in the resulting list, there can be different methods. We’ll look at these methods in detail. By the end of this tutorial, you will have a clear understanding of how to convert dataframes to lists and be able to apply this knowledge to your own projects.
Converting Dataframe to a List
When converting the data in a pandas dataframe to a list, there can be multiple ways in which you may want the values in the resulting list to be depending upon your use case. For example,
- Dataframe to a list of all row values.
- Dataframe to a list of all column values.
- Dataframe to a list of dictionaries.
Let’s now look at the above use cases in detail with the help of some examples.
Dataframe to a list of all row values.
The goal here is to change the dataframe into a list of lists with each individual list containing the values of a single row. To convert a dataframe to a list of row values use df.values.tolist() where df is the dataframe you want to convert.
Let’s look at an example.
Here, we created a dataframe with three rows and two columns. The dataframe contains the name and age information of three people.
Let’s now convert the above dataframe to a list of row values.
You can see that the resulting list contains the row values as separate lists.
Dataframe to a list of column values
The goal here is to convert the dataframe to a list of lists with each individual list containing all the values of a single column. Use the following steps to convert a dataframe to a list of column values –
- Create an empty list to store the result.
- Iterate through each column in the dataframe and for each iteration append the list of column values to the above list.
Let’s look at an example. We’ll use the same dataframe as above.
Let’s now create a list of all column values from the above dataframe.
In the above example, we first create an empty list called result . Then, use a for loop to iterate over each column in the DataFrame df . For each column, we use the .values.tolist() method to convert the column values into a list, and append the resulting list of column values to the result list.
Finally, the result list is printed to the console using the print() function.
You can see we get the list of column values.
3) Dataframe to a list of dictionaries
The goal here is to convert the dataframe to a list of dictionaries where each dictionary represents a row. To convert a Pandas DataFrame to a list of dictionaries in Python, you can use the to_dict() method with the orient parameter set to ‘records’ . Let’s look at an example.
For the above dataframe, let’s create a list of dictionaries.
You can see that the resulting list contains a list of dictionaries with each dictionary containing the respective row values with the column names as keys.
Conclusion
In conclusion, we have learned how to convert a dataframe to a list in Python using three different methods: converting a dataframe to a list of rows, a list of columns, and a list of dictionaries.
Converting a dataframe to a list in Python is a common task in data analysis and can be achieved using different methods depending on the desired output format. By mastering these techniques, you can easily manipulate dataframes in Python and perform various data analysis tasks.
You might also be interested in –
Author

Piyush is a data professional passionate about using data to understand things better and make informed decisions. He has experience working as a Data Scientist in the consulting domain and holds an engineering degree from IIT Roorkee. His hobbies include watching cricket, reading, and working on side projects.
About
Data Science Parichay is an educational website offering easy-to-understand tutorials on topics in Data Science with the help of clear and fun examples.
How to Convert Pandas DataFrame to List?
Pandas tolist() function is used to convert Pandas DataFrame to list. In Python, pandas is the most efficient library for providing various functions to convert one data structure to another data structure. DataFrame is a two-dimensional data structure and it consists of rows and columns in form of a tabular format, which is used to store the data. Whereas a list is a single-dimensional data structure and it stores the collection of Data.
Using df.values().tolist() syntax we can easily convert Pandas DataFrame to a list. In this article, I will explain the tolist() function and using this how we can convert pandas DataFrame to a Python list, and also I explain how we can convert the Pandas DataFrame column to a list with several examples.
1. Quick Examples of Convert DataFrame to List
If you are in hurry, below are some quick examples of how to convert DataFrame to a list.
Let’s create a Pandas DataFrame with a Python dictionary of lists, pandas DataFrame columns names Courses , Fee , Duration , Discount .
To create a DataFrame, we need Data. So, we have created a Dictionary in which keys are column names and values are the lists of values.
2. Pandas Convert DataFrame to List using tolist()
In order to convert Pandas DataFrame to list use df.values.tolist() Here, df.values returns a DataFrame as a NumPy array. And, tolist() converts Numpy to list. Please remember that only the values in the DataFrame will be returned, and the axes labels will be removed.
Yields below output.
Again, the df.values return values present in the dataframe. tolist() will convert those values into a list.
3. Convert Pandas Column to List
By using Series.values.tolist() you can convert the Pandas DataFrame Column to List. df[‘Courses’] returns the DataFrame column as a Series and then use values.tolist() to convert the column values to list.
We consider that the columns of a DataFrame are Series objects hence, we can convert the columns of DataFrame into a list using the tolist() method. Let’s use tolist() to convert one of the columns (series) of DataFrame to list. For example,

Yields below output. Convert DataFrame column to list
4. Convert DataFrame to Nested List
We can convert DataFrame to the nested list by iterating all columns of the given DataFrame and these values are assigned into the temporary list. Finally, using append() we can append the temporary list to an empty list, where the lists are all column values of a given DataFrame. Here, df.columns get columns from DataFrame
Yields below output.
5. Convert Pandas Index Column to List
We can convert the pandas DataFrame index column to List using the below syntax.

Yields below output. Convert index column to list