Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/294.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何从RangeIndex中获取步长_Python_Pandas - Fatal编程技术网

Python 如何从RangeIndex中获取步长

Python 如何从RangeIndex中获取步长,python,pandas,Python,Pandas,当我打印RangeIndex时,我可以看到它“知道”它的步长是多少 >>> r = pd.RangeIndex(0, 15, 3) >>> print(r) RangeIndex(start=0, stop=15, step=3) 我希望将其作为一个属性访问,但我不认为“步长”或“步长大小”之类的内容是一个属性(甚至不认为是启动和停止)。这可能吗?我尝试过遵循源代码,但我无能为力。如果你r.\uu dict\uuuu,你可以看到r.\u step会解决你的问

当我打印RangeIndex时,我可以看到它“知道”它的步长是多少

>>> r = pd.RangeIndex(0, 15, 3)
>>> print(r)
RangeIndex(start=0, stop=15, step=3)

我希望将其作为一个属性访问,但我不认为“步长”或“步长大小”之类的内容是一个属性(甚至不认为是启动和停止)。这可能吗?我尝试过遵循源代码,但我无能为力。

如果你
r.\uu dict\uuuu
,你可以看到
r.\u step
会解决你的问题;)啊,谢谢!!这似乎是一个奇怪的步骤,我应该避免这样做吗?
\uuu
表明此属性不是对象的公共API的一部分,可能会在不通知的情况下更改。感谢您提供的信息–我想知道他们为什么不使其稳定和可访问,与
DatetimeIndex
freq
类似,原因是
RangeIndex
不像
DatetimeIndex
那样“稳定”,即
RangeIndex
很容易成为索引操作中的
Int64Index
(没有步骤)。如果你
r.\uu dict\uuu
,您可以看到
r.\u步骤将解决您的问题;)啊,谢谢!!这似乎是一个奇怪的步骤,我应该避免这样做吗?
\uuu
表明此属性不是对象的公共API的一部分,可能会在不通知的情况下更改。感谢您提供的信息–我想知道他们为什么不使其稳定和可访问,与
DatetimeIndex
freq
类似,原因是
RangeIndex
不像
DatetimeIndex
那样“稳定”,即
RangeIndex
在索引操作中很容易变成
Int64Index
(没有步骤)。