Home > Net >  Delete Rows from Object Type Column
Delete Rows from Object Type Column

Time:11-26

My objective is to delete all the rows that have the word Drop in the column Drop.

The column has the next properties:

df.dtypes['Drop']: dtype('O')

type(df['Drop']): pandas.core.series.Series

I have tried:

indexNames = df[df['Drop'] == 'Drop'].index
df.drop(indexNames, inplace=True)

df.drop(df['Drop'] == 'Drop', axis=0)

df['Drop_1'] = df.where((df['Drop'] == 'Drop'), 1, 0)
df.drop(df['Drop_1'] == 1, axis=0)
df.drop(df['Drop_1'])

CodePudding user response:

If you want to remove rows from the dataframe where Drop is is in the Drop column for those rows:

df = df[~df['Drop'].astype(str).str.contains('Drop')]
  • Related