From 16452fce805721dd76e08769875d6a334a896c43 Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 00:15:28 -0400 Subject: [PATCH 1/9] #21128 adding documentation for freq in datetimes.py --- pandas/core/indexes/datetimes.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index 83950f1d71633..be6d05e04c977 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -186,7 +186,10 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin, copy : bool Make a copy of input ndarray freq : string or pandas offset object, optional - One of pandas date offset strings or corresponding objects + One of pandas date offset strings or corresponding objects. The string + 'infer' can be passed in order to allow users to set the frequency of + the index as the inferred frequency upon creation + start : starting value, datetime-like, optional If data is None, start is used as the start point in generating regular timestamp data. From 3180573dbb55dbe313232ed2a3afa6a0a8c47b05 Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 00:16:43 -0400 Subject: [PATCH 2/9] #21128 adding documentation for freq in timedeltas.py --- pandas/core/indexes/timedeltas.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index 9707d19953418..f0fd622b13f81 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -107,7 +107,10 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, TimelikeOps, Int64Index): Optional timedelta-like data to construct index with unit: unit of the arg (D,h,m,s,ms,us,ns) denote the unit, optional which is an integer/float number - freq: a frequency for the index, optional + freq : string or pandas offset object, optional + One of pandas date offset strings or corresponding objects. The string + 'infer' can be passed in order to allow users to set the frequency of + the index as the inferred frequency upon creation copy : bool Make a copy of input ndarray start : starting value, timedelta-like, optional From efbd4d17945e45401653ffb65cef02681e4d787c Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 00:19:21 -0400 Subject: [PATCH 3/9] #21128 adding examples for freq=infer field --- doc/source/timedeltas.rst | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/doc/source/timedeltas.rst b/doc/source/timedeltas.rst index 745810704f665..429812045c55d 100644 --- a/doc/source/timedeltas.rst +++ b/doc/source/timedeltas.rst @@ -363,6 +363,12 @@ or ``np.timedelta64`` objects. Passing ``np.nan/pd.NaT/nat`` will represent miss pd.TimedeltaIndex(['1 days', '1 days, 00:00:05', np.timedelta64(2,'D'), datetime.timedelta(days=2,seconds=2)]) + In [5]: pd.TimedeltaIndex(['0 days', '10 days', '20 days']) + Out[5]: TimedeltaIndex(['0 days', '10 days', '20 days'], dtype='timedelta64[ns]', freq=None) + + In [4]: pd.TimedeltaIndex(['0 days', '10 days', '20 days'], freq='infer') + Out[4]: TimedeltaIndex(['0 days', '10 days', '20 days'], dtype='timedelta64[ns]', freq='10D') + Generating Ranges of Time Deltas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From aec1037484bf5a374c0049e5636c125fcbc7071f Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 00:20:37 -0400 Subject: [PATCH 4/9] #21128 adding examples for freq=infer in timeseries.rst --- doc/source/timeseries.rst | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 1b0cf86995a39..1148c159d998f 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -185,6 +185,13 @@ options like ``dayfirst`` or ``format``, so use ``to_datetime`` if these are req pd.Timestamp('2010/11/12') +You can also use the `DatetimeIndex` constructor directly: +In [3]: pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05']) +Out[3]: DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], dtype='datetime64[ns]', freq=None) + +In [2]: pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], freq='infer') +Out[2]: DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], dtype='datetime64[ns]', freq='2D') + Providing a Format Argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From daf1f8677e184b7088c52fbbb3252e157e1c698b Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 19:02:34 -0400 Subject: [PATCH 5/9] 21128 updating infer documentation in timedeltas.rst --- doc/source/timedeltas.rst | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/doc/source/timedeltas.rst b/doc/source/timedeltas.rst index 429812045c55d..691b89ccd8c14 100644 --- a/doc/source/timedeltas.rst +++ b/doc/source/timedeltas.rst @@ -363,11 +363,12 @@ or ``np.timedelta64`` objects. Passing ``np.nan/pd.NaT/nat`` will represent miss pd.TimedeltaIndex(['1 days', '1 days, 00:00:05', np.timedelta64(2,'D'), datetime.timedelta(days=2,seconds=2)]) - In [5]: pd.TimedeltaIndex(['0 days', '10 days', '20 days']) - Out[5]: TimedeltaIndex(['0 days', '10 days', '20 days'], dtype='timedelta64[ns]', freq=None) +'infer' can be passed in order to set the frequency of the index as the inferred frequency +upon creation - In [4]: pd.TimedeltaIndex(['0 days', '10 days', '20 days'], freq='infer') - Out[4]: TimedeltaIndex(['0 days', '10 days', '20 days'], dtype='timedelta64[ns]', freq='10D') +.. ipython:: python + + pd.TimedeltaIndex(['0 days', '10 days', '20 days'], freq='infer') Generating Ranges of Time Deltas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From e50abd3ae2778c328d1f82e5aa58c51a40f2e22d Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 19:04:51 -0400 Subject: [PATCH 6/9] 21128 updating infer documentation in timeseries.rst --- doc/source/timeseries.rst | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 1148c159d998f..223b2228d1230 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -186,11 +186,15 @@ options like ``dayfirst`` or ``format``, so use ``to_datetime`` if these are req pd.Timestamp('2010/11/12') You can also use the `DatetimeIndex` constructor directly: -In [3]: pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05']) -Out[3]: DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], dtype='datetime64[ns]', freq=None) -In [2]: pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], freq='infer') -Out[2]: DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], dtype='datetime64[ns]', freq='2D') +'infer' can be passed in order to set the frequency of the index as the inferred frequency +upon creation + +.. ipython:: python + + pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05']) + + pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], freq='infer') Providing a Format Argument ~~~~~~~~~~~~~~~~~~~~~~~~~~~ From 35164d598e2d06c7b511f307c5017ab9cd7aaea3 Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 19:06:54 -0400 Subject: [PATCH 7/9] 21128 updating documentation for infer in datetimes.py --- pandas/core/indexes/datetimes.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/datetimes.py b/pandas/core/indexes/datetimes.py index be6d05e04c977..963eb6dc053bf 100644 --- a/pandas/core/indexes/datetimes.py +++ b/pandas/core/indexes/datetimes.py @@ -187,8 +187,8 @@ class DatetimeIndex(DatelikeOps, TimelikeOps, DatetimeIndexOpsMixin, Make a copy of input ndarray freq : string or pandas offset object, optional One of pandas date offset strings or corresponding objects. The string - 'infer' can be passed in order to allow users to set the frequency of - the index as the inferred frequency upon creation + 'infer' can be passed in order to set the frequency of the index as the + inferred frequency upon creation start : starting value, datetime-like, optional If data is None, start is used as the start point in generating regular From 93163a64830025031a069bea62dfaa25c32e08d5 Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 19:08:08 -0400 Subject: [PATCH 8/9] 21128 updating documentation for infer in timedeltas.py --- pandas/core/indexes/timedeltas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index f0fd622b13f81..a39a48c4ca56b 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -109,8 +109,8 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, TimelikeOps, Int64Index): which is an integer/float number freq : string or pandas offset object, optional One of pandas date offset strings or corresponding objects. The string - 'infer' can be passed in order to allow users to set the frequency of - the index as the inferred frequency upon creation + 'infer' can be passed in order to set the frequency of the index as the + inferred frequency upon creation copy : bool Make a copy of input ndarray start : starting value, timedelta-like, optional From 3d833501a06ed2eda3b8c05650fdb7f82e5aa9f9 Mon Sep 17 00:00:00 2001 From: jschendel Date: Wed, 20 Jun 2018 17:11:05 -0600 Subject: [PATCH 9/9] final fixups --- doc/source/timedeltas.rst | 4 ++-- doc/source/timeseries.rst | 10 ++++++---- pandas/core/indexes/timedeltas.py | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/doc/source/timedeltas.rst b/doc/source/timedeltas.rst index 691b89ccd8c14..e602e45784f4a 100644 --- a/doc/source/timedeltas.rst +++ b/doc/source/timedeltas.rst @@ -363,8 +363,8 @@ or ``np.timedelta64`` objects. Passing ``np.nan/pd.NaT/nat`` will represent miss pd.TimedeltaIndex(['1 days', '1 days, 00:00:05', np.timedelta64(2,'D'), datetime.timedelta(days=2,seconds=2)]) -'infer' can be passed in order to set the frequency of the index as the inferred frequency -upon creation +The string 'infer' can be passed in order to set the frequency of the index as the +inferred frequency upon creation: .. ipython:: python diff --git a/doc/source/timeseries.rst b/doc/source/timeseries.rst index 223b2228d1230..5262eedc23baa 100644 --- a/doc/source/timeseries.rst +++ b/doc/source/timeseries.rst @@ -185,15 +185,17 @@ options like ``dayfirst`` or ``format``, so use ``to_datetime`` if these are req pd.Timestamp('2010/11/12') -You can also use the `DatetimeIndex` constructor directly: - -'infer' can be passed in order to set the frequency of the index as the inferred frequency -upon creation +You can also use the ``DatetimeIndex`` constructor directly: .. ipython:: python pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05']) +The string 'infer' can be passed in order to set the frequency of the index as the +inferred frequency upon creation: + +.. ipython:: python + pd.DatetimeIndex(['2018-01-01', '2018-01-03', '2018-01-05'], freq='infer') Providing a Format Argument diff --git a/pandas/core/indexes/timedeltas.py b/pandas/core/indexes/timedeltas.py index a39a48c4ca56b..e90e1264638b0 100644 --- a/pandas/core/indexes/timedeltas.py +++ b/pandas/core/indexes/timedeltas.py @@ -110,7 +110,7 @@ class TimedeltaIndex(DatetimeIndexOpsMixin, TimelikeOps, Int64Index): freq : string or pandas offset object, optional One of pandas date offset strings or corresponding objects. The string 'infer' can be passed in order to set the frequency of the index as the - inferred frequency upon creation + inferred frequency upon creation copy : bool Make a copy of input ndarray start : starting value, timedelta-like, optional