获取此数据集。
我按包含 [0,1] 值的 Cancer_type 列对数据框进行了排序,
df_genes.sort_values(['Cancer_type'], ascending=True)
然后我重置索引。
df_genes.reset_index(drop=True,inplace=True)
重置索引会弄乱 Cancer_type 列。 我应该如何重置索引以保持 Cancer_type 列排序。 这link遵循相同的程序,但我得到不同的结果。
最佳答案
这个呢?
df_genes = df_genes.sort_values(['Cancer_type']).reset_index(drop=True)
关于python-3.x - 排序数据框后重置索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53332116/