Skip to content

Use better example in pd.lookup replacement #42106

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
MarcoGorelli opened this issue Jun 18, 2021 · 3 comments · Fixed by #42110
Closed

Use better example in pd.lookup replacement #42106

MarcoGorelli opened this issue Jun 18, 2021 · 3 comments · Fixed by #42110
Assignees
Milestone

Comments

@MarcoGorelli
Copy link
Member

#39171 (comment)

In the user guide, let's use

idx, cols = pd.factorize(df['col'])
df.reindex(cols, axis=1).to_numpy()[np.arange(len(df)), idx]

instead of the current workaround

https://pandas.pydata.org/pandas-docs/dev/user_guide/indexing.html#looking-up-values-by-index-column-labels

cc @erfannariman
also cc @quanghm in case you have further comments on this

@raghuabhishek
Copy link
Contributor

Hi MacroGorelli, Can I take this issue and work on it.

@MarcoGorelli
Copy link
Member Author

sure, PRs welcome

@raghuabhishek
Copy link
Contributor

Thanks MarcoGorelli, I have raised a PR #42110. Can you pls review it and let me know if there are changes required.

@jreback jreback added this to the 1.3 milestone Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants