Skip to content

BUG: Behavior change on DataFrame instantiation from 2.0.0 2.0.1 #53100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
2 of 3 tasks
ivirshup opened this issue May 5, 2023 · 4 comments
Closed
2 of 3 tasks

BUG: Behavior change on DataFrame instantiation from 2.0.0 2.0.1 #53100

ivirshup opened this issue May 5, 2023 · 4 comments
Labels
Bug Constructors Series/DataFrame/Index/pd.array Constructors DataFrame DataFrame data structure Regression Functionality that used to work in a prior pandas version
Milestone

Comments

@ivirshup
Copy link
Contributor

ivirshup commented May 5, 2023

Pandas version checks

  • I have checked that this issue has not already been reported.

  • I have confirmed this bug exists on the latest version of pandas.

  • I have confirmed this bug exists on the main branch of pandas.

Reproducible Example

import pandas as pd

pd.DataFrame({}).columns.dtype

Issue Description

On 2.0.0, this returned:

dtype('O')

On 2.0.1, this returns:

dtype('int64')

This was changed in #52404, and I'd previously reported a similar issue around the 2.0.0rcs in #51725.

Happy to continue this conversation on #51725 if that's more appropriate.

I would note that:

pd.DataFrame(columns=[]).columns.dtype

Still returns dtype('O') in 2.0.1, as it did in 2.0.0 and in the 1.x series.

I have lots of tests that rely on creating an empty dataframe where the dtype of the columns should be "string like" or pd.api.types.infer_dtype -> "empty". (e.g. my library requires only works with dataframes with where column names must be strings, similar to pyarrow).

From

It sounds like there is a desire to move to "empty" as the dtype. I am a fan of this, and think it resembles the 1.x behavior.

Expected Behavior

Ideally, for the behavior of pd.DataFrame({}) to not change between bug fix releases.

This could also be addressed with information around:

  • Whether pd.DataFrame(columns=[]) will also change in a future version.
  • What way won't change

Installed Versions

INSTALLED VERSIONS
------------------
commit           : 37ea63d540fd27274cad6585082c91b1283f963d
python           : 3.10.10.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 20.6.0
Version          : Darwin Kernel Version 20.6.0: Thu Mar  9 20:39:26 PST 2023; root:xnu-7195.141.49.700.6~1/RELEASE_X86_64
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : None
LOCALE           : None.UTF-8

pandas           : 2.0.1
numpy            : 1.24.3
pytz             : 2023.3
dateutil         : 2.8.2
setuptools       : 67.7.2
pip              : 23.1.2
Cython           : None
pytest           : 7.3.1
hypothesis       : None
sphinx           : 6.2.1
blosc            : None
feather          : None
xlsxwriter       : None
lxml.etree       : None
html5lib         : None
pymysql          : None
psycopg2         : None
jinja2           : 3.1.2
IPython          : 8.13.2
pandas_datareader: None
bs4              : 4.12.2
bottleneck       : None
brotli           : None
fastparquet      : None
fsspec           : 2023.4.0
gcsfs            : None
matplotlib       : 3.7.1
numba            : 0.57.0
numexpr          : None
odfpy            : None
openpyxl         : 3.1.2
pandas_gbq       : None
pyarrow          : None
pyreadstat       : None
pyxlsb           : None
s3fs             : None
scipy            : 1.10.1
snappy           : None
sqlalchemy       : None
tables           : None
tabulate         : None
xarray           : None
xlrd             : None
zstandard        : None
tzdata           : 2023.3
qtpy             : None
pyqt5            : None
@ivirshup ivirshup added Bug Needs Triage Issue that has not been reviewed by a pandas team member labels May 5, 2023
@lithomas1
Copy link
Member

Thanks for reporting this issue. I can reproduce this.

cc @topper-123.

@lithomas1 lithomas1 added Regression Functionality that used to work in a prior pandas version DataFrame DataFrame data structure Constructors Series/DataFrame/Index/pd.array Constructors and removed Needs Triage Issue that has not been reviewed by a pandas team member labels May 5, 2023
@lithomas1 lithomas1 added this to the 2.0.2 milestone May 5, 2023
@phofl
Copy link
Member

phofl commented May 5, 2023

Yeah this was changed on purpose. -1 on rolling back

@flying-sheep
Copy link
Contributor

What’s the purpose? @phofl could you please link some place where this is being explained?

@lithomas1 lithomas1 modified the milestones: 2.0.3, 2.0.4 Jun 27, 2023
@mroeschke
Copy link
Member

Since this was discussed in #52404 and changed in #52426 (with release notes). Seems like there's not much appetite from the core team to roll this back so closing for now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Constructors Series/DataFrame/Index/pd.array Constructors DataFrame DataFrame data structure Regression Functionality that used to work in a prior pandas version
Projects
None yet
Development

No branches or pull requests

6 participants