for i inrange(50):# 行索引
index = np.random.randint(100,200,size =1)[0]
cols = df.columns
# 列索引
col = np.random.choice(cols)
df.loc[index,col]=None
for i inrange(20):# 行索引
index = np.random.randint(100,200,size =1)[0]
cols = df.columns
# 列索引
col = np.random.choice(cols)# not a number 不是一个数
df.loc[index,col]= np.NAN
for i inrange(1000):# 行索引
index = np.random.randint(100,2100,size =1)[0]
cols = df.columns
# 列索引
col = np.random.choice(cols)
df.loc[index,col]=None
df.isnull().sum()
df.head()
df.tail()
# 去重之后的数据
df['Python'].unique()
df['Python'].value_counts()
en = df['En'].value_counts()
en
en.index[0]
s = df.median()print(s,type(s))
zhongshu =[]for col in df.columns:
zhongshu.append(df[col].value_counts().index[0])
s = Series(zhongshu,index = df.columns)
s
df2 = df.fillna(s)
df2
df2.isnull().sum()
df.isnull().sum()
df3 = df.iloc[:20]
df3
'''method : {'backfill', 'bfill', 'pad', 'ffill', None}, default None
Method to use for filling holes in reindexed Series
pad / ffill: propagate last valid observation forward to next valid
backfill / bfill: use NEXT valid observation to fill gap'''
df3.fillna(method='bfill',axis =1)