Skip to content

DOC:updated docstring in .to_datetime() #14452

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

Closed
wants to merge 7 commits into from
Closed

DOC:updated docstring in .to_datetime() #14452

wants to merge 7 commits into from

Conversation

keshavramaswamy
Copy link
Contributor

@keshavramaswamy keshavramaswamy commented Oct 19, 2016

@keshavramaswamy keshavramaswamy changed the title updated docstring in .to_datetime() DOC:updated docstring in .to_datetime() Oct 19, 2016
@codecov-io
Copy link

codecov-io commented Oct 19, 2016

Current coverage is 85.25% (diff: 100%)

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

@@             master     #14452   diff @@
==========================================
  Files           140        140          
  Lines         50631      50655    +24   
  Methods           0          0          
  Messages          0          0          
  Branches          0          0          
==========================================
+ Hits          43166      43185    +19   
- Misses         7465       7470     +5   
  Partials          0          0          

Powered by Codecov. Last update c31ea34...3aa78cf

@@ -270,7 +270,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
If a date that does not meet timestamp limitations, passing errors='coerce'
will force to NaT. Furthermore this will force non-dates to NaT as well.

>>> pd.to_datetime('13000101', format='%Y%m%d')
>>> pd.to_datetime('13000101', format='%Y%m%d', errors='ignore')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's nice to add an example of default behavior, and describe what the timestamp limitation is.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sinhrks sure.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u add it to the docstring?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes sense - I'll do that!

@sinhrks sinhrks added Docs Datetime Datetime data dtype labels Oct 20, 2016
@sinhrks sinhrks added this to the 0.19.1 milestone Oct 20, 2016
@keshavramaswamy
Copy link
Contributor Author

  • The timestamp limitation is that "the timespan that can be represented using a 64-bit integer is limited to approximately 584 years".
  • So the default behavior (from version 0.17.0) is errors='raise' i.e. when a date does not meet timestamp limitations, an exception will be raised.
    Setting errors='ignore' will simply return the original input instead of raising any exception.

@keshavramaswamy
Copy link
Contributor Author

@sinhrks Can this be merged?

@keshavramaswamy
Copy link
Contributor Author

@jreback Can this be merged? Please let me know if there are any changes to be added.

@@ -267,10 +268,15 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
1 2016-03-05
dtype: datetime64[ns]

If a date that does not meet timestamp limitations, passing errors='coerce'
will force to NaT. Furthermore this will force non-dates to NaT as well.
Since pandas represents timestamps in nanosecond resolution, the timespan
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sentence is not a complete explanation; instead you can simply refer to a link in the docs about min/max values that are supported.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jreback jreback closed this in 18fba53 Oct 24, 2016
@jreback
Copy link
Contributor

jreback commented Oct 24, 2016

thanks!

@keshavramaswamy keshavramaswamy deleted the master branch October 29, 2016 17:02
jorisvandenbossche pushed a commit to jorisvandenbossche/pandas that referenced this pull request Nov 2, 2016
…for out-of-bounds timestamps

with errors='ignore'

closes pandas-dev#14448

Author: Keshav Ramaswamy <[email protected]>
Author: Keshav Ramaswamy <[email protected]>

Closes pandas-dev#14452 from keshavramaswamy/master and squashes the following commits:

5468fc5 [Keshav Ramaswamy] added link to timestamp limitations in docstring
3aa78cf [Keshav Ramaswamy] edit docstring to fit python standards
8bfa58e [Keshav Ramaswamy] edited docstring to fit python standards
5ed8ef5 [Keshav Ramaswamy] edut docstring to fit Python Standards
7402de4 [Keshav Ramaswamy] edited docstring to fit python standards
c16ad6b [Keshav Ramaswamy] added timestamp limitations and default behavior to docstring
0db07b5 [Keshav Ramaswamy] updated docstring in .to_datetime()

(cherry picked from commit 18fba53)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Datetime Datetime data dtype Docs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

DOC/BUG: pd.to_datetime example produces different results from documentation
4 participants