dataframe drop
时间: 2023-08-30 19:11:09 浏览: 76
pandas.DataFrame.drop_duplicates 用法介绍
Dataframe drop is a method used in pandas library to remove rows or columns from a dataframe. The drop method takes one or more labels as arguments, which can be either the row or column labels, and removes them from the dataframe. The syntax for dropping rows and columns is different.
To drop a row from a dataframe, we use the `drop()` method with the `axis` parameter set to 0:
```
df.drop(index, axis=0)
```
Here, `index` represents the index of the row to be dropped.
To drop a column from a dataframe, we use the `drop()` method with the `axis` parameter set to 1:
```
df.drop(column, axis=1)
```
Here, `column` represents the name or label of the column to be dropped.
The `drop()` method returns a new dataframe with the specified rows or columns removed. It does not modify the original dataframe.
阅读全文