Creating from  multi-dimensional list to dataframe row with columns

Here we are taking input from multi-dimensional lists and assigning column names in the DataFrame() function

Syntax: pd.DataFrame(list,columns)

where

  1. list is an multidimensional list
  2. columns are the column names

Example:

Python3




# import pandas module
import pandas as pd
 
# consider a list
list1 = [["durga", "java", 90],
         ["gopi", "python", 80],
         ["pavani", "c/cpp", 94],
         ["sravya", "html", 90]]
 
# convert the list into dataframe
# row using columns from multi lists
data = pd.DataFrame(list1, columns=['student1',
                                    'subject',
                                    'marks'])
 
# display
data


Output:



How to Convert a List to a DataFrame Row in Python?

In this article, we will discuss how to convert a list to a dataframe row in Python.

Similar Reads

Method 1: Using T function

This is known as the Transpose function, this will convert the list into a row. Here each value is stored in one column....

Method 2: Creating from multi-dimensional list to dataframe row

...

Method 3: Using a list with index and columns

Here we are converting a list of lists to dataframe rows...

Method 4: Using zip() function

...

Method 5: Using a list of dictionary

Here we are getting data (rows ) from the list and assigning columns to these values from columns...

Method 6: Creating from  multi-dimensional list to dataframe row with columns

...

Contact Us