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

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

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 :: How to loop over grouped Pandas dataframe? 
Python :: cross join pandas 
Python :: python order by date 
Python :: pyserial read 
Python :: python remove all elemnts in list containing string 
Python :: object value python 
Python :: python path to python executable 
Python :: urllib 
Python :: matplotlib log scale y axis base 
Python :: xml to excel python 
Python :: how to multiply a string in python 
Python :: __new__ python 
Python :: keras declare functional model 
Python :: pathlib remove extension 
Python :: use matplotlib in python 
Python :: what is self in python 
Python :: checking if a string contains a substring python 
Python :: To visualize the correlation between any two columns | scatter plot graph 
Python :: django now template tag 
Python :: subtract from dataframe column 
Python :: python rgb to hex 
Python :: display array of odd rows and even columns in numpy 
Python :: increase axis ticks pyplot 
Python :: cheat sheet python 
Python :: how to concat on the basis of particular columns in pandas 
Python :: pyplot savefig 
Python :: create a dataframe from dict 
Python :: python tkinter projects 
Python :: merge dicts python 
Python :: pretty size python 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =