MCPcopy
hub / github.com/pandas-dev/pandas / date_converter

Function date_converter

pandas/io/parsers/base_parser.py:763–793  ·  view source on GitHub ↗
(
    date_col,
    col: Hashable,
    dayfirst: bool = False,
    cache_dates: bool = True,
    date_format: dict[Hashable, str] | str | None = None,
)

Source from the content-addressed store, hash-verified

761
762
763def date_converter(
764 date_col,
765 col: Hashable,
766 dayfirst: bool = False,
767 cache_dates: bool = True,
768 date_format: dict[Hashable, str] | str | None = None,
769):
770 if date_col.dtype.kind in "Mm":
771 return date_col
772
773 date_fmt = date_format.get(col) if isinstance(date_format, dict) else date_format
774
775 str_objs = lib.ensure_string_array(np.asarray(date_col))
776 try:
777 result = tools.to_datetime(
778 str_objs,
779 format=date_fmt,
780 utc=False,
781 dayfirst=dayfirst,
782 cache=cache_dates,
783 )
784 except (ValueError, TypeError):
785 # test_usecols_with_parse_dates4
786 # test_multi_index_parse_dates
787 return str_objs
788
789 if isinstance(result, DatetimeIndex):
790 arr = result.to_numpy()
791 arr.flags.writeable = True
792 return arr
793 return result._values
794
795
796parser_defaults = {

Callers 3

readMethod · 0.90
_agg_indexMethod · 0.85
_do_date_conversionsMethod · 0.85

Calls 2

getMethod · 0.45
to_numpyMethod · 0.45

Tested by

no test coverage detected