Skip to content

BUG: Mismatch between get and set behavior for slices of floating indices #2727

Closed
@stephenwlin

Description

@stephenwlin

When df.index.inferred_type is 'floating', df.ix[start:end] uses only label-based indexing only when both start and end are floating on the getitem side but when either start or end are floating on the setitem side (where start and end are both either integers or floats within epsilon of integers)

In [2]: df=p.DataFrame(["a", "b", "c", "d"], index=[1.00, 2.00, 3.00, 4.00])

In [3]: df.ix[1.0:4] # uses positional indexing to get last three rows
Out[3]: 
   0
2  b
3  c
4  d

In [4]: df.ix[1.0:4.0] # uses label-based indexing to get all four rows
Out[4]: 
   0
1  a
2  b
3  c
4  d

In [5]: df.ix[1.0:4] = "y" # uses label-based indexing to set all four rows

In [6]: df
Out[6]:
   0
1  y
2  y
3  y
4  y

In [7]: df.ix[1.0:4.0] = "z" # uses label-based indexing to set all four rows

In [8]: df
Out[8]:
   0
1  z
2  z
3  z
4  z

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