你可以使用
apply你的列有检查
dtype它是否是
numeric或不检查
dtype.kind:
res = df.apply(lambda x: x.fillna(0) if x.dtype.kind in 'biufc' else x.fillna('.'))print(res) A B City Name0 1.0 0.25 Seattle Jack1 2.1 0.00 SF Sue2 0.0 0.00 LA .3 4.7 4.00 OC Bob4 5.6 12.20 . Alice5 6.8 14.40 . John


