系列t的第一个值是NaN,而不是s。为什么即使系列具有相同的索引也是如此。
import numpy as np
import pandas as pd
s = pd.Series([1,2,3,4,5,6],index= [1,2,3,4,5,6])
t = pd.Series([2,4,6,8,10,12],index= [1,2,3,4,5,6])
df = pd.DataFrame(np.c_[s,t],columns = ["MUL1","MUL2"])
df["MUL2"] =t
df
Output:
MUL1 MUL2
0 1 NaN
1 2 2.0
2 3 4.0
3 4 6.0
4 5 8.0
5 6 10.0
问题是np.c_
返回没有索引值的二维数组: