Take this dataset.

I sorted the data frame by Cancer_type column which contains [0,1] values,
df_genes.sort_values(['Cancer_type'], ascending=True)

Then I reset the index.
df_genes.reset_index(drop=True,inplace=True)

Resetting index messes up the Cancer_type column. How should I reset the index keeping the Cancer_type column sorted. This link follows same procedure but I'm getting different results.
What about this?
df_genes = df_genes.sort_values(['Cancer_type']).reset_index(drop=True)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With