Skip to content

Can't assign to subsets of MultiIndex columns DataFrames using partial labels #1803

Closed
@sadruddin

Description

Assigning a value (scalar or Series) to the subset of a dataframe with MultiIndex columns addressed by a partial label doesn't work.

df = pandas.DataFrame(index=[1, 3, 5], columns=pandas.MultiIndex.from_tuples([('A', '1'), ('A', '2'), ('B', '1')]))
df['A'] = 0.0 # Doesn't work
df['A'] = df['B', '1'] # Works, but adds a column instead of updating the two existing ones

df2 = df.T.copy()
df2.ix['A'] = 0.0 # Works
df2.ix['A'] = df2['B', '1'] # Works

The same thing in the rows dimension works as expected.

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