Skip to content

Why .sort_values() on column containing same values shuffles entire dataframe ? #39877

Closed
@artsheiko

Description

@artsheiko
df = pd.DataFrame({
    'col1': ['A', 'A', 'A', 'A', 'A', 'A']*15,
    'col2': [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]*15,
    'col3': [0, 1, 9, 4, 2, 3]*15,
    'col4': ['a', 'B', 'c', 'D', 'e', 'F']*15
})
df.sort_values('col2', ascending=True)

Why this operation disorders the entire dataframe ? The same will be produced if the function will be applied for the col1.

image

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions