Skip to content

support Array.insert when label is not given #879

Closed
@gdementen

Description

@gdementen
>>> arr = ndtest(3)
>>> arr.insert(-1, before='a1', label='before_a1')
a  a0  before_a1  a1  a2
    0         -1   1   2
>>> arr.insert(-1, before='a1')
KeyError: "axis 'a' not found in {}"

Here is what I would have expected.

>>> arr.insert(-1, before='a1')
a  a0  None  a1  a2
    0    -1   1   2

IIRC, I did this by design: if there is no label, it assumes the axis is present in "value". However, I regret this now as it is both annoying (*) and the error message is hard to understand (especially when this happens in some larger code). I took several minutes to figure out I had forgotten the label argument, so I expect other users could really have trouble figuring what the problem is.

(*) there are cases where you really don't care about the label: you just want the value inserted at the right place.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions