Skip to content

Inconsistent error raising in indexing #14525

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
cyrusmaher opened this issue Oct 27, 2016 · 2 comments · Fixed by #29378
Closed

Inconsistent error raising in indexing #14525

cyrusmaher opened this issue Oct 27, 2016 · 2 comments · Fixed by #29378
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Milestone

Comments

@cyrusmaher
Copy link
Contributor

cyrusmaher commented Oct 27, 2016

A small, complete example of the issue

x = np.random.randn(2, 2)
y = pd.Series(range(2))
y.loc[range(2)] = x # succeeds
y.loc[:] = x # fails

Expected Output

Since we're assigning a 2D array to a 1D vector that is smaller than the raveled array, I would expect both assignments to fail.

@jreback jreback added Indexing Related to indexing on series/frames, not to indexes themselves Error Reporting Incorrect or improved errors from pandas Difficulty Intermediate labels Oct 28, 2016
@jreback jreback added this to the Next Major Release milestone Oct 28, 2016
@jreback
Copy link
Contributor

jreback commented Oct 28, 2016

sure if you want to jump into the deep end on indexing. yes this is prob not being checked.

@mroeschke
Copy link
Member

Looks like both the previously successful assignment now fails. Could use a test.

In [118]: y.loc[range(2)] = x

ValueError: shape mismatch: value array of shape (2,2) could not be broadcast to indexing result of shape (2,)

In [119]: pd.__version__
Out[119]: '0.26.0.dev0+652.g30362ed82'

@mroeschke mroeschke added good first issue Needs Tests Unit test(s) needed to prevent regressions and removed Error Reporting Incorrect or improved errors from pandas Indexing Related to indexing on series/frames, not to indexes themselves labels Oct 23, 2019
@jreback jreback modified the milestones: Contributions Welcome, 1.0 Nov 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Needs Tests Unit test(s) needed to prevent regressions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants