MCPcopy Create free account
hub / github.com/ColdGrub1384/Pyto / date2num

Function date2num

site-packages/matplotlib/dates.py:393–428  ·  view source on GitHub ↗

Convert datetime objects to Matplotlib dates. Parameters ---------- d : `datetime.datetime` or `numpy.datetime64` or sequences of these Returns ------- float or sequence of floats Number of days (fraction part represents hours, minutes, seconds, ms) sin

(d)

Source from the content-addressed store, hash-verified

391
392
393def date2num(d):
394 """
395 Convert datetime objects to Matplotlib dates.
396
397 Parameters
398 ----------
399 d : `datetime.datetime` or `numpy.datetime64` or sequences of these
400
401 Returns
402 -------
403 float or sequence of floats
404 Number of days (fraction part represents hours, minutes, seconds, ms)
405 since 0001-01-01 00:00:00 UTC, plus one.
406
407 Notes
408 -----
409 The addition of one here is a historical artifact. Also, note that the
410 Gregorian calendar is assumed; this is not universal practice.
411 For details see the module docstring.
412 """
413 if hasattr(d, "values"):
414 # this unpacks pandas series or dataframes...
415 d = d.values
416 if not np.iterable(d):
417 if (isinstance(d, np.datetime64) or (isinstance(d, np.ndarray) and
418 np.issubdtype(d.dtype, np.datetime64))):
419 return _dt64_to_ordinalf(d)
420 return _to_ordinalf(d)
421
422 else:
423 d = np.asarray(d)
424 if np.issubdtype(d.dtype, np.datetime64):
425 return _dt64_to_ordinalf(d)
426 if not d.size:
427 return d
428 return _to_ordinalf_np_vectorized(d)
429
430
431def julian2num(j):

Callers 10

__init__Method · 0.90
__call__Method · 0.85
datestr2numFunction · 0.85
drangeFunction · 0.85
tick_valuesMethod · 0.85
autoscaleMethod · 0.85
tick_valuesMethod · 0.85
autoscaleMethod · 0.85
tick_valuesMethod · 0.85
convertMethod · 0.85

Calls 3

hasattrFunction · 0.85
_dt64_to_ordinalfFunction · 0.85
_to_ordinalfFunction · 0.70

Tested by

no test coverage detected