pandas主要有三个用来删除的函数,.drop()、.drop_duplicates()、.dropna()。总结如下
- .drop()删除行、列
- .drop_duplicates()删除重复数据
- .dropna()删除空值(所在行、列)
为避免篇幅太长,将其分为两部分,不想看参数介绍的可以直接看实例。
本篇介绍.drop()
官方介绍:https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.drop.html#pandas.DataFrame.drop
DataFrame.drop(labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors='raise')[source]
Drop specified labels from rows or columns.
Remove rows or columns by specifying label names and corresponding axis, or by specifying directly index or column names. When using a multi-index, labels on different levels can be removed by specifying the level.
Parameters:
labels : single label or list-like
Index or