-
-
Notifications
You must be signed in to change notification settings - Fork 18.1k
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: undeprecate is_datetime64tz_dtype #55514
Comments
The suggested replacement requires you to pass |
Oooh, thanks! I do see that now that I look at the deprecation warning, but since the old function took arr or dtype it wasn't clear to me that I had to change the argument in addition to the function. Can the deprecation warning be changed to something like:
Alternatively, could we add a new pd type checker which checks both types? This would be a more direct replacement to the older function. As it stands removing the old function will require everyone to put in both checks (arr and dtype) so it seems to me to make more sense to collect both checks in one place. Something like:
|
in most cases you should be able to know which type of object you have and use a single appropriate check. Do you have a particular use case where this is burdensome? If you really need is_arr_or_instance, you've just written it; why would it need to live in pandas? |
There are over 4k uses of is_datetime64tz_dtype which don't explicitly call For example, I don't know pandas well enough to know what types constitute arrays. Would
As for my specific example, there are a handful of functions shared between pd.Series and pd.Timestamp, such as |
The fact that this is ambiguous is exactly why the non-ambiguous check is better.
A big part of the reason it was deprecated was that it was very inefficient. Checks like these happen a lot and their poor performance add up. |
Fair enough! Well, thank you very much for your clarifications, and hopefully if anyone else bumps into this issue they'll at least see this thread. |
Thanks for suggestion, but per the discussion the original proposal is unlikely to happen so closing |
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
Issue Description
is_datetime64tz_dtype is being deprecated but the suggested replacement function doesn't behave the same way. Looking at is_datetime64tz_dtype it can return True if isinstance(arr_or_dtype, DatetimeTZDtype) or if DatetimeTZDtype.is_dtype(arr_or_dtype). Thus the suggested use of isinstance(...) is not a complete replacement for the deprecated function.
The code above illustrates a trivial case where is_datetime64tz_dtype returns True as does DatetimeTZDtype.is_dtype() but isinstance(..., pd.DatetimeTZDtype) returns False.
Expected Behavior
The replacement for a deprecated fuction should behave exactly the same under all inputs.
Installed Versions
INSTALLED VERSIONS
commit : e86ed37
python : 3.11.6.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.22621
machine : AMD64
processor : Intel64 Family 6 Model 166 Stepping 0, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United States.1252
pandas : 2.1.1
numpy : 1.26.0
pytz : 2023.3.post1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.2.1
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
dataframe-api-compat: None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : None
sqlalchemy : None
tables : None
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: