How to stop the table from returning to its default mode?

Question:

I’ve got a problem with a table in Pandas. I have these lines of code to delete rows with ‘Pfam’ value when it’s together with ‘SMART’ value for the same index (protein accession number).

df_filtered['nunique'] = df_filtered.groupby('protein accession').analysis.transform('nunique')
df_filtered[~((df_filtered['analysis'] == 'Pfam') & (df_filtered['nunique'] > 1))]

But if I want to change something within the table, it is again converting to the state before the above code was executed.
This is how the table looked like before the change:

image
and after I dropped one of the columns:

image2

Ps I’ve tried to add inplace=True but I got the syntax error.

Asked By: Aurinko

||

Answers:

assign the df_filtered result back to it

df_filtered = df_filtered[~((df_filtered['analysis'] == 'Pfam') & (df_filtered['nunique'] > 1))]
Answered By: Naveed
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.