Ahs*_*566 3 dataframe python-3.x pandas
获取这个数据集。
我按 Cancer_type 列对数据框进行排序,其中包含 [0,1] 值,
df_genes.sort_values(['Cancer_type'], ascending=True)
然后我重置了索引。
df_genes.reset_index(drop=True,inplace=True)
Run Code Online (Sandbox Code Playgroud)
重置索引会弄乱 Cancer_type 列。我应该如何重置索引以保持 Cancer_type 列的排序。此链接遵循相同的过程,但我得到不同的结果。
那这个呢?
df_genes = df_genes.sort_values(['Cancer_type']).reset_index(drop=True)
Run Code Online (Sandbox Code Playgroud)