+1 vote
in Programming Languages by (56.8k points)
I want to create a dataframe using lists. What is the Pythonic way to do this?

1 Answer

+1 vote
by (351k points)
selected by
 
Best answer

Here is an example to show how to create a pandas dataframe using lists. The list variables will be used as column names in the dataframe.

>>> a=[1,2,3,4]
>>> b=[11,12,13,14]
>>> c=[21,22,23,24]
>>> import pandas as pd
>>> df =pd.DataFrame(zip(a,b,c), columns=['a','b','c'])
>>> df
   a   b   c
0  1  11  21
1  2  12  22
2  3  13  23
3  4  14  24


...