From 875d0d8f107782b3847e633b582893e75b72b9a1 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Fri, 17 May 2024 22:47:01 +0530 Subject: [PATCH 1/3] DOC: add SA01 for pandas.tseries.api.guess_datetime_format --- 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 c448a7e7c01b5..701ceafd7f976 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -859,6 +859,11 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: """ Guess the datetime format of a given datetime string. + This function attempts to deduce the format of a given datetime string. It is + useful for situations where the datetime format is unknown and needs to be + determined for proper parsing. The function handles various datetime components + including year, month, day, hour, minute, second, and timezone information. + Parameters ---------- dt_str : str @@ -876,6 +881,12 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: datetime format string (for `strftime` or `strptime`), or None if it can't be guessed. + See Also + -------- + to_datetime : Convert argument to datetime. + Timestamp : Pandas replacement for python datetime.datetime object. + DatetimeIndex : Immutable ndarray-like of datetime64 data. + Examples -------- >>> from pandas.tseries.api import guess_datetime_format From 578dfd7cf1bfc621c6012892b6bbcd472671af5d Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Fri, 17 May 2024 22:47:11 +0530 Subject: [PATCH 2/3] DOC: remove SA01 for pandas.tseries.api.guess_datetime_format --- ci/code_checks.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/ci/code_checks.sh b/ci/code_checks.sh index a194c340c63a5..62bea85387622 100755 --- a/ci/code_checks.sh +++ b/ci/code_checks.sh @@ -527,7 +527,6 @@ if [[ -z "$CHECK" || "$CHECK" == "docstrings" ]]; then -i "pandas.testing.assert_index_equal PR07,SA01" \ -i "pandas.testing.assert_series_equal PR07,SA01" \ -i "pandas.timedelta_range SA01" \ - -i "pandas.tseries.api.guess_datetime_format SA01" \ -i "pandas.tseries.offsets.BDay PR02,SA01" \ -i "pandas.tseries.offsets.BMonthBegin PR02" \ -i "pandas.tseries.offsets.BQuarterBegin PR02" \ From 640ecad3b7e1918ca8240d22c482109a935d0d51 Mon Sep 17 00:00:00 2001 From: tuhinsharma121 Date: Sat, 18 May 2024 00:48:53 +0530 Subject: [PATCH 3/3] DOC: incorporate review suggestions Co-authored-by: mroeschke --- pandas/_libs/tslibs/parsing.pyx | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/_libs/tslibs/parsing.pyx b/pandas/_libs/tslibs/parsing.pyx index 701ceafd7f976..35d2433a707a0 100644 --- a/pandas/_libs/tslibs/parsing.pyx +++ b/pandas/_libs/tslibs/parsing.pyx @@ -861,8 +861,7 @@ def guess_datetime_format(dt_str: str, bint dayfirst=False) -> str | None: This function attempts to deduce the format of a given datetime string. It is useful for situations where the datetime format is unknown and needs to be - determined for proper parsing. The function handles various datetime components - including year, month, day, hour, minute, second, and timezone information. + determined for proper parsing. The function is not guaranteed to return a format. Parameters ----------