MCPcopy Create free account
hub / github.com/apache/arrow / parse_datetime_format_str

Function parse_datetime_format_str

python/pyarrow/interchange/from_dataframe.py:284–299  ·  view source on GitHub ↗

Parse datetime `format_str` to interpret the `data`.

(format_str)

Source from the content-addressed store, hash-verified

282
283
284def parse_datetime_format_str(format_str):
285 """Parse datetime `format_str` to interpret the `data`."""
286
287 # timestamp 'ts{unit}:tz'
288 timestamp_meta = re.match(r"ts([smun]):(.*)", format_str)
289 if timestamp_meta:
290 unit, tz = timestamp_meta.group(1), timestamp_meta.group(2)
291 if unit != "s":
292 # the format string describes only a first letter of the unit, so
293 # add one extra letter to convert the unit to numpy-style:
294 # 'm' -> 'ms', 'u' -> 'us', 'n' -> 'ns'
295 unit += "s"
296
297 return unit, tz
298
299 raise NotImplementedError(f"DateTime kind is not supported: {format_str}")
300
301
302def map_date_type(data_type):

Callers 1

map_date_typeFunction · 0.85

Calls 1

groupMethod · 0.45

Tested by

no test coverage detected