`#读取目标excel表,忽略前面2行
df=pd.read_excel(r‘F:\人工智能_优学\Pandas-learn-code\pandas-learn-code\datas\student_excel\student_excel.xlsx‘,skiprows=2)
df.dropna(axis=‘columns‘,how=‘all‘,inplace=True)
df.dropna(axis=‘index‘,how=‘all‘,inplace=True)
df.loc[:,‘分数‘]=df[‘分数‘].fillna(0)
df.loc[:,‘姓名‘]=df[‘姓名‘].fillna(method=‘ffill‘)
df.to_excel(r‘F:\人工智能_优学\Pandas-learn-code\pandas-learn-code\datas\student_excel\student_excel_clean_2.xlsx‘,index=False)`
8.Pandas对缺失值的处理(Excel表清洗格式异常的数据)
原文:https://www.cnblogs.com/hisweety/p/13347513.html