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

Function _parse_date_columns

pandas/io/sql.py:139–157  ·  view source on GitHub ↗

Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns.

(data_frame: DataFrame, parse_dates)

Source from the content-addressed store, hash-verified

137
138
139def _parse_date_columns(data_frame: DataFrame, parse_dates) -> DataFrame:
140 """
141 Force non-datetime columns to be read as such.
142 Supports both string formatted and integer timestamp columns.
143 """
144 parse_dates = _process_parse_dates_argument(parse_dates)
145
146 # we want to coerce datetime64_tz dtypes for now to UTC
147 # we could in theory do a 'nice' conversion from a FixedOffset tz
148 # GH11216
149 for i, (col_name, df_col) in enumerate(data_frame.items()):
150 if isinstance(df_col.dtype, DatetimeTZDtype) or col_name in parse_dates:
151 try:
152 fmt = parse_dates[col_name]
153 except (KeyError, TypeError):
154 fmt = None
155 data_frame.isetitem(i, _handle_date_column(df_col, format=fmt))
156
157 return data_frame
158
159
160def _convert_arrays_to_dataframe(

Callers 2

_wrap_resultFunction · 0.85
_wrap_result_adbcFunction · 0.85

Calls 4

_handle_date_columnFunction · 0.85
isetitemMethod · 0.80
itemsMethod · 0.45

Tested by

no test coverage detected