Skip to content

Commit 7402de4

Browse files
edited docstring to fit python standards
1 parent c16ad6b commit 7402de4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pandas/tseries/tools.py

+12-8
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def _lexer_split_from_str(dt_str):
3030
# The StringIO(str(_)) is for dateutil 2.2 compatibility
3131
return _timelex.split(compat.StringIO(str(dt_str)))
3232

33+
3334
_DATEUTIL_LEXER_SPLIT = _lexer_split_from_str
3435
except (ImportError, AttributeError):
3536
pass
@@ -43,6 +44,7 @@ def _infer(a, b):
4344
raise AssertionError('Inputs must both have the same timezone,'
4445
' {0} != {1}'.format(tz, b.tzinfo))
4546
return tz
47+
4648
tz = None
4749
if start is not None:
4850
tz = _infer(start, end)
@@ -133,7 +135,7 @@ def _guess_datetime_format(dt_str, dayfirst=False,
133135
for i, token_format in enumerate(format_guess):
134136
token_filled = tokens[i].zfill(padding)
135137
if (token_format is None and
136-
token_filled == parsed_datetime.strftime(attr_format)):
138+
token_filled == parsed_datetime.strftime(attr_format)):
137139
format_guess[i] = attr_format
138140
tokens[i] = token_filled
139141
found_attrs.update(attrs)
@@ -267,13 +269,14 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
267269
1 2016-03-05
268270
dtype: datetime64[ns]
269271
270-
Since pandas represents timestamps in nanosecond resolution, the timespan that can be represented using a 64-bit integer is limited to approximately 584 years.
271-
272-
If a date that does not meet timestamp limitations, passing errors='ignore' will simply return the original input instead of raising any exception.
272+
Since pandas represents timestamps in nanosecond resolution, the timespan that can be represented using a 64-bit
273+
integer is limited to approximately 584 years.
274+
If a date that does not meet timestamp limitations, passing errors='ignore' will simply return the original input
275+
instead of raising any exception.
276+
Passing errors='coerce' will force to NaT. Furthermore this will force non-dates to NaT as well.
277+
273278
>>> pd.to_datetime('13000101', format='%Y%m%d', errors='ignore')
274279
datetime.datetime(1300, 1, 1, 0, 0)
275-
276-
Passing errors='coerce' will force to NaT. Furthermore this will force non-dates to NaT as well.
277280
>>> pd.to_datetime('13000101', format='%Y%m%d', errors='coerce')
278281
NaT
279282
@@ -425,6 +428,7 @@ def _convert_listlike(arg, box, format, name=None, tz=tz):
425428

426429
return _convert_listlike(np.array([arg]), box, format)[0]
427430

431+
428432
# mappings for assembling units
429433
_unit_map = {'year': 'year',
430434
'years': 'year',
@@ -557,7 +561,7 @@ def calc_with_mask(carg, mask):
557561
result = np.empty(carg.shape, dtype='M8[ns]')
558562
iresult = result.view('i8')
559563
iresult[~mask] = tslib.iNaT
560-
result[mask] = calc(carg[mask].astype(np.float64).astype(np.int64)).\
564+
result[mask] = calc(carg[mask].astype(np.float64).astype(np.int64)). \
561565
astype('M8[ns]')
562566
return result
563567

@@ -642,7 +646,6 @@ def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
642646
DateParseError = tslib.DateParseError
643647
normalize_date = tslib.normalize_date
644648

645-
646649
# Fixed time formats for time parsing
647650
_time_formats = ["%H:%M", "%H%M", "%I:%M%p", "%I%M%p",
648651
"%H:%M:%S", "%H%M%S", "%I:%M:%S%p", "%I%M%S%p"]
@@ -768,6 +771,7 @@ def format(dt):
768771
"""Returns date in YYYYMMDD format."""
769772
return dt.strftime('%Y%m%d')
770773

774+
771775
OLE_TIME_ZERO = datetime(1899, 12, 30, 0, 0, 0)
772776

773777

0 commit comments

Comments
 (0)