pandas.RangeIndex — pandas 3.0.0.dev0+2103.g41968a550a documentation (original) (raw)
class pandas.RangeIndex(start=None, stop=None, step=None, dtype=None, copy=False, name=None)[source]#
Immutable Index implementing a monotonic integer range.
RangeIndex is a memory-saving special case of an Index limited to representing monotonic ranges with a 64-bit dtype. Using RangeIndex may in some instances improve computing speed.
This is the default index type used by DataFrame and Series when no explicit index is provided by the user.
Parameters:
startint (default: 0), range, or other RangeIndex instance
If int and “stop” is not given, interpreted as “stop” instead.
stopint (default: 0)
The end value of the range (exclusive).
stepint (default: 1)
The step size of the range.
dtypenp.int64
Unused, accepted for homogeneity with other index types.
copybool, default False
Unused, accepted for homogeneity with other index types.
nameobject, optional
Name to be stored in the index.
Attributes
Methods
See also
The base pandas Index type.
Examples
list(pd.RangeIndex(5)) [0, 1, 2, 3, 4]
list(pd.RangeIndex(-2, 4)) [-2, -1, 0, 1, 2, 3]
list(pd.RangeIndex(0, 10, 2)) [0, 2, 4, 6, 8]
list(pd.RangeIndex(2, -10, -3)) [2, -1, -4, -7]
list(pd.RangeIndex(0)) []
list(pd.RangeIndex(1, 0)) []