Skip to content

Commit ebb4acd

Browse files
committed
doc fixes & cleanup
1 parent 209591a commit ebb4acd

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

pandas/tseries/tools.py

+6-10
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,8 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
243243
method of parsing them. In some cases this can increase the parsing
244244
speed by ~5-10x.
245245
origin : scalar, default is 'unix'
246-
convertible to Timestamp / string ('julian', 'unix')
246+
Define the reference date. The numeric values would be parsed as number
247+
of units (defined by `unit`) since this reference date.
247248
248249
- If 'unix' (or POSIX) time; origin is set to 1970-01-01.
249250
- If 'julian', unit must be 'D', and origin is set to beginning of
@@ -483,17 +484,12 @@ def _convert_listlike(arg, box, format, name=None, tz=tz):
483484
# this should be lossless in terms of precision
484485
offset = offset // tslib.Timedelta(1, unit=unit)
485486

486-
arg = np.asarray(arg)
487+
# scalars & ndarray-like can handle the addition
488+
if is_list_like(arg) and not isinstance(
489+
arg, (ABCSeries, ABCIndexClass, np.ndarray)):
490+
arg = np.asarray(arg)
487491
arg = arg + offset
488492

489-
# convert to the tenor of the original arg
490-
if is_scalar(original):
491-
arg = arg.item()
492-
elif isinstance(original, ABCSeries):
493-
arg = type(original)(arg, index=original.index, name=original.name)
494-
elif isinstance(original, ABCIndexClass):
495-
arg = type(original)(arg)
496-
497493
if isinstance(arg, tslib.Timestamp):
498494
result = arg
499495
elif isinstance(arg, ABCSeries):

0 commit comments

Comments
 (0)