Open anmyachev opened 2 years ago
I think the loc case is correct
I think the loc case is correct
for the case in the OP (without the edit) or for the swapped case ("Note: if you swap 2 lines from above, then the code will work!") or both?
Note this is a change in behavior from 1.3.5 when it worked for both cases and ordering did not matter.
I'll label as a regression, for now pending further investigation.
All of them should raise
to be clear, on main...
df = pd.DataFrame(np.zeros((256, 10)))
array_2d = np.zeros((256, 2))
df.loc[:, 0] = array_2d
df[0] = array_2d
works
df = pd.DataFrame(np.zeros((256, 10)))
array_2d = np.zeros((256, 2))
df[0] = array_2d
df.loc[:, 0] = array_2d
raises
All of them should raise
i'm ignoring the df["col33"] = array_2d
case as that was added to the OP later.
so both the above code samples (in this comment) should raise and there is a bug on master?
Note this is a change in behavior from 1.3.5 when it worked for both cases and ordering did not matter.
i'll do a bisect shortly to get more insight.
Yes I think so, if you use a list as indexer, e.g. [0], they are already raising.
also if you initial dataframe has multiple dtypes and we are running through the split path, they are also raising.
you can test this through adding df[100] = „a“ before doing the 2d assignment
first bad commit: [03dd698bc1e84c35aba8b51bdd45c472860b9ec3] BUG: DataFrame.__setitem__ sometimes operating inplace (#43406)
yet it is the loc
case that has changed behavior, only after a __setitem__ operation.
Haven't checked the behavior change, but I think that this works at all should be considered a bug.
removing from 1.4.x milestone.
Pandas version checks
[X] I have checked that this issue has not already been reported.
[X] I have confirmed this bug exists on the latest version of pandas.
[ ] I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
Inconsistent behavior of functions that should behave the same.
Expected Behavior
Either an exception should be thrown for both cases, or it should not, but also in both cases.
Installed Versions