-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
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
Changes from 6 commits
0db07b5
c16ad6b
7402de4
5ed8ef5
8bfa58e
3aa78cf
5468fc5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ def _infer(a, b): | |
raise AssertionError('Inputs must both have the same timezone,' | ||
' {0} != {1}'.format(tz, b.tzinfo)) | ||
return tz | ||
|
||
tz = None | ||
if start is not None: | ||
tz = _infer(start, end) | ||
|
@@ -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 | ||
that can be represented using a 64-bit integer is limited to approximately | ||
584 years. | ||
If a date that does not meet timestamp limitations, passing errors='ignore' | ||
will simply return the original input instead of raising any exception. | ||
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') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @sinhrks sure. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can u add it to the docstring? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. makes sense - I'll do that! |
||
datetime.datetime(1300, 1, 1, 0, 0) | ||
>>> pd.to_datetime('13000101', format='%Y%m%d', errors='coerce') | ||
NaT | ||
|
@@ -423,6 +429,7 @@ def _convert_listlike(arg, box, format, name=None, tz=tz): | |
|
||
return _convert_listlike(np.array([arg]), box, format)[0] | ||
|
||
|
||
# mappings for assembling units | ||
_unit_map = {'year': 'year', | ||
'years': 'year', | ||
|
@@ -555,7 +562,7 @@ def calc_with_mask(carg, mask): | |
result = np.empty(carg.shape, dtype='M8[ns]') | ||
iresult = result.view('i8') | ||
iresult[~mask] = tslib.iNaT | ||
result[mask] = calc(carg[mask].astype(np.float64).astype(np.int64)).\ | ||
result[mask] = calc(carg[mask].astype(np.float64).astype(np.int64)). \ | ||
astype('M8[ns]') | ||
return result | ||
|
||
|
@@ -640,7 +647,6 @@ def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None): | |
DateParseError = tslib.DateParseError | ||
normalize_date = tslib.normalize_date | ||
|
||
|
||
# Fixed time formats for time parsing | ||
_time_formats = ["%H:%M", "%H%M", "%I:%M%p", "%I%M%p", | ||
"%H:%M:%S", "%H%M%S", "%I:%M:%S%p", "%I%M%S%p"] | ||
|
@@ -766,6 +772,7 @@ def format(dt): | |
"""Returns date in YYYYMMDD format.""" | ||
return dt.strftime('%Y%m%d') | ||
|
||
|
||
OLE_TIME_ZERO = datetime(1899, 12, 30, 0, 0, 0) | ||
|
||
|
||
|
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://pandas.pydata.org/pandas-docs/stable/timeseries.html#timeseries-timestamp-limits