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

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

Closed
jreback opened this issue Jan 20, 2016 · 2 comments
Closed

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

jreback opened this issue Jan 20, 2016 · 2 comments
Labels
Deprecate Functionality to remove in pandas Testing pandas testing functions or related to the test suite
Milestone

Comments

@jreback
Copy link
Contributor

jreback commented Jan 20, 2016

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

@jreback jreback added Testing pandas testing functions or related to the test suite Deprecate Functionality to remove in pandas Difficulty Intermediate labels Jan 20, 2016
@jreback jreback added this to the 0.18.0 milestone Jan 20, 2016
@shoyer
Copy link
Member

shoyer commented Jan 20, 2016

Hmm. I wonder if we should adjust numpy to not issue a deprecation warning when the "Z" specifier is provided? Folks will be using that for quite a while for backwards compat, and it's actually 100% forwards compat in the typical case where you're time zone naive as UTC only...

@jreback
Copy link
Contributor Author

jreback commented Jan 20, 2016

it IS technically wrong I think though. a 'Z' implies by definition a tz-aware date (that is UTC). Since numpy doesn't support aware, then I guess it is clear what it is.

But you are right, it is no harm. OTOH, if you don't issue a DeprecationWarning then no-one will ever fix it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Deprecate Functionality to remove in pandas Testing pandas testing functions or related to the test suite
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants