简体   繁体   中英

How to create dataframe from index and array

I have an array and index

array=array([1,2,3])

index=Index(['A','B','C'],dtype='object')

I'd like to concat them and create dataframe like following

df

column   data
A         1
B         2
C         3

I tried

pd.concat([index.array])

But didn't work well. How can I achieve them?

Thanks

Let us try

pd.Series(array,index=index).to_frame('data')
Out[144]: 
   data
A     1
B     2
C     3

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