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
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
how to convert a list to dataframe in python
import pandas as pd
from pandas import DataFrame
df = DataFrame(lst,columns=['num'])
pass list of columns names in pandas
>>> import pandas
>>> # create three rows of [0, 1, 2]
>>> df = pandas.DataFrame([range(3), range(3), range(3)])
>>> print df
0 1 2
0 0 1 2
1 0 1 2
2 0 1 2
>>> my_columns = ["a", "b", "c"]
>>> df.columns = my_columns
>>> print df
a b c
0 0 1 2
1 0 1 2
2 0 1 2
list to dataframe columns
import pandas as pd
lst = [1,2,3]
df = pd.DataFrame([lst])
df.columns =['col1','col2','col3']
df
to get this:
col1 col2 col3
0 1 2 3
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us