Skip to content

SNOW-2199122: pandas DeprecationWarning: is_datetime64tz_dtype is deprecated and will be removed in a future version #2399

@michaelxfrench

Description

@michaelxfrench

Python version

Python 3.11.12 (main, Apr 9 2025, 04:03:34) [MSC v.1943 64 bit (AMD64)]

Operating system and processor architecture

Windows-10-10.0.22631-SP0

Installed packages

alembic==1.14.0
annotated-types==0.7.0
anyio==4.8.0
asn1crypto==1.5.1
backoff==2.2.1
black==24.10.0
boto3==1.36.1
boto3-stubs-lite==1.36.1
botocore==1.36.1
botocore-stubs==1.36.1
certifi==2024.12.14
cffi==1.17.1
charset-normalizer==3.4.1
click==8.1.8
cloudpickle==3.0.0
colorama==0.4.6
coloredlogs==14.0
croniter==6.0.0
cryptography==45.0.4
dagster==1.8.13
dagster-aws==0.24.13
dagster-graphql==1.8.13
dagster-pipes==1.8.13
dagster-postgres==0.24.13
dagster-slack==0.24.13
dagster-webserver==1.8.13
docstring_parser==0.16
filelock==3.16.1
fsspec==2024.12.0
gql==3.5.0
graphene==3.4.3
graphql-core==3.2.5
graphql-relay==3.2.0
greenlet==3.1.1
grpcio==1.69.0
grpcio-health-checking==1.62.3
h11==0.14.0
httptools==0.6.4
humanfriendly==10.0
idna==3.10
iniconfig==2.1.0
Jinja2==3.1.5
jmespath==1.0.1
Mako==1.3.8
markdown-it-py==3.0.0
MarkupSafe==3.0.2
mdurl==0.1.2
multidict==6.1.0
mypy==1.16.1
mypy-boto3-ecs==1.36.1
mypy-boto3-emr==1.36.0
mypy-boto3-emr-serverless==1.36.0
mypy-boto3-glue==1.36.0
mypy-extensions==1.0.0
numpy==2.2.1
packaging==24.2
pandas==2.2.3
pathspec==0.12.1
platformdirs==4.3.6
pluggy==1.6.0
propcache==0.2.1
protobuf==4.25.5
psutil==6.1.1
psycopg2-binary==2.9.10
pyarrow==18.1.0
pycparser==2.22
pydantic==2.9.2
pydantic_core==2.23.4
Pygments==2.19.1
PyJWT==2.10.1
pyodbc==5.2.0
pyOpenSSL==25.1.0
pyreadline3==3.5.4
pytest==8.4.1
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-tss-sdk==1.2.3
pytz==2024.2
pywin32==308
PyYAML==6.0.2
requests==2.32.3
requests-toolbelt==1.0.0
rich==13.9.4
ruff==0.12.2
s3transfer==0.11.1
six==1.17.0
slack_sdk==3.34.0
sniffio==1.3.1
snowflake==1.6.0
snowflake-connector-python==3.16.0
snowflake-snowpark-python==1.33.0
snowflake._legacy==1.0.1
snowflake.core==1.6.0
sortedcontainers==2.4.0
SQLAlchemy==2.0.41
starlette==0.45.2
structlog==25.1.0
tabulate==0.9.0
ThycoticUtility==0.1.1
tomli==2.2.1
tomlkit==0.12.5
toposort==1.10
tqdm==4.67.1
types-awscrt==0.23.6
types-s3transfer==0.11.1
typing_extensions==4.12.2
tzdata==2024.2
tzlocal==5.3.1
universal_pathlib==0.2.6
urllib3==2.3.0
uvicorn==0.34.0
watchdog==5.0.3
watchfiles==1.0.4
websockets==14.1
yarl==1.18.3

What did you do?

# I was seeing the Deprecation warning while testing with pytest.
# The following code is a short script to reproduce the warning.
import warnings
warnings.simplefilter('default')  # Show all warnings, including deprecation

snowflake_session: snowpark.Session = # a snowpark session
snowflake_session.write_pandas(pd.DataFrame({
    'id': [1, 2, 3],
    'name': ['Alice', 'Bob', 'Charlie'],
    'amount': [100.5, 200.75, 300.0],
    'created_at': pd.to_datetime(['2025-07-10', '2025-07-09', '2025-07-08'])
}), "test_table", database="test_db", schema="test_schema", auto_create_table=True, quote_identifiers=False)

What did you expect to see?

Hey Snowflake Team!

As of pandas version 2.1.0, the call to is_datetime64tz_dtype is deprecated (https://pandas.pydata.org/docs/reference/api/pandas.api.types.is_datetime64tz_dtype.html). When running tests that use the write_pandas function, I am seeing the following DeprecationWarning along with those mentioned in #2353.

C:\Users\michael.french\AppData\Local\pypoetry\Cache\virtualenvs\de-dagster-dynamicsqlarchive-svc-LJmyQSmo-py3.11\Lib\site-packages\snowflake\connector\pandas_tools.py:408: DeprecationWarning: is_datetime64tz_dtype is deprecated and will be removed in a future version. Check `isinstance(dtype, pd.DatetimeTZDtype)` instead.
  [pandas.api.types.is_datetime64tz_dtype(df[c]) for c in df.columns]

Let me know if there's any more information I could provide.

Thanks

Can you set logging to DEBUG and collect the logs?

import logging
import os

for logger_name in ('snowflake.connector',):
    logger = logging.getLogger(logger_name)
    logger.setLevel(logging.DEBUG)
    ch = logging.StreamHandler()
    ch.setLevel(logging.DEBUG)
    ch.setFormatter(logging.Formatter('%(asctime)s - %(threadName)s %(filename)s:%(lineno)d - %(funcName)s() - %(levelname)s - %(message)s'))
    logger.addHandler(ch)

Metadata

Metadata

Labels

bugstatus-triage_doneInitial triage done, will be further handled by the driver team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions