From 284092f21f23b9a4a2810a892d40465d392874d0 Mon Sep 17 00:00:00 2001 From: Vladimir Podolskiy Date: Tue, 2 Feb 2021 15:47:09 +0100 Subject: [PATCH 1/3] Added an example for infer_freq Added an example for infer_freq function. The initial index is built using a fixed number of periods to avoid encoding frequency in this index explicitly. --- pandas/tseries/frequencies.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index c5b875b8f027e..13de6047d0d9d 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -145,6 +145,13 @@ def infer_freq(index, warn: bool = True) -> Optional[str]: If the index is not datetime-like. ValueError If there are fewer than three values. + + Examples + -------- + >>> idx = pd.date_range(start = '2020/12/01', end = '2020/12/30', periods = 30) + >>> pd.infer_freq(idx) + 'D' + """ import pandas as pd From 8725a486a38b8f20d91bdfb85577beaba28d86fb Mon Sep 17 00:00:00 2001 From: Vladimir Podolskiy Date: Tue, 2 Feb 2021 17:24:45 +0100 Subject: [PATCH 2/3] Update frequencies.py Removed empty line and deleted spaces. --- pandas/tseries/frequencies.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 13de6047d0d9d..0a49c5e555f11 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -145,13 +145,12 @@ def infer_freq(index, warn: bool = True) -> Optional[str]: If the index is not datetime-like. ValueError If there are fewer than three values. - + Examples -------- >>> idx = pd.date_range(start = '2020/12/01', end = '2020/12/30', periods = 30) >>> pd.infer_freq(idx) 'D' - """ import pandas as pd From 5e6d4173a4768dc46260bc4cea64a6146f00cfa3 Mon Sep 17 00:00:00 2001 From: Vladimir Podolskiy Date: Mon, 29 Mar 2021 16:36:46 +0200 Subject: [PATCH 3/3] Deleted spaces from parameters list in example --- pandas/tseries/frequencies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tseries/frequencies.py b/pandas/tseries/frequencies.py index 0a49c5e555f11..ea60bc7f91a36 100644 --- a/pandas/tseries/frequencies.py +++ b/pandas/tseries/frequencies.py @@ -148,7 +148,7 @@ def infer_freq(index, warn: bool = True) -> Optional[str]: Examples -------- - >>> idx = pd.date_range(start = '2020/12/01', end = '2020/12/30', periods = 30) + >>> idx = pd.date_range(start='2020/12/01', end='2020/12/30', periods=30) >>> pd.infer_freq(idx) 'D' """