Skip to content

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

Closed
@cpcloud

Description

@cpcloud

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}

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugIndexingRelated to indexing on series/frames, not to indexes themselves

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions