BUG: RangeIndex has zero length after subtraction from constant value #53255
Labels
Bug
Index
Related to the Index class or subclasses
Numeric Operations
Arithmetic, Comparison, and Logical operations
Pandas version checks
Reproducible Example
Issue Description
If the index of a
Series
orDataFrame
is aRangeIndex
object the example belowraises a
ValueError
, because the newRangeIndex
has a length of zero.ValueError Traceback
Expected Behavior
I would expect, that the
step
changes to-1
or the object is transferred to anIndex
object like-s.index
does.Installed Versions
pandas : 2.0.1
numpy : 1.22.2
pytz : 2021.3
dateutil : 2.8.2
setuptools : 60.9.3
pip : 22.0.3
Cython : 0.29.28
pytest : 7.0.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.8.0
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.0.3
IPython : 8.1.1
pandas_datareader: None
bs4 : 4.11.2
bottleneck : None
brotli : None
fastparquet : None
fsspec : 2022.02.0
gcsfs : None
matplotlib : 3.5.1
numba : None
numexpr : 2.8.1
odfpy : None
openpyxl : 3.0.9
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.8.0
snappy : None
sqlalchemy : None
tables : 3.7.0
tabulate : None
xarray : None
xlrd : None
zstandard : None
tzdata : 2023.3
qtpy : None
pyqt5 : None
The text was updated successfully, but these errors were encountered: