简体   繁体   中英

Pandas Dataframe

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

You can simply pass in the lists as rows into the DataFrame constructor

import pandas as pd
pd.DataFrame(data=[d,e,f])

Try this:

data=[]
data.append(d)
data.append(e)
data.append(f)
data=pd.DataFrame(data)
print (data)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM