Skip to content

BUG: Bug in setting with loc/ix a single indexer on a multi-index axis and a listlike (related to GH3777) #4766

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

Merged
merged 1 commit into from
Sep 7, 2013

Conversation

jreback
Copy link
Contributor

@jreback jreback commented Sep 6, 2013

related to #3777

This shows enlarging (and setting inplace)

In [8]: df = DataFrame(np.random.randint(5,10,size=9).reshape(3, 3),
   ...:    ...:                        columns=list('abc'),
   ...:    ...:                        index=[[4,4,8],[8,10,12]])

In [9]: 

In [9]: df
Out[9]: 
      a  b  c
4 8   8  8  8
  10  9  7  6
8 12  8  7  9

In [10]: df.loc[4,'d'] = [0,1.]

In [11]: df
Out[11]: 
      a  b  c   d
4 8   8  8  8   0
  10  9  7  6   1
8 12  8  7  9 NaN

In [12]: df.loc[4,'d'] = [3,4]

In [13]: df
Out[13]: 
      a  b  c   d
4 8   8  8  8   3
  10  9  7  6   4
8 12  8  7  9 NaN

Invalid assignments

In [10]: df.loc[4,'d'] = [3]
ValueError: cannot set using a multi-index selection indexer with a different length than the value

In [11]: df.loc[4,'d'] = [3,4,5]
ValueError: cannot set using a multi-index selection indexer with a different length than the value

jreback added a commit that referenced this pull request Sep 7, 2013
BUG: Bug in setting with loc/ix a single indexer on a multi-index axis and a listlike (related to GH3777)
@jreback jreback merged commit 22f04f7 into pandas-dev:master Sep 7, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant