Skip to content

DEPR/TEST: fix numpy tz-aware parsing warnings #12100

Closed
@jreback

Description

@jreback
/home/travis/build/pydata/pandas/pandas/tseries/tests/test_period.py:420: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future

full build here
note this is only on the numpy-dev builds (last 2)

@shoyer recent change to show a deprecation warning on passing tz-aware strings to numpy here is now causing loads of tests to show these.

so in order to keep backward compat I suppose we need a wrapper function

In [1]: np.__version__
Out[1]: '1.12.0.dev0+a38942a'

In [2]: np.datetime64('2007-01-01 09:00:00.001Z')
/Users/jreback/miniconda/envs/numpy_dev/bin/ipython:1: DeprecationWarning: parsing timezone aware datetimes is deprecated; this will raise an error in the future
  #!/bin/bash /Users/jreback/miniconda/envs/numpy_dev/bin/python.app
Out[2]: numpy.datetime64('2007-01-01T09:00:00.001')

In [3]: np.datetime64('2007-01-01 09:00:00.001')
Out[3]: numpy.datetime64('2007-01-01T09:00:00.001')

In [4]: np.datetime64('2007-01-01 09:00:00.001').item()
Out[4]: datetime.datetime(2007, 1, 1, 9, 0, 0, 1000)

current numpy

In [2]: np.__version__
Out[2]: '1.10.2'

In [3]: np.datetime64('2007-01-01 09:00:00.001Z')
Out[3]: numpy.datetime64('2007-01-01T04:00:00.001-0500')

In [5]: np.datetime64('2007-01-01 09:00:00.001Z').item()
Out[5]: datetime.datetime(2007, 1, 1, 9, 0, 0, 1000)

so maybe

np_datetime64_compat(....) that can then introspect our defined _np_version_under1p11 (define in pandas/__init__.py) and add a 'Z' if needed (pre-suppose that we change the input formats to
2007-01-01 09:00:00.001') for clarity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DeprecateFunctionality to remove in pandasTestingpandas testing functions or related to the test suite

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions