学习Pandas.DataFrame(3)
dropping and splitting dataframe
handing missing and duplicated rows
dropping column and splitting dataframe
# 从dataframe中删除列,并返回一个新dataframe
dataframe.drop(columns=['col1','col2'...])
# 从dataframe中删除列,加inplace参数直接修改源dataframe
dataframe.drop(columns=['col1','col2'...], inplace=True)
# 从dataframe中抽取几列作为一个新的dataframe
new_df = dataframe.loc[:,['col1', 'col2'...]]
handing missing value in columns and duplicated rows
# 删除dataframe中含有NaN的行,返回一个新的dataframe,info()可以列出哪些列少值
new_df = dataframe.dropna()
# 删除dataframe中含有NaN的行,加inplace参数直接修改源dataframe
dataframe.dropna(inplace=True)
# 列出duplicated的行
dataframe.duplicated()
# 删除duplicated的行并直接修改源dataframe
dataframe.drop_duplicates(inplace=True)
TO BE CONTINUED…