Skip to content

BUG: factorize with objects differentiate 0/1 from False, True #62888

Description

@jbrockmendel

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

ser = pd.Series([0, 1, True, False])

>>> ser.factorize()[1]
Index([0, 1], dtype='object')

Issue Description

factorize on object dtype doesn't differentiate 0 from False or 1 from True.

This is half of the issue behind #21108.

Expected Behavior

I'd expect the uniques to include [True, False, 1, 0]

Installed Versions

Details

Replace this line with the output of pd.show_versions()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    AlgosNon-arithmetic algos: value_counts, factorize, sorting, isin, clip, shift, diffBug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions