Skip to content

Consider adding isnative property to StringDtype? #33269

@krassowski

Description

@krassowski

Code Sample

Assuming Jupyter notebook environment

!pip install rpy2
%load_ext rpy2.ipython
from pandas import *
characters= = Series(['a', 'b'], dtype=StringDtype())
%R -i characters

Leads to an error in rpy2:

AttributeError: 'StringDtype' object has no attribute 'isnative'`

which I described in rpy2/rpy2#669. However, as this concerns a new experimental feature in pandas I wanted to bring a difference in public interface between different Dtypes to your attention.

Problem description

The new, experimental StringDtype inherits from ExtensionDtype rather than from PandasExtensionDtype. This means that it does not have isnative property.

Questions

  • is it intended to have some Dtypes with isnative attribute and others without?
  • in your opinion, should the rpy2 issue be worked around downstream or should the API be amended in pandas (I expect that other packages may also expect dtypes to have certain attributes from PandasExtensionDtype)?

Output of pd.show_versions()

INSTALLED VERSIONS

commit : None
python : 3.8.1.final.0
python-bits : 64
OS : Linux
OS-release : 5.3.0-26-generic
machine : x86_64
processor : x86_64
byteorder : little
LC_ALL : None
LANG : en_GB.UTF-8
LOCALE : en_GB.UTF-8

pandas : 1.0.3
numpy : 1.18.2
pytz : 2019.3
dateutil : 2.8.1
pip : 19.2.3
setuptools : 41.2.0
Cython : None
pytest : 5.4.1
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 2.11.1
IPython : 7.13.0
pandas_datareader: None
bs4 : None
bottleneck : None
fastparquet : None
gcsfs : None
lxml.etree : None
matplotlib : 3.2.1
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pytables : None
pytest : 5.4.1
pyxlsb : None
s3fs : None
scipy : 1.4.1
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
xlsxwriter : None
numba : None

Metadata

Metadata

Assignees

No one assigned

    Labels

    Closing CandidateMay be closeable, needs more eyeballsEnhancementExtensionArrayExtending pandas with custom dtypes or arrays.Needs DiscussionRequires discussion from core team before further actionStringsString extension data type and string data

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions