Skip to content

setting values in a dataframe with duplicated keys #34034

Closed
@c-foschi

Description

@c-foschi

I have a dataframe with duplicated keys, and I need to assign values to some column of that dataframe, for some different keys. Dataframe indexes support duplicated keys, so I assume that this kind of work should be easy, if not I don't see why dataframes should be allowed to have duplicated keys. Anyway, setting the values like this:

df.loc[key, 'column']= vector

gives me the following error:

ValueError: Must have equal len keys and value when setting with an iterable

even if the number of times key appears in the index of df is equal to the length of vector. I think this should be fixed.

Thank you,
c. foschi

Metadata

Metadata

Assignees

Labels

IndexingRelated to indexing on series/frames, not to indexes themselvesNeeds TestsUnit test(s) needed to prevent regressions

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions