ewa_07
ewa_07

Reputation: 11

How to hide specific rows in pandas dataframe

I have a df with books titles, authors etc. I want to hide some specific rows where the book_category = 'biography'.

The thing is that I just want to hide these rows - don't remove them from entire df as I can't change the shape of this df. I need to hide them only visually. I was trying with loc selection, but unfortunately this changed the shape of my df. Do you know the method how to do this operation?

Upvotes: 1

Views: 2123

Answers (1)

Zephyr
Zephyr

Reputation: 12496

You could save the rows you want in another temporary dataframe and display this one:

df2 = df[df['book_category'] != 'biography']

Upvotes: 2

Related Questions