diff --git a/pandas/tseries/tools.py b/pandas/tseries/tools.py index 93d35ff964e69..68182b6f7267e 100644 --- a/pandas/tseries/tools.py +++ b/pandas/tseries/tools.py @@ -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) @@ -266,11 +267,15 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False, 0 2015-02-04 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. - - >>> pd.to_datetime('13000101', format='%Y%m%d') + + 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', errors='ignore') datetime.datetime(1300, 1, 1, 0, 0) >>> pd.to_datetime('13000101', format='%Y%m%d', errors='coerce') NaT @@ -423,6 +428,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 +561,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 +646,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 +771,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)