pandas 缺失值不是NaN的处理情况
作者:互联网
import pandas as pd
import numpy as np
data = pd.Series([1, -999, 2, -999, -1000, 3])
# 替换单个值
# data.replace(-999, np.NaN, inplace=True) # 将 -999替换成为 Nan
# 替换多个值
# data.replace([-999, -1000], np.NaN, inplace=True)
# 对不同的值替换
# data.replace([-999, -1000], [np.nan, 0], inplace=True)
# 传入的参数可以是字典
data.replace({-999: np.nan, -1000: 0}, inplace=True)
print(data)
标签:NaN,999,inplace,缺失,True,np,replace,data,pandas 来源: https://blog.csdn.net/weixin_43229819/article/details/121318658