Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to convert a list into a dataframe in python

from pandas import DataFrame

People_List = ['Jon','Mark','Maria','Jill','Jack']

df = DataFrame (People_List,columns=['First_Name'])
print (df)
Comment

Basic method of Converting List to Dataframe

# import pandas as pd 

import pandas as pd 
# list of strings 
list = ['Softhunt.net', 'Learn', 'coding', 'skills']
# Calling DataFrame constructor on list 
df = pd.DataFrame(list) 
print(df)
Comment

pandas list to df

# import pandas as pd 
import pandas as pd 
  
# list of strings 
lst = ['Geeks', 'For', 'Geeks', 'is',  
            'portal', 'for', 'Geeks'] 
  
# Calling DataFrame constructor on list 
df = pd.DataFrame(lst) 
df 
Comment

List to Dataframe

# import pandas as pd 

import pandas as pd 
# list of strings 
lst = ['fav', 'tutor', 'coding', 'skills']
# Calling DataFrame constructor on list 
df = pd.DataFrame(lst) 
print(df) 
Comment

convert list to dataframe

L = ['Thanks You', 'Its fine no problem', 'Are you sure']

#create new df 
df = pd.DataFrame({'col':L})
print (df)

                   col
0           Thanks You
1  Its fine no problem
2         Are you sure
Comment

how to convert a list to dataframe in python

import pandas as pd
from pandas import DataFrame
df = DataFrame(lst,columns=['num'])
Comment

change dataframe to list

df.values.tolist()
Comment

list of dataframe to dataframe

import pandas as pd
df = pd.concat(list_of_dataframes)
# easy way
Comment

convert list of lists to pandas dataframe

salary = [['Company', 'Job', 'Salary($)'],
          ['Google', 'Machine Learning Engineer', 121000],
          ['Google', 'Data Scientist', 109000],
          ['Google', 'Tech Lead', 129000],
          ['Facebook', 'Data Scientist', 103000]]
df = pd.DataFrame(salary[1:], columns=salary[0])
Comment

PREVIOUS NEXT
Code Example
Python :: python split every character in string 
Python :: python remove all elemnts in list containing string 
Python :: append dictionary to list python 
Python :: install play sound python terminal 
Python :: create requirement .txt 
Python :: run flask in debug mode 
Python :: Python how to compile to exe file 
Python :: python hide print output 
Python :: how to delete all instances of a model in django 
Python :: python for loop get iteration number 
Python :: python while loop 
Python :: keras declare functional model 
Python :: textclip python arabic 
Python :: how to install python dill 
Python :: most frequent word in an array of strings python 
Python :: get the name of a current script in python 
Python :: for loop with enumerate python 
Python :: How to round to 2 decimals with Python? 
Python :: nested loop in list comprehension 
Python :: add place in certain index python string 
Python :: numpy average 
Python :: print(hello world) 
Python :: python print with 2 decimals 
Python :: python - find specific name in a df 
Python :: python property 
Python :: python turtle spiral 
Python :: Command errored out with exit status 1: 
Python :: d-tale colab 
Python :: python tkinter text get 
Python :: extract email address using expression in django 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =