数据分析 1

# some example

import pandas as pd
from pandas import Series,DataFrame

#数据提取
df = pd.read_excel('./测试数据.xlsx')
df.head()

#剔除无用的列
df.drop(labels=['none','none1'],axis=1,inplace=True) #

df.isnull().any(axis=1)
indexs = ~(df.isnull().any(axis=1))
df.loc[indexs]
len(df.loc[indexs])

df.dropna(0,"any")  #drop 系列0是行
df.shape

# 填充
n_df = df.fillna(method='bfill',axis=0).fillna(method='ffill',axis=0) #
n_df.isnull().any(axis=0)#检测哪些列中存在空值

猜你喜欢

转载自www.cnblogs.com/zhangchen-sx/p/10864443.html
今日推荐