dfs是:
StockCode
84077K 32.694876
23005J 28.248135
85099BJ 24.581063
23084M 24.078340
85099FC 19.276526
Name: 127269, dtype: float64
其中127269是CustomerID
dfc是:
CustomerID
0 127269
我正在尝试使用以下命令连接dfs和dfc:
final_frame = pd.concat([dfc, dfs], axis=1)
我得到的结果是:
CustomerID 127269
0 127269.0 NaN
84077K NaN 32.694876
而我期望的结果是:
CustomerID StockCode
0 127269 84077K
print (dfs) gives me:
StockCode
84077K 32.694876
Name: 127269, dtype: float64
print(dfc) gives me:
CustomerID
0 127269
有人能建议怎样才能达到这个结果吗
您的问题是
dfs
是一个系列,而不是一个数据帧,您需要用它的索引的第一个值来连接。所以你应该使用:它应该给你预期的产出
我做了以下工作:
并得到以下输出:
相关问题 更多 >
编程相关推荐