pandas icon indicating copy to clipboard operation
pandas copied to clipboard

ENH: Adding back lookup or value setting by indices

Open jasperhyp opened this issue 3 years ago • 2 comments

Feature Type

  • [X] Adding new functionality to pandas

  • [ ] Changing existing functionality in pandas

  • [ ] Removing existing functionality in pandas

Problem Description

As this discussion shows, there are use cases where we want specific loadings indexed by (row, col) pairs to be set to specific values. Unlike using .loc, indexing a group of columns and a group of rows of the same length would return only the values at corresponding positions.

Feature Description

This shouldn't be difficult...

Alternative Solutions

In numpy or pytorch or any numerical packages this is the default.

Additional Context

No response

jasperhyp avatar Aug 06 '22 20:08 jasperhyp

pls look at prior discussions this is not a very common or useful operation in pandas

jreback avatar Aug 06 '22 20:08 jreback

pls look at prior discussions this is not a very common or useful operation in pandas

Hi Jeff, Thanks for the pointers. I checked the previous discussions and I think there are some people requesting this functionality of lookup (as shown in #40140) and the main reason for deprecation is more on the performance side. My feature request arises more out of the need to set values for specific loadings indexed by (row, col) pairs rather than just looking them up, which I agree can be easily done by the current factorize functionality. But setting values is a more delicate thing and would require mapping back and forth the columns & indices if doing manually by first transforming to NumPy then transform back. Having a Pandas-native functionality wrapping around this pipeline of operations would be extremely helpful.

jasperhyp avatar Aug 07 '22 03:08 jasperhyp