MCPcopy
hub / github.com/dask/dask / to_datetime

Function to_datetime

dask/dataframe/dask_expr/_collection.py:6124–6151  ·  view source on GitHub ↗
(arg, meta=None, **kwargs)

Source from the content-addressed store, hash-verified

6122
6123@wraps(pd.to_datetime)
6124def to_datetime(arg, meta=None, **kwargs):
6125 tz_kwarg = {"tz": "utc"} if kwargs.get("utc") else {}
6126
6127 (arg,) = _maybe_from_pandas([arg])
6128
6129 if meta is None:
6130 if isinstance(arg, Index):
6131 meta = get_meta_library(arg).DatetimeIndex([], **tz_kwarg)
6132 meta.name = arg.name
6133 if PANDAS_GE_300:
6134 meta = meta.as_unit(
6135 get_meta_library(arg).to_datetime(meta_nonempty(arg._meta)).unit
6136 )
6137 elif not (is_dataframe_like(arg) or is_series_like(arg)):
6138 raise NotImplementedError(
6139 "dask.dataframe.to_datetime does not support "
6140 "non-index-able arguments (like scalars)"
6141 )
6142 else:
6143 meta = meta_series_constructor(arg)([pd.Timestamp("2000", **tz_kwarg)])
6144 meta.index = meta.index.astype(arg.index.dtype)
6145 meta.index.name = arg.index.name
6146 else:
6147 meta = make_meta(meta)
6148
6149 kwargs.pop("infer_datetime_format", None)
6150
6151 return new_collection(ToDatetime(frame=arg, kwargs=kwargs, meta=meta))
6152
6153
6154@wraps(pd.to_timedelta)

Callers 3

test_to_datetimeFunction · 0.90
test_to_datetime_reprFunction · 0.90

Calls 11

_maybe_from_pandasFunction · 0.90
get_meta_libraryFunction · 0.90
meta_series_constructorFunction · 0.90
make_metaFunction · 0.90
new_collectionFunction · 0.90
ToDatetimeClass · 0.90
is_dataframe_likeFunction · 0.85
is_series_likeFunction · 0.85
popMethod · 0.80
getMethod · 0.45
astypeMethod · 0.45

Tested by 3

test_to_datetimeFunction · 0.72
test_to_datetime_reprFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…