第一种方法 rate.replace(np.inf,np.NaN).fillna(0) 第二种方法,使用该方法改变inf成nan pd.options.mode.use_inf_as_na = True rate.fillna(0)