Skip to content

Dictionary assignment with loc with existing index doesn't properly match column names in dict #9874

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
cpcloud opened this issue Apr 13, 2015 · 4 comments · Fixed by #9877
Closed
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Milestone

Comments

@cpcloud
Copy link
Member

cpcloud commented Apr 13, 2015

uses the example DataFrame from #9857.

In [3]: df = pd.DataFrame({'x': [1,2,6], 'y': [2,2,8], 'z':[-5,0,5]})

In [4]: df = df.set_index('z')

In [5]: rhs = {'x': 9, 'y': 99}

In [6]: df.loc[5]
Out[6]:
x    6
y    8
Name: 5, dtype: int64

In [7]: df.loc[5] = rhs

In [8]: df
Out[8]:
                      x                    y
z
-5                    1                    2
 0                    2                    2
 5  {u'y': 99, u'x': 9}  {u'y': 99, u'x': 9}
@cpcloud cpcloud added Bug Indexing Related to indexing on series/frames, not to indexes themselves labels Apr 13, 2015
@cpcloud cpcloud added this to the 0.16.1 milestone Apr 13, 2015
@shoyer
Copy link
Member

shoyer commented Apr 13, 2015

I didn't realize that we supported dictionaries on the RHS of assignments :)

@jreback
Copy link
Contributor

jreback commented Apr 13, 2015

this does an .append(...) with the stuff on the rhs.

@jorisvandenbossche
Copy link
Member

Is this documented somewhere?

@cpcloud
Copy link
Member Author

cpcloud commented Apr 13, 2015

I can add some docs. I've got a fix for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Indexing Related to indexing on series/frames, not to indexes themselves
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants