DEPR: Deprecate Timestamp.to_datetime #14101

Merged
merged 3 commits into from Aug 29, 2016

Conversation

Projects
None yet
4 participants
Member

gfyoung commented Aug 27, 2016 edited

  1. Deprecate NaT.to_datetime
  2. Deprecate Timestamp.to_datetime
  3. Issue UserWarning in Timestamp.to_datetime when nanoseconds is non-zero

NaT is also a _Timestamp, so the second deprecation covered the first one as well.

Closes #8254.

@jreback jreback and 1 other commented on an outdated diff Aug 27, 2016

pandas/tslib.pyx
cdef:
pandas_datetimestruct dts
_TSObject ts
+
+ if self.nanosecond != 0 and warn:
+ print 'Warning: discarding nonzero nanoseconds'
@jreback

jreback Aug 27, 2016

Contributor

print(..)

@jreback

jreback Aug 27, 2016

Contributor

maybe we should make this an actual warning

@jreback

jreback Aug 27, 2016

Contributor

UserWarning I think ok

codecov-io commented Aug 27, 2016 edited

Current coverage is 85.26% (diff: 100%)

Merging #14101 into master will decrease coverage by <.01%

@@             master     #14101   diff @@
==========================================
  Files           139        139          
  Lines         50502      50502          
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
- Hits          43063      43062     -1   
- Misses         7439       7440     +1   
  Partials          0          0          

Powered by Codecov. Last update a0151a7...1fe9f46

jorisvandenbossche added this to the 0.19.0 milestone Aug 27, 2016

@jreback jreback commented on the diff Aug 27, 2016

pandas/tslib.pyx
cdef:
pandas_datetimestruct dts
_TSObject ts
+
+ if self.nanosecond != 0 and warn:
+ warnings.warn("Discarding nonzero nanoseconds in conversion",
+ UserWarning, stacklevel=2)
@jreback

jreback Aug 27, 2016

Contributor

hmm maybe RuntimeWarning is better? not sure when that is typically used

@gfyoung

gfyoung Aug 27, 2016

Member

I think user warning makes more sense here because this is converting user-provided data.

@jreback jreback commented on the diff Aug 27, 2016

doc/source/whatsnew/v0.19.0.txt
@@ -1031,6 +1031,7 @@ Deprecations
- ``Categorical.reshape`` has been deprecated and will be removed in a subsequent release (:issue:`12882`)
- ``Series.reshape`` has been deprecated and will be removed in a subsequent release (:issue:`12882`)
+- ``Timestamp.to_datetime`` has been deprecated in favour of ``Timestamp.to_pydatetime`` (:issue:`8254`)
@jreback

jreback Aug 27, 2016

Contributor

add entry about the new warning

gfyoung added some commits Aug 27, 2016

@gfyoung gfyoung DEPR: Deprecate Timestamp.to_datetime 57e9bb9
@gfyoung gfyoung API: Issue real warning in to_pydatetime 88eefc1
@gfyoung gfyoung DEPR: Deprecate NaT.to_datetime
Closes gh-8254.
1fe9f46
Member

gfyoung commented Aug 28, 2016

@jorisvandenbossche , @jreback : Travis is giving the green light, so this should be ready to merge if there are no other concerns.

@jorisvandenbossche jorisvandenbossche merged commit a9c15d3 into pandas-dev:master Aug 29, 2016

3 checks passed

codecov/patch Coverage not affected when comparing a0151a7...1fe9f46
Details
codecov/project 85.26% (target 82.00%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@gfyoung Thanks!

gfyoung deleted the gfyoung:ts-to-datetime-depr branch Aug 30, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment