Skip to content

Commit a11346b

Browse files
committed
Added unit julian to to_datetime
See #11276
1 parent c2aa6a2 commit a11346b

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

pandas/tseries/tools.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
219219
exact : boolean, True by default
220220
- If True, require an exact format match.
221221
- If False, allow the format to match anywhere in the target string.
222-
unit : unit of the arg (D,s,ms,us,ns) denote the unit in epoch
222+
unit : unit of the arg (D,s,ms,us,ns,julian) denote the unit in epoch
223223
(e.g. a unix timestamp), which is an integer/float number.
224224
infer_datetime_format : boolean, default False
225225
If no `format` is given, try to infer the format based on the first
@@ -271,6 +271,11 @@ def to_datetime(arg, errors='raise', dayfirst=False, yearfirst=False,
271271
>>> pd.to_datetime('13000101', format='%Y%m%d', errors='coerce')
272272
NaT
273273
"""
274+
if unit == 'julian':
275+
from pandas.core.api import Timestamp
276+
unit = 'D'
277+
arg = arg - Timestamp(0).to_julian_date()
278+
274279
return _to_datetime(arg, errors=errors, dayfirst=dayfirst, yearfirst=yearfirst,
275280
utc=utc, box=box, format=format, exact=exact,
276281
unit=unit, infer_datetime_format=infer_datetime_format)

0 commit comments

Comments
 (0)