From 020103acf0dab330a92adf6095ef5a58c3bf26a5 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Tue, 5 Sep 2023 21:39:40 -0500 Subject: [PATCH 01/24] updating init to include guess_datetime_format func --- pandas/_libs/tslibs/__init__.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pandas/_libs/tslibs/__init__.py b/pandas/_libs/tslibs/__init__.py index 2cabbe3ff07da..f41b468f380b1 100644 --- a/pandas/_libs/tslibs/__init__.py +++ b/pandas/_libs/tslibs/__init__.py @@ -33,6 +33,7 @@ "is_supported_unit", "npy_unit_to_abbrev", "get_supported_reso", + "guess_datetime_format", ] from pandas._libs.tslibs import dtypes # pylint: disable=import-self @@ -63,6 +64,9 @@ Tick, to_offset, ) +from pandas._libs.tslibs.parsing import ( + guess_datetime_format, +) from pandas._libs.tslibs.period import ( IncompatibleFrequency, Period, From aa65a914e331d4adaae5091b67ae53a8fe23b312 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Tue, 5 Sep 2023 21:41:10 -0500 Subject: [PATCH 02/24] included guess_datetime_format in api --- pandas/tseries/api.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/tseries/api.py b/pandas/tseries/api.py index 9fdf95d09fe52..8c9b352839bbd 100644 --- a/pandas/tseries/api.py +++ b/pandas/tseries/api.py @@ -4,5 +4,6 @@ from pandas.tseries import offsets from pandas.tseries.frequencies import infer_freq +from pandas._libs.tslibs.parsing import guess_datetime_format -__all__ = ["infer_freq", "offsets"] +__all__ = ["infer_freq", "offsets", "guess_datetime_format"] From a9ec6a4afaf7843fb6f5e02b9c938740f302c76b Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Fri, 8 Sep 2023 06:38:52 -0500 Subject: [PATCH 03/24] updated test to include guess_datetime_format method --- pandas/tests/tslibs/test_api.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/tests/tslibs/test_api.py b/pandas/tests/tslibs/test_api.py index a596d4a85074e..7081983718f38 100644 --- a/pandas/tests/tslibs/test_api.py +++ b/pandas/tests/tslibs/test_api.py @@ -57,6 +57,7 @@ def test_namespace(): "is_supported_unit", "get_supported_reso", "npy_unit_to_abbrev", + "guess_datetime_format" ] expected = set(submodules + api) From c61fff33f8b02c2bf4d088d0ad1c70bf8b803fc3 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Fri, 8 Sep 2023 06:47:59 -0500 Subject: [PATCH 04/24] ran pre-commit hook --- pandas/_libs/tslibs/__init__.py | 4 +--- pandas/tests/tslibs/test_api.py | 2 +- pandas/tseries/api.py | 3 ++- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/pandas/_libs/tslibs/__init__.py b/pandas/_libs/tslibs/__init__.py index f41b468f380b1..c622121578dcb 100644 --- a/pandas/_libs/tslibs/__init__.py +++ b/pandas/_libs/tslibs/__init__.py @@ -64,9 +64,7 @@ Tick, to_offset, ) -from pandas._libs.tslibs.parsing import ( - guess_datetime_format, -) +from pandas._libs.tslibs.parsing import guess_datetime_format from pandas._libs.tslibs.period import ( IncompatibleFrequency, Period, diff --git a/pandas/tests/tslibs/test_api.py b/pandas/tests/tslibs/test_api.py index 7081983718f38..b52bc78d58296 100644 --- a/pandas/tests/tslibs/test_api.py +++ b/pandas/tests/tslibs/test_api.py @@ -57,7 +57,7 @@ def test_namespace(): "is_supported_unit", "get_supported_reso", "npy_unit_to_abbrev", - "guess_datetime_format" + "guess_datetime_format", ] expected = set(submodules + api) diff --git a/pandas/tseries/api.py b/pandas/tseries/api.py index 8c9b352839bbd..ec2d7d2304839 100644 --- a/pandas/tseries/api.py +++ b/pandas/tseries/api.py @@ -2,8 +2,9 @@ Timeseries API """ +from pandas._libs.tslibs.parsing import guess_datetime_format + from pandas.tseries import offsets from pandas.tseries.frequencies import infer_freq -from pandas._libs.tslibs.parsing import guess_datetime_format __all__ = ["infer_freq", "offsets", "guess_datetime_format"] From d8c2ea1d3c6f5ebc04fe4349b696576d91b307e6 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Sat, 9 Sep 2023 10:34:47 -0500 Subject: [PATCH 05/24] updated latest rst doc with enhancement note --- doc/source/whatsnew/v2.1.1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.1.1.rst b/doc/source/whatsnew/v2.1.1.rst index 42af61be26355..c06401482d758 100644 --- a/doc/source/whatsnew/v2.1.1.rst +++ b/doc/source/whatsnew/v2.1.1.rst @@ -42,7 +42,7 @@ Bug fixes Other ~~~~~ -- +- Enhancement in :meth:`_libs.tslibs.parsing.guess_datetime_format` to make public (:issue:`54727`) .. --------------------------------------------------------------------------- .. _whatsnew_211.contributors: From 6f5713e97b58064461f7dd455de4f79d51afbdcd Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Tue, 12 Sep 2023 19:50:11 -0500 Subject: [PATCH 06/24] removed enhancement update --- doc/source/whatsnew/v2.1.1.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.1.1.rst b/doc/source/whatsnew/v2.1.1.rst index c06401482d758..ede3a0b4e5a21 100644 --- a/doc/source/whatsnew/v2.1.1.rst +++ b/doc/source/whatsnew/v2.1.1.rst @@ -42,7 +42,7 @@ Bug fixes Other ~~~~~ -- Enhancement in :meth:`_libs.tslibs.parsing.guess_datetime_format` to make public (:issue:`54727`) + .. --------------------------------------------------------------------------- .. _whatsnew_211.contributors: From 51b3ef145038c8d8549609e2032f845d0a741bec Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Tue, 12 Sep 2023 19:52:01 -0500 Subject: [PATCH 07/24] alphabetize other-enhancement list --- doc/source/whatsnew/v2.2.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.2.0.rst b/doc/source/whatsnew/v2.2.0.rst index 249f08c7e387b..f293fb3b86554 100644 --- a/doc/source/whatsnew/v2.2.0.rst +++ b/doc/source/whatsnew/v2.2.0.rst @@ -45,8 +45,8 @@ enhancement2 Other enhancements ^^^^^^^^^^^^^^^^^^ +- :meth:`pandas.tseries.guess_datetime_format` is now available (:issue:`54727`) - DataFrame.apply now allows the usage of numba (via ``engine="numba"``) to JIT compile the passed function, allowing for potential speedups (:issue:`54666`) -- .. --------------------------------------------------------------------------- .. _whatsnew_220.notable_bug_fixes: From cc204f498d8e95f3b0471cb426259f5873956880 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Wed, 13 Sep 2023 20:28:39 -0500 Subject: [PATCH 08/24] added guess_datetime_format --- doc/source/reference/general_functions.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/reference/general_functions.rst b/doc/source/reference/general_functions.rst index 02b0bf5d13dde..7586e4bcf36fb 100644 --- a/doc/source/reference/general_functions.rst +++ b/doc/source/reference/general_functions.rst @@ -58,6 +58,7 @@ Top-level dealing with datetimelike data period_range timedelta_range infer_freq + guess_datetime_format Top-level dealing with Interval data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 85456e7034479f5d05d481aeed0a9ce68e24a543 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Wed, 13 Sep 2023 20:53:21 -0500 Subject: [PATCH 09/24] updated guess_datetime_format docstring with warning sphinx directive --- pandas/_libs/tslibs/parsing.pyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index ef1a870b8653c..ca9fdc2499967 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -874,7 +874,7 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: Datetime string to guess the format of. dayfirst : bool, default False If True parses dates with the day first, eg 20/01/2005 - Warning: dayfirst=True is not strict, but will prefer to parse + .. warning:: dayfirst=True is not strict, but will prefer to parse with day first (this is a known bug). Returns From 7c1ee7717673c7fec2c449099e30a839694cd2f5 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Wed, 13 Sep 2023 21:15:48 -0500 Subject: [PATCH 10/24] fixed spelling from pre-commit hook --- pandas/_libs/tslibs/parsing.pyx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index ca9fdc2499967..9df42dc957653 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -882,6 +882,17 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: str or None : ret datetime format string (for `strftime` or `strptime`), or None if it can't be guessed. + + Examples + -------- + # successful guess + # returns a datetime formatted string + >>> guess_datetime_format('13/09/2023') + '%d/%m/%Y' + + # unsuccessful guess due to date string with extra or unexpected characters + # returns nothing + >>> guess_datetime_format('2023|September|13') """ cdef: NPY_DATETIMEUNIT out_bestunit From a7f619d309ee835c41057973cd2dbc4a410d7d30 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Sat, 16 Sep 2023 06:29:16 -0500 Subject: [PATCH 11/24] update guess_datetime_format docstring examples --- pandas/_libs/tslibs/parsing.pyx | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index 9df42dc957653..272dff98ca3b1 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -885,14 +885,11 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: Examples -------- - # successful guess - # returns a datetime formatted string - >>> guess_datetime_format('13/09/2023') - '%d/%m/%Y' - - # unsuccessful guess due to date string with extra or unexpected characters - # returns nothing - >>> guess_datetime_format('2023|September|13') + >>> guess_datetime_format('09/13/2023') + '%m/%d/%Y' + + >>> guess_datetime_format('2023|September|13') + [] """ cdef: NPY_DATETIMEUNIT out_bestunit From b9aa8b045331b263ca719c9d8310fc0e7b5b4242 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Sat, 16 Sep 2023 06:42:16 -0500 Subject: [PATCH 12/24] fixed trailing whitespace --- pandas/_libs/tslibs/parsing.pyx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index 272dff98ca3b1..50a7e199cc50b 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -885,11 +885,14 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: Examples -------- + >>> # Successful guess + >>> # Returns a datetime formatted string >>> guess_datetime_format('09/13/2023') '%m/%d/%Y' + >>> # Unsuccessful guess due to date string with extra or unexpected characters + >>> # Returns nothing >>> guess_datetime_format('2023|September|13') - [] """ cdef: NPY_DATETIMEUNIT out_bestunit From a993189ddb9343d9c5a25e4cb8782247b2cfc07e Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Sat, 16 Sep 2023 07:10:34 -0500 Subject: [PATCH 13/24] correct sphinx directive for guess_datetime_format with trailing whitespace --- pandas/_libs/tslibs/parsing.pyx | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index 50a7e199cc50b..93bede780f21c 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -874,8 +874,11 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: Datetime string to guess the format of. dayfirst : bool, default False If True parses dates with the day first, eg 20/01/2005 - .. warning:: dayfirst=True is not strict, but will prefer to parse - with day first (this is a known bug). + + ..warning:: + + dayfirst=True is not strict, but will prefer to parse + with day first (this is a known bug). Returns ------- From a1c56cbfb9154c76b3d60076bd8fc55b21e00470 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Sat, 16 Sep 2023 16:35:09 -0500 Subject: [PATCH 14/24] updated whatsnew with corrected guess_datatime_format api method string --- doc/source/whatsnew/v2.2.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.2.0.rst b/doc/source/whatsnew/v2.2.0.rst index 92cf47f24c9c5..2e950cb4d3174 100644 --- a/doc/source/whatsnew/v2.2.0.rst +++ b/doc/source/whatsnew/v2.2.0.rst @@ -45,7 +45,7 @@ enhancement2 Other enhancements ^^^^^^^^^^^^^^^^^^ -- :meth:`pandas.tseries.guess_datetime_format` is now available (:issue:`54727`) +- :meth:`pandas.tseries.api.guess_datetime_format` is now available (:issue:`54727`) - DataFrame.apply now allows the usage of numba (via ``engine="numba"``) to JIT compile the passed function, allowing for potential speedups (:issue:`54666`) .. --------------------------------------------------------------------------- From 6519ccb7c21afc11943110cf38db570ca718566f Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Mon, 18 Sep 2023 18:24:54 -0500 Subject: [PATCH 15/24] removed extra line --- doc/source/whatsnew/v2.1.1.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/whatsnew/v2.1.1.rst b/doc/source/whatsnew/v2.1.1.rst index e68af0e25f97a..f60560dfe6ccd 100644 --- a/doc/source/whatsnew/v2.1.1.rst +++ b/doc/source/whatsnew/v2.1.1.rst @@ -44,7 +44,6 @@ Bug fixes Other ~~~~~ - .. --------------------------------------------------------------------------- .. _whatsnew_211.contributors: From bc77ac7bea0e6b06cdc0108e8a1e5311637d281b Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Mon, 18 Sep 2023 18:27:32 -0500 Subject: [PATCH 16/24] removed comment lines in example for guess_datetime_format --- pandas/_libs/tslibs/parsing.pyx | 4 ---- 1 file changed, 4 deletions(-) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index 93bede780f21c..b2c04b002d8e3 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -888,13 +888,9 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: Examples -------- - >>> # Successful guess - >>> # Returns a datetime formatted string >>> guess_datetime_format('09/13/2023') '%m/%d/%Y' - >>> # Unsuccessful guess due to date string with extra or unexpected characters - >>> # Returns nothing >>> guess_datetime_format('2023|September|13') """ cdef: From e04af8d5092234889eba87073f7b644f2b2bf0b4 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Mon, 18 Sep 2023 18:28:25 -0500 Subject: [PATCH 17/24] removed api from method call for guess_datetime_format --- doc/source/whatsnew/v2.2.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v2.2.0.rst b/doc/source/whatsnew/v2.2.0.rst index 2e950cb4d3174..92cf47f24c9c5 100644 --- a/doc/source/whatsnew/v2.2.0.rst +++ b/doc/source/whatsnew/v2.2.0.rst @@ -45,7 +45,7 @@ enhancement2 Other enhancements ^^^^^^^^^^^^^^^^^^ -- :meth:`pandas.tseries.api.guess_datetime_format` is now available (:issue:`54727`) +- :meth:`pandas.tseries.guess_datetime_format` is now available (:issue:`54727`) - DataFrame.apply now allows the usage of numba (via ``engine="numba"``) to JIT compile the passed function, allowing for potential speedups (:issue:`54666`) .. --------------------------------------------------------------------------- From ffa56916fcdcf56de032265b883d359bfe8ba344 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Mon, 18 Sep 2023 18:39:16 -0500 Subject: [PATCH 18/24] pre-commit hook fix for whitespace --- doc/source/reference/general_functions.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/source/reference/general_functions.rst b/doc/source/reference/general_functions.rst index 7586e4bcf36fb..998748d7af4d3 100644 --- a/doc/source/reference/general_functions.rst +++ b/doc/source/reference/general_functions.rst @@ -58,7 +58,10 @@ Top-level dealing with datetimelike data period_range timedelta_range infer_freq - guess_datetime_format + +.. autosummary:: + :toctree : api/ + pandas.tseries.guess_datetime_format Top-level dealing with Interval data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From e4f99dab1c25dc677c8652029b6d4c4e473dd23b Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Mon, 18 Sep 2023 19:22:24 -0500 Subject: [PATCH 19/24] fix extra char --- doc/source/reference/general_functions.rst | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/source/reference/general_functions.rst b/doc/source/reference/general_functions.rst index 998748d7af4d3..18a8aab73bb22 100644 --- a/doc/source/reference/general_functions.rst +++ b/doc/source/reference/general_functions.rst @@ -59,8 +59,11 @@ Top-level dealing with datetimelike data timedelta_range infer_freq +Top-level dealing with datetimelike data formatting +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autosummary:: :toctree : api/ + pandas.tseries.guess_datetime_format Top-level dealing with Interval data From 92ea6e721a751f7ee3c11e1d684c1145d70b8a13 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Mon, 18 Sep 2023 19:52:37 -0500 Subject: [PATCH 20/24] fix whitespace --- doc/source/reference/general_functions.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/source/reference/general_functions.rst b/doc/source/reference/general_functions.rst index 18a8aab73bb22..fb1f1a7d3076a 100644 --- a/doc/source/reference/general_functions.rst +++ b/doc/source/reference/general_functions.rst @@ -59,6 +59,12 @@ Top-level dealing with datetimelike data timedelta_range infer_freq +.. autosummary:: + :toctree: api/ + :currentmodule: pandas.tseries.frequencies + + guess_datetime_format + Top-level dealing with datetimelike data formatting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .. autosummary:: From 90f912b07954ba09d7fb7dbef27ec15dc9dad745 Mon Sep 17 00:00:00 2001 From: Donald Thevalingam Date: Mon, 18 Sep 2023 20:06:39 -0500 Subject: [PATCH 21/24] removed toctree api --- doc/source/reference/general_functions.rst | 1 - 1 file changed, 1 deletion(-) diff --git a/doc/source/reference/general_functions.rst b/doc/source/reference/general_functions.rst index fb1f1a7d3076a..c1ea38ebc3f51 100644 --- a/doc/source/reference/general_functions.rst +++ b/doc/source/reference/general_functions.rst @@ -60,7 +60,6 @@ Top-level dealing with datetimelike data infer_freq .. autosummary:: - :toctree: api/ :currentmodule: pandas.tseries.frequencies guess_datetime_format From 0e03f49654fe70d928e155fc767b77809f3b5423 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 26 Oct 2023 12:09:43 +0100 Subject: [PATCH 22/24] fixup --- doc/source/reference/general_functions.rst | 20 ++++++++------------ pandas/_libs/tslibs/parsing.pyx | 3 +-- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/doc/source/reference/general_functions.rst b/doc/source/reference/general_functions.rst index c1ea38ebc3f51..f21636290de7c 100644 --- a/doc/source/reference/general_functions.rst +++ b/doc/source/reference/general_functions.rst @@ -59,20 +59,9 @@ Top-level dealing with datetimelike data timedelta_range infer_freq -.. autosummary:: - :currentmodule: pandas.tseries.frequencies - - guess_datetime_format - -Top-level dealing with datetimelike data formatting -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -.. autosummary:: - :toctree : api/ - - pandas.tseries.guess_datetime_format - Top-level dealing with Interval data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + .. autosummary:: :toctree: api/ @@ -85,6 +74,13 @@ Top-level evaluation eval +Datetime formats +~~~~~~~~~~~~~~~~ +.. autosummary:: + :toctree: api/ + + tseries.api.guess_datetime_format + Hashing ~~~~~~~ .. autosummary:: diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index bbc8530d09ce5..6a45e90dc6150 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -875,8 +875,7 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: dayfirst : bool, default False If True parses dates with the day first, eg 20/01/2005 - ..warning:: - + .. warning:: dayfirst=True is not strict, but will prefer to parse with day first (this is a known bug). From 16a14c1db8a578a222759f748a2178e147e772c0 Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 26 Oct 2023 14:03:07 +0100 Subject: [PATCH 23/24] try fixing docstring --- pandas/_libs/tslibs/parsing.pyi | 2 +- pandas/_libs/tslibs/parsing.pyx | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/pandas/_libs/tslibs/parsing.pyi b/pandas/_libs/tslibs/parsing.pyi index 2a2d98dab0d8b..40394f915d4b0 100644 --- a/pandas/_libs/tslibs/parsing.pyi +++ b/pandas/_libs/tslibs/parsing.pyi @@ -24,7 +24,7 @@ def try_parse_dates( parser, ) -> npt.NDArray[np.object_]: ... def guess_datetime_format( - dt_str, + dt_str: str, dayfirst: bool | None = ..., ) -> str | None: ... def concat_date_cols( diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index c53bc8a21caf8..bfdd6c58432fa 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -868,6 +868,7 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: Examples -------- + >>> from pandas.tseries.api import guess_datetime_format >>> guess_datetime_format('09/13/2023') '%m/%d/%Y' From 0f0f7efa52b9e8bfe70ff4933afe82d4924ff7ce Mon Sep 17 00:00:00 2001 From: MarcoGorelli <33491632+MarcoGorelli@users.noreply.github.com> Date: Thu, 26 Oct 2023 17:36:35 +0100 Subject: [PATCH 24/24] add whatsnew note --- doc/source/reference/general_functions.rst | 1 - doc/source/whatsnew/v2.2.0.rst | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/reference/general_functions.rst b/doc/source/reference/general_functions.rst index f21636290de7c..e93514de5f762 100644 --- a/doc/source/reference/general_functions.rst +++ b/doc/source/reference/general_functions.rst @@ -61,7 +61,6 @@ Top-level dealing with datetimelike data Top-level dealing with Interval data ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - .. autosummary:: :toctree: api/ diff --git a/doc/source/whatsnew/v2.2.0.rst b/doc/source/whatsnew/v2.2.0.rst index 795d277268e44..4ebd65208df81 100644 --- a/doc/source/whatsnew/v2.2.0.rst +++ b/doc/source/whatsnew/v2.2.0.rst @@ -78,6 +78,7 @@ Other enhancements - :attr:`Series.attrs` / :attr:`DataFrame.attrs` now uses a deepcopy for propagating ``attrs`` (:issue:`54134`). - :func:`read_csv` now supports ``on_bad_lines`` parameter with ``engine="pyarrow"``. (:issue:`54480`) - :func:`read_spss` now returns a :class:`DataFrame` that stores the metadata in :attr:`DataFrame.attrs`. (:issue:`54264`) +- :func:`tseries.api.guess_datetime_format` is now part of the public API (:issue:`54727`) - :meth:`ExtensionArray._explode` interface method added to allow extension type implementations of the ``explode`` method (:issue:`54833`) - :meth:`ExtensionArray.duplicated` added to allow extension type implementations of the ``duplicated`` method (:issue:`55255`) - DataFrame.apply now allows the usage of numba (via ``engine="numba"``) to JIT compile the passed function, allowing for potential speedups (:issue:`54666`)