Force non-datetime columns to be read as such. Supports both string formatted and integer timestamp columns.
(data_frame: DataFrame, parse_dates)
| 137 | |
| 138 | |
| 139 | def _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 | |
| 160 | def _convert_arrays_to_dataframe( |
no test coverage detected