Skip to content
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

BUG: Pandas string dtype reverts to object dtype when initialising index #42455

Closed
2 of 3 tasks
mlee94 opened this issue Jul 9, 2021 · 2 comments
Closed
2 of 3 tasks
Labels
Closing Candidate May be closeable, needs more eyeballs ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses

Comments

@mlee94
Copy link

mlee94 commented Jul 9, 2021

  • 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.

In [2]: pd.Index(['A', 'B', 'C', 'D'], dtype=pd.StringDtype()).dtype
Out[2]: dtype('O')

In [3]: pd.Index([1, 2, 3, 4], dtype=int).dtype
Out[3]: dtype('int64')
Output pd.show_versions()
  INSTALLED VERSIONS
  ------------------
  commit           : f00ed8f47020034e752baf0250483053340971b0
  python           : 3.7.9.final.0
  python-bits      : 64
  OS               : Windows
  OS-release       : 10
  Version          : 10.0.19041
  machine          : AMD64
  processor        : Intel64 Family 6 Model 58 Stepping 0, GenuineIntel
  byteorder        : little
  LC_ALL           : None
  LANG             : None
  LOCALE           : None.None
  
  pandas           : 1.3.0
  numpy            : 1.19.5
  pytz             : 2020.5
  dateutil         : 2.8.1
  pip              : 21.0
  setuptools       : 49.6.0.post20210108
  Cython           : None
  pytest           : 6.2.1
  hypothesis       : None
  sphinx           : 3.5.4
  blosc            : None
  feather          : None
  xlsxwriter       : 1.3.9
  lxml.etree       : 4.6.3
  html5lib         : None
  pymysql          : None
  psycopg2         : 2.8.6 (dt dec pq3 ext lo64)
  jinja2           : 2.11.2
  IPython          : 7.19.0
  pandas_datareader: None
  bs4              : 4.9.3
  bottleneck       : None
  fsspec           : 2021.05.0
  fastparquet      : None
  gcsfs            : None
  matplotlib       : 3.3.3
  numexpr          : None
  odfpy            : None
  openpyxl         : 3.0.7
  pandas_gbq       : None
  pyarrow          : 3.0.0
  pyxlsb           : None
  s3fs             : None
  scipy            : 1.6.2
  sqlalchemy       : 1.4.3
  tables           : None
  tabulate         : 0.8.9
  xarray           : 0.16.2
  xlrd             : None
  xlwt             : None
  numba            : 0.53.1

I don't think the dtype should change here. Seems to be okay for other dtypes apart from strings.

@mzeitlin11
Copy link
Member

Thanks for reporting this @mlee94. This occurs because Index does not currently support holding extension types, which is covered under #39133

@mzeitlin11 mzeitlin11 added Closing Candidate May be closeable, needs more eyeballs ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses labels Jul 9, 2021
@phofl
Copy link
Member

phofl commented Jul 15, 2021

Agreed

@phofl phofl closed this as completed Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Closing Candidate May be closeable, needs more eyeballs ExtensionArray Extending pandas with custom dtypes or arrays. Index Related to the Index class or subclasses
Projects
None yet
Development

No branches or pull requests

3 participants