Skip to content

Use better example in pd.lookup replacement #42106

Closed
@MarcoGorelli

Description

@MarcoGorelli

#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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions