Skip to content

ENH: Generalize RangeIndex to support floats #46484

@TomAugspurger

Description

@TomAugspurger

Is your feature request related to a problem?

When working with geospatial data in xarray, it's common to have regularly-spaced, floating-point coordinates. Using a RangeIndex with floating-point start, stop, and step would cut down on the memory usage. https://github.com/gjoseph92/stackstac/blob/1c6553a5b6b2acbb89388bd8b1c2d280ea2f3bd5/stackstac/prepare.py#L412

Describe the solution you'd like

Let RangeIndex accept floating point start, stop, and step. Will need to change a handful of other methods to support the generalization (e.g. inferred_type, probably some of the hashtable stuff).

API breaking implications

None.

Describe alternatives you've considered

Reimplementing all of the index classes to support an "encoding" scheme, which would subsume range encoding, categorical encoding, ... But that's a ton of work :)

Additional context

>>> pd.RangeIndex(0.0, 1.0, 0.1)
RangeIndex(start=0.0, stop=1.0, step=0.1)  # same valuesas np.arange(0.0, 1.0, 0.1)

Metadata

Metadata

Assignees

Labels

EnhancementIndexRelated to the Index class or subclasses

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions