|
263 | 263 | :ref:`io.csv.mixed_timezones` for more.
|
264 | 264 |
|
265 | 265 | Note: A fast-path exists for iso8601-formatted dates.
|
266 |
| -infer_datetime_format : bool, default False |
267 |
| - If True and `parse_dates` is enabled, pandas will attempt to infer the |
268 |
| - format of the datetime strings in the columns, and if it can be inferred, |
269 |
| - switch to a faster method of parsing them. In some cases this can increase |
270 |
| - the parsing speed by 5-10x. |
271 | 266 | keep_date_col : bool, default False
|
272 | 267 | If True and `parse_dates` specifies combining multiple columns then
|
273 | 268 | keep the original columns.
|
|
484 | 479 | "decimal",
|
485 | 480 | "iterator",
|
486 | 481 | "dayfirst",
|
487 |
| - "infer_datetime_format", |
488 | 482 | "verbose",
|
489 | 483 | "skipinitialspace",
|
490 | 484 | "low_memory",
|
@@ -649,7 +643,7 @@ def read_csv(
|
649 | 643 | verbose: bool = ...,
|
650 | 644 | skip_blank_lines: bool = ...,
|
651 | 645 | parse_dates: bool | Sequence[Hashable] | None = ...,
|
652 |
| - infer_datetime_format: bool = ..., |
| 646 | + infer_datetime_format: bool | lib.NoDefault = ..., |
653 | 647 | keep_date_col: bool = ...,
|
654 | 648 | date_parser=...,
|
655 | 649 | dayfirst: bool = ...,
|
@@ -710,7 +704,7 @@ def read_csv(
|
710 | 704 | verbose: bool = ...,
|
711 | 705 | skip_blank_lines: bool = ...,
|
712 | 706 | parse_dates: bool | Sequence[Hashable] | None = ...,
|
713 |
| - infer_datetime_format: bool = ..., |
| 707 | + infer_datetime_format: bool | lib.NoDefault = ..., |
714 | 708 | keep_date_col: bool = ...,
|
715 | 709 | date_parser=...,
|
716 | 710 | dayfirst: bool = ...,
|
@@ -771,7 +765,7 @@ def read_csv(
|
771 | 765 | verbose: bool = ...,
|
772 | 766 | skip_blank_lines: bool = ...,
|
773 | 767 | parse_dates: bool | Sequence[Hashable] | None = ...,
|
774 |
| - infer_datetime_format: bool = ..., |
| 768 | + infer_datetime_format: bool | lib.NoDefault = ..., |
775 | 769 | keep_date_col: bool = ...,
|
776 | 770 | date_parser=...,
|
777 | 771 | dayfirst: bool = ...,
|
@@ -832,7 +826,7 @@ def read_csv(
|
832 | 826 | verbose: bool = ...,
|
833 | 827 | skip_blank_lines: bool = ...,
|
834 | 828 | parse_dates: bool | Sequence[Hashable] | None = ...,
|
835 |
| - infer_datetime_format: bool = ..., |
| 829 | + infer_datetime_format: bool | lib.NoDefault = ..., |
836 | 830 | keep_date_col: bool = ...,
|
837 | 831 | date_parser=...,
|
838 | 832 | dayfirst: bool = ...,
|
@@ -906,7 +900,7 @@ def read_csv(
|
906 | 900 | skip_blank_lines: bool = True,
|
907 | 901 | # Datetime Handling
|
908 | 902 | parse_dates: bool | Sequence[Hashable] | None = None,
|
909 |
| - infer_datetime_format: bool = False, |
| 903 | + infer_datetime_format: bool | lib.NoDefault = lib.no_default, |
910 | 904 | keep_date_col: bool = False,
|
911 | 905 | date_parser=None,
|
912 | 906 | dayfirst: bool = False,
|
@@ -941,6 +935,14 @@ def read_csv(
|
941 | 935 | storage_options: StorageOptions = None,
|
942 | 936 | use_nullable_dtypes: bool = False,
|
943 | 937 | ) -> DataFrame | TextFileReader:
|
| 938 | + if infer_datetime_format is not lib.no_default: |
| 939 | + # Kept for compatibility with old code - TODO remove |
| 940 | + warnings.warn( |
| 941 | + "The argument 'infer_datetime_format' has been removed - a strict version " |
| 942 | + "of it is now the default, see " |
| 943 | + "https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html", |
| 944 | + stacklevel=find_stack_level(inspect.currentframe()), |
| 945 | + ) |
944 | 946 | # locals() should never be modified
|
945 | 947 | kwds = locals().copy()
|
946 | 948 | del kwds["filepath_or_buffer"]
|
@@ -993,7 +995,7 @@ def read_table(
|
993 | 995 | verbose: bool = ...,
|
994 | 996 | skip_blank_lines: bool = ...,
|
995 | 997 | parse_dates: bool | Sequence[Hashable] = ...,
|
996 |
| - infer_datetime_format: bool = ..., |
| 998 | + infer_datetime_format: bool | lib.NoDefault = ..., |
997 | 999 | keep_date_col: bool = ...,
|
998 | 1000 | date_parser=...,
|
999 | 1001 | dayfirst: bool = ...,
|
@@ -1054,7 +1056,7 @@ def read_table(
|
1054 | 1056 | verbose: bool = ...,
|
1055 | 1057 | skip_blank_lines: bool = ...,
|
1056 | 1058 | parse_dates: bool | Sequence[Hashable] = ...,
|
1057 |
| - infer_datetime_format: bool = ..., |
| 1059 | + infer_datetime_format: bool | lib.NoDefault = ..., |
1058 | 1060 | keep_date_col: bool = ...,
|
1059 | 1061 | date_parser=...,
|
1060 | 1062 | dayfirst: bool = ...,
|
@@ -1115,7 +1117,7 @@ def read_table(
|
1115 | 1117 | verbose: bool = ...,
|
1116 | 1118 | skip_blank_lines: bool = ...,
|
1117 | 1119 | parse_dates: bool | Sequence[Hashable] = ...,
|
1118 |
| - infer_datetime_format: bool = ..., |
| 1120 | + infer_datetime_format: bool | lib.NoDefault = ..., |
1119 | 1121 | keep_date_col: bool = ...,
|
1120 | 1122 | date_parser=...,
|
1121 | 1123 | dayfirst: bool = ...,
|
@@ -1176,7 +1178,7 @@ def read_table(
|
1176 | 1178 | verbose: bool = ...,
|
1177 | 1179 | skip_blank_lines: bool = ...,
|
1178 | 1180 | parse_dates: bool | Sequence[Hashable] = ...,
|
1179 |
| - infer_datetime_format: bool = ..., |
| 1181 | + infer_datetime_format: bool | lib.NoDefault = ..., |
1180 | 1182 | keep_date_col: bool = ...,
|
1181 | 1183 | date_parser=...,
|
1182 | 1184 | dayfirst: bool = ...,
|
@@ -1250,7 +1252,7 @@ def read_table(
|
1250 | 1252 | skip_blank_lines: bool = True,
|
1251 | 1253 | # Datetime Handling
|
1252 | 1254 | parse_dates: bool | Sequence[Hashable] = False,
|
1253 |
| - infer_datetime_format: bool = False, |
| 1255 | + infer_datetime_format: bool | lib.NoDefault = lib.no_default, |
1254 | 1256 | keep_date_col: bool = False,
|
1255 | 1257 | date_parser=None,
|
1256 | 1258 | dayfirst: bool = False,
|
@@ -1888,10 +1890,6 @@ def TextParser(*args, **kwds) -> TextFileReader:
|
1888 | 1890 | Encoding to use for UTF when reading/writing (ex. 'utf-8')
|
1889 | 1891 | squeeze : bool, default False
|
1890 | 1892 | returns Series if only one column.
|
1891 |
| - infer_datetime_format: bool, default False |
1892 |
| - If True and `parse_dates` is True for a column, try to infer the |
1893 |
| - datetime format based on the first datetime string. If the format |
1894 |
| - can be inferred, there often will be a large parsing speed-up. |
1895 | 1893 | float_precision : str, optional
|
1896 | 1894 | Specifies which converter the C engine should use for floating-point
|
1897 | 1895 | values. The options are `None` or `high` for the ordinary converter,
|
|
0 commit comments