From 16452fce805721dd76e08769875d6a334a896c43 Mon Sep 17 00:00:00 2001 From: vak Date: Fri, 25 May 2018 00:15:28 -0400 Subject: [PATCH 1/8] #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/8] #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/8] #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/8] #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/8] 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/8] 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/8] 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/8] 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