The Wayback Machine - https://web.archive.org/web/20231029190929/https://www.geeksforgeeks.org/make-a-pandas-dataframe-with-two-dimensional-list-python/
Open In App
Related Articles

Make a Pandas DataFrame with two-dimensional list | Python

Improve Article
Improve
Save Article
Save
Like Article
Like

As we know Python is a great language for doing data analysis, primarily because of the fantastic ecosystem of data-centric Python packages. Pandas is one of those packages and makes importing and analyzing data much easier.

Pandas Dataframe can be achieved in multiple ways. In this article, we will learn how to create a dataframe using two-dimensional List.

Example #1:




# import pandas as pd 
import pandas as pd  
      
# List1  
lst = [['Geek', 25], ['is', 30], 
       ['for', 26], ['Geeksforgeeks', 22]] 
  
# creating df object with columns specified    
df = pd.DataFrame(lst, columns =['Tag', 'number']) 
print(df )


Output:

             Tag  number
0           Geek      25
1             is      30
2            for      26
3  Geeksforgeeks      22

 
Example #2:




import pandas as pd  
      
# List1  
lst = [['tom', 'reacher', 25], ['krish', 'pete', 30], 
       ['nick', 'wilson', 26], ['juli', 'williams', 22]] 
      
df = pd.DataFrame(lst, columns =['FName', 'LName', 'Age'],
                                           dtype = float) 
print(df)


Output:

   FName     LName  Age
0    tom   reacher   25
1  krish      pete   30
2   nick    wilson   26
3   juli  williams   22

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 24 Oct, 2019
Like Article
Save Article
Similar Reads
Related Tutorials