eeco_haldia
eeco_haldia

Reputation: 45

Deleting Rows in a Dataframe

I want to delete some specific rows in a Dataframe in Python . The dataframe consists of a series of tables and we have to delete the rows where only the first cell has values . For example the in the bottom , rows highlighted in yellows.

enter image description here

Upvotes: 0

Views: 243

Answers (1)

Pavan Suvarna
Pavan Suvarna

Reputation: 501

If Unwanted rows have specific part string common then you could explicitly delete those using

df_new = df[~df.columnName.str.contains("FINANCIAL SERVICES")]

and if the row cells are NULL use dropna

df.dropna(subset=df.columns[1:], how= 'all', inplace = True)

Upvotes: 1

Related Questions