Home > Enterprise >  How to stop the table from returning to its default mode?
How to stop the table from returning to its default mode?

Time:10-10

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.

CodePudding user response:

assign the df_filtered result back to it

df_filtered = df_filtered[~((df_filtered['analysis'] == 'Pfam') & (df_filtered['nunique'] > 1))]
  • Related