基本信息
源码名称:知乎数据清洗整理和结论研究
源码大小:2.30M
文件格式:.zip
开发语言:Python
更新时间:2021-02-22
×
请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
源码介绍
知乎数据清洗整理和结论研究
# 数据清洗 - 去除空值
# 要求:创建函数
# 提示:fillna方法填充缺失数据,注意inplace参数
def data_cleaning(df):
cols = df.columns
for col in cols:
if df[col].dtype == 'object':
df[col].fillna('缺失数据', inplace = True)
else:
df[col].fillna(0, inplace = True)
return(df)
# 该函数可以将任意数据内空值替换
data1_c = data_cleaning(data1)
data1_c.head(10)