I have two lists:
l1 = ['0a',22,44]
l2 = ['0b',25,55,66]
Now I join them so that each list becomes a column of a data frame:
import pandas as p
df1 = p.DataFrame(zip(l1,l2))
df1
I received the data frame with 3 rows and 2 columns (the value 66
of l2
is missed). It looks identical to the definition of ndarray
, which says: "all columns must have the same number of rows if ndarray
is passed into dataframe". But I don't work with ndarray
!
If, however, I join lists as rows of a data frame, then Python saves 66
:
df2 = p.DataFrame([l1,l2])
Is there any way to pass lists into dataframe as columns, while saving all values of lists in dataframe