[英]How to create dataframe from index and array
I have an array
and index
我有一个array
和index
array=array([1,2,3])
index=Index(['A','B','C'],dtype='object')
I'd like to concat them and create dataframe
like following我想连接它们并创建dataframe
如下
df
column data
A 1
B 2
C 3
I tried我试过了
pd.concat([index.array]) 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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.