In Pandas, you can delete a row in a DataFrame based on a certain column value by using the drop() method and passing the index label of the row you want to delete.
下面是一个例子,在一个包含身高、体重和性别的DataFrame中,我们将Gender列移动到第一列: importpandasaspd# 构建DataFramedata={'Height':[175,168,180,160],'Weight':[70,60,80,45],'Gender':['Male','Female','Male','Female']}df=pd.DataFrame(data)# 将Gender列移动到第一列gender=df...
DataFrame.drop( labels=None, axis=0, index=None, columns=None, level=None, inplace=False, errors='raise' ) # short forms df.drop(axis=None) # deletes a specified column df.drop(index=None) # deletes a specified row Let us understand with the help of an example. ...