REGR: Setting values with 'loc' and boolean mask mixes up values (all-True mask) · Issue #48701 · pandas-dev/pandas (original) (raw)
Navigation Menu
- Explore
- Pricing
Provide feedback
Saved searches
Use saved searches to filter your results more quickly
Appearance settings
Description
According to documentation, using loc
should work with Boolean arrays. However, the following does not seem to work:
import pandas as pd
n = 17
data = pd.DataFrame({ "name": n * ["a"], "x": range(n), "y": range(n) })
copy = data.copy()
idx = n * [True] data.loc[idx, ["x", "y"]] = data[["x", "y"]] assert data.equals(copy) # Raises assertion error
The weird thing is that if n is smaller then the code works. This has been tested on Pandas 1.5.0