From f1d4a102c24919bf4b467b5f1ce96d8f080c61e3 Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sat, 10 Oct 2020 08:26:51 +0200 Subject: [PATCH 01/17] remove assert in core/generic.py and add test for datetimeindex slicing --- pandas/core/generic.py | 2 +- pandas/tests/generic/test_generic.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 338b45b5503dc..faabe77191ea6 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3736,7 +3736,7 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries: Slicing with this method is *always* positional. """ - assert isinstance(slobj, slice), type(slobj) + # assert isinstance(slobj, slice), type(slobj) axis = self._get_block_manager_axis(axis) result = self._constructor(self._mgr.get_slice(slobj, axis=axis)) result = result.__finalize__(self) diff --git a/pandas/tests/generic/test_generic.py b/pandas/tests/generic/test_generic.py index 2c2584e8dee01..20f2c65dd2467 100644 --- a/pandas/tests/generic/test_generic.py +++ b/pandas/tests/generic/test_generic.py @@ -897,3 +897,12 @@ def test_flags_identity(self, as_frame): assert s.flags is s.flags s2 = s.copy() assert s2.flags is not s.flags + + def test_slice_incomplete_datetimes(self): + # GH36953 and GH35509 + increment = pd.Series(pd.to_timedelta([30.0, 30.1, 29.9, 30.0], unit='s')).cumsum() + increment[-1] = None + index = pd.Timestamp("2012-01-01 09:00") + increment + df = pd.Series(range(len(index)), index=index).to_frame() + assert len(df["2012-01-01":"2012-01-05"]) == 1000 + From cd1a136096e78bfb0605b150c697b4abf210b2e5 Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sat, 10 Oct 2020 08:31:37 +0200 Subject: [PATCH 02/17] fix formatting in test_generic --- pandas/tests/generic/test_generic.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/pandas/tests/generic/test_generic.py b/pandas/tests/generic/test_generic.py index 20f2c65dd2467..ba1c2605efc81 100644 --- a/pandas/tests/generic/test_generic.py +++ b/pandas/tests/generic/test_generic.py @@ -900,9 +900,10 @@ def test_flags_identity(self, as_frame): def test_slice_incomplete_datetimes(self): # GH36953 and GH35509 - increment = pd.Series(pd.to_timedelta([30.0, 30.1, 29.9, 30.0], unit='s')).cumsum() + increment = pd.Series( + pd.to_timedelta([30.0, 30.1, 29.9, 30.0], unit="s") + ).cumsum() increment[-1] = None index = pd.Timestamp("2012-01-01 09:00") + increment df = pd.Series(range(len(index)), index=index).to_frame() assert len(df["2012-01-01":"2012-01-05"]) == 1000 - From fe478c40071588d3c4551643945d3bd9afab95f4 Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sat, 10 Oct 2020 08:54:16 +0200 Subject: [PATCH 03/17] fix test and remove commented line --- pandas/core/generic.py | 1 - pandas/tests/generic/test_generic.py | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index faabe77191ea6..500911fb727d6 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3736,7 +3736,6 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries: Slicing with this method is *always* positional. """ - # assert isinstance(slobj, slice), type(slobj) axis = self._get_block_manager_axis(axis) result = self._constructor(self._mgr.get_slice(slobj, axis=axis)) result = result.__finalize__(self) diff --git a/pandas/tests/generic/test_generic.py b/pandas/tests/generic/test_generic.py index ba1c2605efc81..6d569ba9e0cdb 100644 --- a/pandas/tests/generic/test_generic.py +++ b/pandas/tests/generic/test_generic.py @@ -906,4 +906,4 @@ def test_slice_incomplete_datetimes(self): increment[-1] = None index = pd.Timestamp("2012-01-01 09:00") + increment df = pd.Series(range(len(index)), index=index).to_frame() - assert len(df["2012-01-01":"2012-01-05"]) == 1000 + assert len(df["2012-01-01":"2012-01-05"]) == 4 From 15a91854ebdbdd53f550e367aacb06c8cbfca4ed Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sat, 10 Oct 2020 09:35:26 +0200 Subject: [PATCH 04/17] updated tests according to PR comments --- pandas/tests/frame/test_timeseries.py | 19 +++++++++++++++++++ pandas/tests/generic/test_generic.py | 10 ---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index 63361789b8e50..5041757fe0301 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -63,3 +63,22 @@ def test_datetime_assignment_with_NaT_and_diff_time_units(self): {0: [1, None], "new": [1e9, None]}, dtype="datetime64[ns]" ) tm.assert_frame_equal(result, expected) + + def test_slice_irregular_datetime_index_with_nan(self): + # GH36953 + index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03", None]) + df = pd.DataFrame(range(len(index)), index=index) + expected = pd.DataFrame(range(len(index[:3])), index=index[:3]) + tm.assert_frame_equal(df["2012-01-01":"2012-01-04"], expected) + + def test_slice_datetime_index(self): + # GH35509 + df = pd.DataFrame( + {"col1": ["a", "b", "c"], "col2": [1, 2, 3]}, + index=pd.to_datetime(["2020-08-01", "2020-07-02", "2020-08-05"]), + ) + expected = pd.DataFrame( + {"col1": ["a", "c"], "col2": [1, 3]}, + index=pd.to_datetime(["2020-08-01", "2020-08-05"]), + ) + tm.assert_frame_equal(df["2020-08"], expected) diff --git a/pandas/tests/generic/test_generic.py b/pandas/tests/generic/test_generic.py index 6d569ba9e0cdb..2c2584e8dee01 100644 --- a/pandas/tests/generic/test_generic.py +++ b/pandas/tests/generic/test_generic.py @@ -897,13 +897,3 @@ def test_flags_identity(self, as_frame): assert s.flags is s.flags s2 = s.copy() assert s2.flags is not s.flags - - def test_slice_incomplete_datetimes(self): - # GH36953 and GH35509 - increment = pd.Series( - pd.to_timedelta([30.0, 30.1, 29.9, 30.0], unit="s") - ).cumsum() - increment[-1] = None - index = pd.Timestamp("2012-01-01 09:00") + increment - df = pd.Series(range(len(index)), index=index).to_frame() - assert len(df["2012-01-01":"2012-01-05"]) == 4 From 6caba474f2df9641553a5206e8a4dd7cd2fdb2dd Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sat, 10 Oct 2020 10:10:31 +0200 Subject: [PATCH 05/17] slice with loc to prevent future warning --- pandas/io/formats/css.py | 20 +++++--------------- pandas/tests/frame/test_timeseries.py | 3 ++- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/pandas/io/formats/css.py b/pandas/io/formats/css.py index 8abe13db370ca..230c33d9bfa15 100644 --- a/pandas/io/formats/css.py +++ b/pandas/io/formats/css.py @@ -86,9 +86,7 @@ class CSSResolver: SIDES = ("top", "right", "bottom", "left") def __call__( - self, - declarations_str: str, - inherited: Optional[Dict[str, str]] = None, + self, declarations_str: str, inherited: Optional[Dict[str, str]] = None, ) -> Dict[str, str]: """ The given declarations to atomic properties. @@ -136,9 +134,7 @@ def __call__( return self._update_other_units(props) def _update_initial( - self, - props: Dict[str, str], - inherited: Dict[str, str], + self, props: Dict[str, str], inherited: Dict[str, str], ) -> Dict[str, str]: # 1. resolve inherited, initial for prop, val in inherited.items(): @@ -158,9 +154,7 @@ def _update_initial( return new_props def _update_font_size( - self, - props: Dict[str, str], - inherited: Dict[str, str], + self, props: Dict[str, str], inherited: Dict[str, str], ) -> Dict[str, str]: # 2. resolve relative font size if props.get("font-size"): @@ -188,18 +182,14 @@ def _update_other_units(self, props: Dict[str, str]) -> Dict[str, str]: prop = f"border-{side}-width" if prop in props: props[prop] = self.size_to_pt( - props[prop], - em_pt=font_size, - conversions=self.BORDER_WIDTH_RATIOS, + props[prop], em_pt=font_size, conversions=self.BORDER_WIDTH_RATIOS, ) for prop in [f"margin-{side}", f"padding-{side}"]: if prop in props: # TODO: support % props[prop] = self.size_to_pt( - props[prop], - em_pt=font_size, - conversions=self.MARGIN_RATIOS, + props[prop], em_pt=font_size, conversions=self.MARGIN_RATIOS, ) return props diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index 5041757fe0301..73735fcb83e40 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -81,4 +81,5 @@ def test_slice_datetime_index(self): {"col1": ["a", "c"], "col2": [1, 3]}, index=pd.to_datetime(["2020-08-01", "2020-08-05"]), ) - tm.assert_frame_equal(df["2020-08"], expected) + tm.assert_frame_equal(df.loc["2020-08"], expected) + From 57039946a73de47f58f2cb0eb75d53eddaa76fdd Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sat, 10 Oct 2020 10:20:44 +0200 Subject: [PATCH 06/17] revert changes in io/formats/css.py --- pandas/io/formats/css.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/pandas/io/formats/css.py b/pandas/io/formats/css.py index 230c33d9bfa15..8abe13db370ca 100644 --- a/pandas/io/formats/css.py +++ b/pandas/io/formats/css.py @@ -86,7 +86,9 @@ class CSSResolver: SIDES = ("top", "right", "bottom", "left") def __call__( - self, declarations_str: str, inherited: Optional[Dict[str, str]] = None, + self, + declarations_str: str, + inherited: Optional[Dict[str, str]] = None, ) -> Dict[str, str]: """ The given declarations to atomic properties. @@ -134,7 +136,9 @@ def __call__( return self._update_other_units(props) def _update_initial( - self, props: Dict[str, str], inherited: Dict[str, str], + self, + props: Dict[str, str], + inherited: Dict[str, str], ) -> Dict[str, str]: # 1. resolve inherited, initial for prop, val in inherited.items(): @@ -154,7 +158,9 @@ def _update_initial( return new_props def _update_font_size( - self, props: Dict[str, str], inherited: Dict[str, str], + self, + props: Dict[str, str], + inherited: Dict[str, str], ) -> Dict[str, str]: # 2. resolve relative font size if props.get("font-size"): @@ -182,14 +188,18 @@ def _update_other_units(self, props: Dict[str, str]) -> Dict[str, str]: prop = f"border-{side}-width" if prop in props: props[prop] = self.size_to_pt( - props[prop], em_pt=font_size, conversions=self.BORDER_WIDTH_RATIOS, + props[prop], + em_pt=font_size, + conversions=self.BORDER_WIDTH_RATIOS, ) for prop in [f"margin-{side}", f"padding-{side}"]: if prop in props: # TODO: support % props[prop] = self.size_to_pt( - props[prop], em_pt=font_size, conversions=self.MARGIN_RATIOS, + props[prop], + em_pt=font_size, + conversions=self.MARGIN_RATIOS, ) return props From 4a7ff03c1f6eba15e3fca3b13869f4f2a340790f Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sat, 10 Oct 2020 10:41:21 +0200 Subject: [PATCH 07/17] run black on test_timeseries.py --- pandas/tests/frame/test_timeseries.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index 73735fcb83e40..54e7d6c7e5b96 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -82,4 +82,3 @@ def test_slice_datetime_index(self): index=pd.to_datetime(["2020-08-01", "2020-08-05"]), ) tm.assert_frame_equal(df.loc["2020-08"], expected) - From 25b229c425765bec6e9203a30fade4ced199ff15 Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sun, 11 Oct 2020 19:57:32 +0200 Subject: [PATCH 08/17] move tests to indexing/test_partial, add whatsnew entry --- doc/source/whatsnew/v1.1.4.rst | 1 + pandas/tests/frame/test_timeseries.py | 18 ------------------ pandas/tests/indexing/test_partial.py | 19 +++++++++++++++++++ 3 files changed, 20 insertions(+), 18 deletions(-) diff --git a/doc/source/whatsnew/v1.1.4.rst b/doc/source/whatsnew/v1.1.4.rst index 3ad8d981be2c9..22b81a5a4451d 100644 --- a/doc/source/whatsnew/v1.1.4.rst +++ b/doc/source/whatsnew/v1.1.4.rst @@ -17,6 +17,7 @@ Fixed regressions - Fixed regression where attempting to mutate a :class:`DateOffset` object would no longer raise an ``AttributeError`` (:issue:`36940`) - Fixed regression where :meth:`DataFrame.agg` would fail with :exc:`TypeError` when passed positional arguments to be passed on to the aggregation function (:issue:`36948`). - Fixed regression in :class:`RollingGroupby` with ``sort=False`` not being respected (:issue:`36889`) +- Fixed regression where slicing :class:`DatetimeIndex` failed on irregular time series with `pd.NaT` or on unsorted indices (:issue:`36953` and :issue:`35509`) .. --------------------------------------------------------------------------- diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index 54e7d6c7e5b96..aff678eb931a7 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -64,21 +64,3 @@ def test_datetime_assignment_with_NaT_and_diff_time_units(self): ) tm.assert_frame_equal(result, expected) - def test_slice_irregular_datetime_index_with_nan(self): - # GH36953 - index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03", None]) - df = pd.DataFrame(range(len(index)), index=index) - expected = pd.DataFrame(range(len(index[:3])), index=index[:3]) - tm.assert_frame_equal(df["2012-01-01":"2012-01-04"], expected) - - def test_slice_datetime_index(self): - # GH35509 - df = pd.DataFrame( - {"col1": ["a", "b", "c"], "col2": [1, 2, 3]}, - index=pd.to_datetime(["2020-08-01", "2020-07-02", "2020-08-05"]), - ) - expected = pd.DataFrame( - {"col1": ["a", "c"], "col2": [1, 3]}, - index=pd.to_datetime(["2020-08-01", "2020-08-05"]), - ) - tm.assert_frame_equal(df.loc["2020-08"], expected) diff --git a/pandas/tests/indexing/test_partial.py b/pandas/tests/indexing/test_partial.py index 337ec683ee745..f021306db862e 100644 --- a/pandas/tests/indexing/test_partial.py +++ b/pandas/tests/indexing/test_partial.py @@ -681,3 +681,22 @@ def test_index_name_empty(self): {"series": [1.23] * 4}, index=pd.RangeIndex(4, name="series_index") ) tm.assert_frame_equal(df, expected) + + def test_slice_irregular_datetime_index_with_nan(self): + # GH36953 + index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03", None]) + df = pd.DataFrame(range(len(index)), index=index) + expected = pd.DataFrame(range(len(index[:3])), index=index[:3]) + tm.assert_frame_equal(df["2012-01-01":"2012-01-04"], expected) + + def test_slice_datetime_index(self): + # GH35509 + df = pd.DataFrame( + {"col1": ["a", "b", "c"], "col2": [1, 2, 3]}, + index=pd.to_datetime(["2020-08-01", "2020-07-02", "2020-08-05"]), + ) + expected = pd.DataFrame( + {"col1": ["a", "c"], "col2": [1, 3]}, + index=pd.to_datetime(["2020-08-01", "2020-08-05"]), + ) + tm.assert_frame_equal(df.loc["2020-08"], expected) From 9bb10fe0cf46a6db47cc63f938d4795691a02fe9 Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sun, 11 Oct 2020 19:58:35 +0200 Subject: [PATCH 09/17] reformat test_timeseries.py --- pandas/tests/frame/test_timeseries.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/frame/test_timeseries.py b/pandas/tests/frame/test_timeseries.py index aff678eb931a7..63361789b8e50 100644 --- a/pandas/tests/frame/test_timeseries.py +++ b/pandas/tests/frame/test_timeseries.py @@ -63,4 +63,3 @@ def test_datetime_assignment_with_NaT_and_diff_time_units(self): {0: [1, None], "new": [1e9, None]}, dtype="datetime64[ns]" ) tm.assert_frame_equal(result, expected) - From 968fdf4e380d4c96505e67c4410653a1aaf6beb0 Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Sun, 11 Oct 2020 20:06:31 +0200 Subject: [PATCH 10/17] update whatsnew --- doc/source/whatsnew/v1.1.4.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.1.4.rst b/doc/source/whatsnew/v1.1.4.rst index 7cf8d6d38168a..441c585cc0cd5 100644 --- a/doc/source/whatsnew/v1.1.4.rst +++ b/doc/source/whatsnew/v1.1.4.rst @@ -20,7 +20,7 @@ Fixed regressions - Fixed regression in :class:`RollingGroupby` with ``sort=False`` not being respected (:issue:`36889`) - Fixed regression in :meth:`Series.astype` converting ``None`` to ``"nan"`` when casting to string (:issue:`36904`) - Fixed regression in :class:`RollingGroupby` causing a segmentation fault with Index of dtype object (:issue:`36727`) -- Fixed regression where slicing :class:`DatetimeIndex` failed on irregular time series with `pd.NaT` or on unsorted indices (:issue:`36953` and :issue:`35509`) +- Fixed regression where slicing :class:`DatetimeIndex` failed on irregular time series with ``pd.NaT`` or on unsorted indices (:issue:`36953` and :issue:`35509`) .. --------------------------------------------------------------------------- From 3710514a16986f5d0bedeac00950ac0151abed99 Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Fri, 16 Oct 2020 20:30:45 +0200 Subject: [PATCH 11/17] add suggestion from comment --- pandas/core/frame.py | 2 ++ pandas/core/generic.py | 1 + 2 files changed, 3 insertions(+) diff --git a/pandas/core/frame.py b/pandas/core/frame.py index 539275c7ff617..658ffb748ec5e 100644 --- a/pandas/core/frame.py +++ b/pandas/core/frame.py @@ -2907,6 +2907,8 @@ def __getitem__(self, key): # Do we have a slicer (on rows)? indexer = convert_to_index_sliceable(self, key) if indexer is not None: + if isinstance(indexer, np.ndarray): + indexer = lib.maybe_indices_to_slice(indexer, len(self)) # either we have a slice or we have a string that can be converted # to a slice for partial-string date indexing return self._slice(indexer, axis=0) diff --git a/pandas/core/generic.py b/pandas/core/generic.py index 361f46818ddfd..ad6e89ac74a5c 100644 --- a/pandas/core/generic.py +++ b/pandas/core/generic.py @@ -3747,6 +3747,7 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries: Slicing with this method is *always* positional. """ + assert isinstance(slobj, slice), type(slobj) axis = self._get_block_manager_axis(axis) result = self._constructor(self._mgr.get_slice(slobj, axis=axis)) result = result.__finalize__(self) From 237b085c21de7cad9484d631d79890bd7db562ae Mon Sep 17 00:00:00 2001 From: Tobias Pitters Date: Fri, 16 Oct 2020 20:34:39 +0200 Subject: [PATCH 12/17] use result and expected in tests --- pandas/tests/indexing/test_partial.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pandas/tests/indexing/test_partial.py b/pandas/tests/indexing/test_partial.py index f021306db862e..87c3ec4ff8f4d 100644 --- a/pandas/tests/indexing/test_partial.py +++ b/pandas/tests/indexing/test_partial.py @@ -687,7 +687,8 @@ def test_slice_irregular_datetime_index_with_nan(self): index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03", None]) df = pd.DataFrame(range(len(index)), index=index) expected = pd.DataFrame(range(len(index[:3])), index=index[:3]) - tm.assert_frame_equal(df["2012-01-01":"2012-01-04"], expected) + result = df["2012-01-01":"2012-01-04"] + tm.assert_frame_equal(result, expected) def test_slice_datetime_index(self): # GH35509 @@ -699,4 +700,5 @@ def test_slice_datetime_index(self): {"col1": ["a", "c"], "col2": [1, 3]}, index=pd.to_datetime(["2020-08-01", "2020-08-05"]), ) - tm.assert_frame_equal(df.loc["2020-08"], expected) + result = df.loc["2020-08"] + tm.assert_frame_equal(result, expected) From 632855bca723bda167e5415d70d287332dfd2661 Mon Sep 17 00:00:00 2001 From: Tobias Pitters <31857876+CloseChoice@users.noreply.github.com> Date: Tue, 20 Oct 2020 20:49:34 +0200 Subject: [PATCH 13/17] Update doc/source/whatsnew/v1.1.4.rst Co-authored-by: Simon Hawkins --- doc/source/whatsnew/v1.1.4.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.1.4.rst b/doc/source/whatsnew/v1.1.4.rst index c821d6160adaa..454ee7de94cd3 100644 --- a/doc/source/whatsnew/v1.1.4.rst +++ b/doc/source/whatsnew/v1.1.4.rst @@ -22,7 +22,7 @@ Fixed regressions - Fixed regression in :class:`RollingGroupby` causing a segmentation fault with Index of dtype object (:issue:`36727`) - Fixed regression in :meth:`DataFrame.resample(...).apply(...)` raised ``AttributeError`` when input was a :class:`DataFrame` and only a :class:`Series` was evaluated (:issue:`36951`) - Fixed regression in :class:`PeriodDtype` comparing both equal and unequal to its string representation (:issue:`37265`) -- Fixed regression where slicing :class:`DatetimeIndex` failed on irregular time series with ``pd.NaT`` or on unsorted indices (:issue:`36953` and :issue:`35509`) +- Fixed regression where slicing :class:`DatetimeIndex` raised :exc:`AssertionError` on irregular time series with ``pd.NaT`` or on unsorted indices (:issue:`36953` and :issue:`35509`) .. --------------------------------------------------------------------------- From e246520a340b826274d5267fb858fd432b2e53db Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Mon, 26 Oct 2020 12:55:29 +0000 Subject: [PATCH 14/17] Update pandas/tests/indexing/test_partial.py --- pandas/tests/indexing/test_partial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexing/test_partial.py b/pandas/tests/indexing/test_partial.py index 315dfe1d8720c..eb349950fcfd0 100644 --- a/pandas/tests/indexing/test_partial.py +++ b/pandas/tests/indexing/test_partial.py @@ -696,7 +696,7 @@ def test_slice_datetime_index(self): {"col1": ["a", "b", "c"], "col2": [1, 2, 3]}, index=pd.to_datetime(["2020-08-01", "2020-07-02", "2020-08-05"]), ) - expected = pd.DataFrame( + expected = DataFrame( {"col1": ["a", "c"], "col2": [1, 3]}, index=pd.to_datetime(["2020-08-01", "2020-08-05"]), ) From 9cf919efb6d0ee7f1a9aed9740b49599f0e822bd Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Mon, 26 Oct 2020 12:55:36 +0000 Subject: [PATCH 15/17] Update pandas/tests/indexing/test_partial.py --- pandas/tests/indexing/test_partial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexing/test_partial.py b/pandas/tests/indexing/test_partial.py index eb349950fcfd0..e6271699a6d02 100644 --- a/pandas/tests/indexing/test_partial.py +++ b/pandas/tests/indexing/test_partial.py @@ -692,7 +692,7 @@ def test_slice_irregular_datetime_index_with_nan(self): def test_slice_datetime_index(self): # GH35509 - df = pd.DataFrame( + df = DataFrame( {"col1": ["a", "b", "c"], "col2": [1, 2, 3]}, index=pd.to_datetime(["2020-08-01", "2020-07-02", "2020-08-05"]), ) From 7f693dc455f72b0c3ac1281de53cc99f7eb4221b Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Mon, 26 Oct 2020 12:55:43 +0000 Subject: [PATCH 16/17] Update pandas/tests/indexing/test_partial.py --- pandas/tests/indexing/test_partial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexing/test_partial.py b/pandas/tests/indexing/test_partial.py index e6271699a6d02..9ac7707dede3d 100644 --- a/pandas/tests/indexing/test_partial.py +++ b/pandas/tests/indexing/test_partial.py @@ -686,7 +686,7 @@ def test_slice_irregular_datetime_index_with_nan(self): # GH36953 index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03", None]) df = pd.DataFrame(range(len(index)), index=index) - expected = pd.DataFrame(range(len(index[:3])), index=index[:3]) + expected = DataFrame(range(len(index[:3])), index=index[:3]) result = df["2012-01-01":"2012-01-04"] tm.assert_frame_equal(result, expected) From 02ae223eb204ab5ca9a1854b212193381e935bce Mon Sep 17 00:00:00 2001 From: Marco Gorelli Date: Mon, 26 Oct 2020 12:55:49 +0000 Subject: [PATCH 17/17] Update pandas/tests/indexing/test_partial.py --- pandas/tests/indexing/test_partial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/indexing/test_partial.py b/pandas/tests/indexing/test_partial.py index 9ac7707dede3d..80b7947eb5239 100644 --- a/pandas/tests/indexing/test_partial.py +++ b/pandas/tests/indexing/test_partial.py @@ -685,7 +685,7 @@ def test_index_name_empty(self): def test_slice_irregular_datetime_index_with_nan(self): # GH36953 index = pd.to_datetime(["2012-01-01", "2012-01-02", "2012-01-03", None]) - df = pd.DataFrame(range(len(index)), index=index) + df = DataFrame(range(len(index)), index=index) expected = DataFrame(range(len(index[:3])), index=index[:3]) result = df["2012-01-01":"2012-01-04"] tm.assert_frame_equal(result, expected)