MCPcopy Index your code
hub / github.com/feast-dev/feast / _coerce_datetime

Function _coerce_datetime

sdk/python/feast/utils.py:343–355  ·  view source on GitHub ↗

Depending on underlying time resolution, arrow to_pydict() sometimes returns pd timestamp type (for nanosecond resolution), and sometimes you get standard python datetime (for microsecond resolution). While pd timestamp class is a subclass of python datetime, it doesn't always behav

(ts)

Source from the content-addressed store, hash-verified

341
342
343def _coerce_datetime(ts):
344 """
345 Depending on underlying time resolution, arrow to_pydict() sometimes returns pd
346 timestamp type (for nanosecond resolution), and sometimes you get standard python datetime
347 (for microsecond resolution).
348 While pd timestamp class is a subclass of python datetime, it doesn't always behave the
349 same way. We convert it to normal datetime so that consumers downstream don't have to deal
350 with these quirks.
351 """
352 if isinstance(ts, pd.Timestamp):
353 return ts.to_pydatetime()
354 else:
355 return ts
356
357
358def _columns_to_proto_values(

Calls

no outgoing calls

Tested by

no test coverage detected