Skip to content

Conversation

@jonathanho168
Copy link
Collaborator

@jonathanho168 jonathanho168 commented Dec 11, 2023

Given original info:

Original Data: ['a', 'b', 'c', 'c', 'd', 'e']
Original Codes: [0 1 2 2 3 4] returned by pd.factorize(original_data)

new_data = ['a', 'd', 'e', 'k']
new_codes, new_uniques = pd.factorize(new_data)
new_codes1, new_uniques1 = pd.factorize(new_data, original_factorization=(original_uniques, original_codes))

new_codes will be 0123 (functionality of existing factorize function did not change)
new_codes1 will be 0345 (we can pass in optional parameter)

Copy link
Collaborator

@minjooki minjooki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@minjooki minjooki merged commit f1a84bb into main Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants