我认为有不同dtypes
的indexes
,所以需要相同的类型 - 例如演员object
(显然str
)int
:
a = pd.Series([0.27, 0.11, 0], index=['14','15','16']) b = pd.Series([0.150286, 0.108026, 0], index=[14,15,16]) print (a) 14 0.27 15 0.11 16 0.00 dtype: float64 print (b) 14 0.150286 15 0.108026 16 0.000000 dtype: float64 print (a.index.dtype) object print (b.index.dtype) int64 #cast to int a.index = a.index.astype(int) print (a.div(b)) 14 1.796575 15 1.018273 16 NaN dtype: float64