Reputation: 89
For example:
d=['a','b','c','d']
e=['1','2','3','4']
f=['e','f','g','h']
I am wondering how to output the following dataframe:
a b c d
1 2 3 4
e f g h
Thanks
Upvotes: 0
Views: 45
Reputation: 166
Try this:
data=[]
data.append(d)
data.append(e)
data.append(f)
data=pd.DataFrame(data)
print (data)
Upvotes: 0
Reputation: 2939
You can simply pass in the lists as rows into the DataFrame constructor
import pandas as pd
pd.DataFrame(data=[d,e,f])
Upvotes: 3