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.
在保留特定列之后,我们需要删除所有其他的列。为了做到这一点,我们只需使用Pandas的drop方法即可,该方法可以删除DataFrame中的某些行或列。下面是一个例子,我们保留一个包含身高、体重和性别的DataFrame中的身高和性别列,并删除其他所有列:import pandas as pd # 构建DataFrame data = {'Height': [175...
SyntaxDataFrame.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....