convert list of lists to pandas dataframe

Solutions on MaxInterview for convert list of lists to pandas dataframe by the best coders in the world

showing results for - "convert list of lists to pandas dataframe"
Ella
12 Feb 2017
1import pandas as pd
2
3data = [['New York Yankees', 'Acevedo Juan', 900000, 'Pitcher'], 
4        ['New York Yankees', 'Anderson Jason', 300000, 'Pitcher'], 
5        ['New York Yankees', 'Clemens Roger', 10100000, 'Pitcher'], 
6        ['New York Yankees', 'Contreras Jose', 5500000, 'Pitcher']]
7
8df = pd.DataFrame.from_records(data)
Giulia
10 Oct 2016
1from pandas import DataFrame
2
3People_List = ['Jon','Mark','Maria','Jill','Jack']
4
5df = DataFrame (People_List,columns=['First_Name'])
6print (df)
7
Louis
24 May 2016
1salary = [['Company', 'Job', 'Salary($)'],
2          ['Google', 'Machine Learning Engineer', 121000],
3          ['Google', 'Data Scientist', 109000],
4          ['Google', 'Tech Lead', 129000],
5          ['Facebook', 'Data Scientist', 103000]]
6df = pd.DataFrame(salary[1:], columns=salary[0])
Stefano
21 Aug 2017
1L = ['Thanks You', 'Its fine no problem', 'Are you sure']
2
3#create new df 
4df = pd.DataFrame({'col':L})
5print (df)
6
7                   col
80           Thanks You
91  Its fine no problem
102         Are you sure
Simona
15 Aug 2018
1# Import pandas library
2import pandas as pd
3  
4# initialize list of lists
5data = [['tom', 10], ['nick', 15], ['juli', 14]]
6  
7# Create the pandas DataFrame
8df = pd.DataFrame(data, columns = ['Name', 'Age'])
9  
10# print dataframe.
11df
12
Gael
19 Apr 2016
1# import pandas as pd 
2
3import pandas as pd 
4# list of strings 
5lst = ['fav', 'tutor', 'coding', 'skills']
6# Calling DataFrame constructor on list 
7df = pd.DataFrame(lst) 
8print(df) 
9
similar questions
queries leading to this page
convert list of lists to pandas dataframe