- API reference
- Index objects
- pandas.RangeIndex
pandas.RangeIndex#
- classpandas.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 representingmonotonic ranges with a 64-bit dtype. Using RangeIndex may in some instancesimprove computing speed.
This is the default index type usedby 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)
- stepint (default: 1)
- 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
The value of thestart parameter (
0
if this was not supplied).The value of thestop parameter.
The value of thestep parameter (
1
if this was not supplied).Methods
from_range
(data[, name, dtype])Create
pandas.RangeIndex
from arange
object.See also
Index
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))[]