我想连接以下两个数据集。任何帮助将不胜感激。
第一个数据total_pos
:
1170050176.9395077
第二个数据
p
:0 -0.000844
1 -0.002487
2 -0.004132
3 -0.006029
4 -0.004442
Length: 5, dtype: float64
我希望输出:
0 1170050176.9395077
1 -0.000844
2 -0.002487
3 -0.004132
4 -0.006029
5 -0.004442
Length: 6, dtype: float64
我的代码:
p = np.concatenate([total_pos,p])
错误:
p = np.concatenate([total_pos,p])
ValueError: zero-dimensional arrays cannot be concatenated
最佳答案
或使用numpy.hstack
:
arr = np.hstack([total_pos, s])
# or into series
s = pd.Series(np.hstack([total_pos, s]))
输出:
array([ 1.17005018e+09, -8.44000000e-04, -2.48700000e-03, -4.13200000e-03,
-6.02900000e-03, -4.44200000e-03])
关于python - 将标量与 Pandas 系列连接,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/58197739/