BUG: Empty dataframe created with Index, not RangeIndex #40077
Labels
API - Consistency
Internal Consistency of API/Behavior
Bug
Constructors
Series/DataFrame/Index/pd.array Constructors
Index
Related to the Index class or subclasses
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
(optional) I have confirmed this bug exists on the master branch of pandas.
Note: Please read this guide detailing how to provide the necessary information for us to reproduce your bug.
Code Sample, a copy-pastable example
Problem description
When creating an empty dataframe it is created with
Index
, and not with aRangeIndex
as specified in the docs. This is a problem, e.g. in the example shown above, where I would not expect the index to change when appending the empty dataframe to itself. However,pd.testing.assert_frame_equals
raisesAssertionError
since the indeces are not equivalent.Expected Output
Output of
pd.show_versions()
INSTALLED VERSIONS
commit : 7d32926
python : 3.9.2.final.0
python-bits : 64
OS : Linux
OS-release : 5.4.0-59-generic
Version : #65-Ubuntu SMP Thu Dec 10 12:01:51 UTC 2020
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_US.UTF-8
LOCALE : en_US.UTF-8
pandas : 1.2.2
numpy : 1.20.1
pytz : 2021.1
dateutil : 2.8.1
pip : 21.0.1
setuptools : 49.6.0.post20210108
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
fsspec : None
fastparquet : None
gcsfs : None
matplotlib : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
numba : None
The text was updated successfully, but these errors were encountered: