From 6182afd39eca0be4e51f00021fffb09b2940c21e Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Thu, 26 Aug 2021 19:38:18 +0530 Subject: [PATCH 01/20] Resolving Index Resetting for tz_localize --- pandas/core/indexes/accessors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 017f58bff03e9..f0036cde13753 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -492,6 +492,7 @@ def __new__(cls, data: Series): name=orig.name, copy=False, dtype=orig._values.categories.dtype, + index=orig.index ) if is_datetime64_dtype(data.dtype): From 056dd9c8b6ad8678eac2220ca4696488f4a45a29 Mon Sep 17 00:00:00 2001 From: Prerana Chakraborty <40196782+kurchi1205@users.noreply.github.com> Date: Thu, 26 Aug 2021 21:23:22 +0530 Subject: [PATCH 02/20] Update test_tz_localize.py Adding a test case --- .../tests/series/methods/test_tz_localize.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 4d7f26076e060..d56560ed5da37 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -1,6 +1,6 @@ import pytest import pytz - +import itertools from pandas._libs.tslibs import timezones from pandas import ( @@ -9,6 +9,8 @@ Series, Timestamp, date_range, + CategoricalDtype, + DataFrame ) import pandas._testing as tm @@ -41,6 +43,20 @@ def test_series_tz_localize_ambiguous_bool(self): result = ser.dt.tz_localize("US/Central", ambiguous=[False]) tm.assert_series_equal(result, expected1) + def test_series_tz_localize_matching_index(self): + #Matching the index of the result with that of the original series + ts_list = date_range(start='2021-01-01T02:00:00', periods=3, freq='1D').to_list() + tz_list = date_range(start='2021-01-01T02:00:00', periods=3, freq='1D',tz='Europe/Berlin').to_list() + df = DataFrame(data=list(itertools.islice(itertools.cycle(ts_list), 9)), + index=[2, 4, 5, 6, 7, 8, 11, 14, 15], + columns=['pure_datetime']) + df['categorical_datetime'] = df['pure_datetime'].astype(CategoricalDtype()) + ser = df['categorical_datetime'] + expected = Series(data=list(itertools.islice(itertools.cycle(tz_list), 9)), + index=[2, 4, 5, 6, 7, 8, 11, 14, 15],name='categorical_datetime') + result = ser.dt.tz_localize('Europe/Berlin') + tm.assert_series_equal(result, expected) + @pytest.mark.parametrize("tz", ["Europe/Warsaw", "dateutil/Europe/Warsaw"]) @pytest.mark.parametrize( "method, exp", From f0ac5ce39dad8e6042dc6aad7213cad895b2a6b6 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Fri, 27 Aug 2021 10:52:00 +0530 Subject: [PATCH 03/20] Solving PEP-8 Issues --- pandas/core/indexes/accessors.py | 2 +- .../tests/series/methods/test_tz_localize.py | 41 ++++++++++++------- 2 files changed, 27 insertions(+), 16 deletions(-) diff --git a/pandas/core/indexes/accessors.py b/pandas/core/indexes/accessors.py index 4c9f56f10b4ff..b8f4b5f9d3423 100644 --- a/pandas/core/indexes/accessors.py +++ b/pandas/core/indexes/accessors.py @@ -492,7 +492,7 @@ def __new__(cls, data: Series): name=orig.name, copy=False, dtype=orig._values.categories.dtype, - index=orig.index + index=orig.index, ) if is_datetime64_dtype(data.dtype): diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index d56560ed5da37..3f1333bc36cc2 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -1,16 +1,18 @@ +import itertools + import pytest import pytz -import itertools + from pandas._libs.tslibs import timezones from pandas import ( + CategoricalDtype, + DataFrame, DatetimeIndex, NaT, Series, Timestamp, date_range, - CategoricalDtype, - DataFrame ) import pandas._testing as tm @@ -44,19 +46,28 @@ def test_series_tz_localize_ambiguous_bool(self): tm.assert_series_equal(result, expected1) def test_series_tz_localize_matching_index(self): - #Matching the index of the result with that of the original series - ts_list = date_range(start='2021-01-01T02:00:00', periods=3, freq='1D').to_list() - tz_list = date_range(start='2021-01-01T02:00:00', periods=3, freq='1D',tz='Europe/Berlin').to_list() - df = DataFrame(data=list(itertools.islice(itertools.cycle(ts_list), 9)), - index=[2, 4, 5, 6, 7, 8, 11, 14, 15], - columns=['pure_datetime']) - df['categorical_datetime'] = df['pure_datetime'].astype(CategoricalDtype()) - ser = df['categorical_datetime'] - expected = Series(data=list(itertools.islice(itertools.cycle(tz_list), 9)), - index=[2, 4, 5, 6, 7, 8, 11, 14, 15],name='categorical_datetime') - result = ser.dt.tz_localize('Europe/Berlin') + # Matching the index of the result with that of the original series + ts_list = date_range( + start="2021-01-01T02:00:00", periods=3, freq="1D" + ).to_list() + tz_list = date_range( + start="2021-01-01T02:00:00", periods=3, freq="1D", tz="Europe/Berlin" + ).to_list() + df = DataFrame( + data=list(itertools.islice(itertools.cycle(ts_list), 9)), + index=[2, 4, 5, 6, 7, 8, 11, 14, 15], + columns=["pure_datetime"], + ) + df["categorical_datetime"] = df["pure_datetime"].astype(CategoricalDtype()) + ser = df["categorical_datetime"] + expected = Series( + data=list(itertools.islice(itertools.cycle(tz_list), 9)), + index=[2, 4, 5, 6, 7, 8, 11, 14, 15], + name="categorical_datetime", + ) + result = ser.dt.tz_localize("Europe/Berlin") tm.assert_series_equal(result, expected) - + @pytest.mark.parametrize("tz", ["Europe/Warsaw", "dateutil/Europe/Warsaw"]) @pytest.mark.parametrize( "method, exp", From 9e8ef7fad3c8703b915146b601786868068838c2 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Fri, 27 Aug 2021 22:50:42 +0530 Subject: [PATCH 04/20] Changing Test Case and updating whatsnew --- doc/source/whatsnew/v1.3.3.rst | 2 +- .../tests/series/methods/test_tz_localize.py | 27 +++++-------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 1340188c3d609..c655ac5e929ed 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,7 +25,7 @@ Fixed regressions Bug fixes ~~~~~~~~~ -- +- Fixed bug in :meth:`__new__` of :class:`CombinedDatetimelikeProperties` maintains index of Categorical Datetime series (:issue:`43080`) - .. --------------------------------------------------------------------------- diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 3f1333bc36cc2..7e85521b97145 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -1,4 +1,4 @@ -import itertools + import pytest import pytz @@ -7,7 +7,6 @@ from pandas import ( CategoricalDtype, - DataFrame, DatetimeIndex, NaT, Series, @@ -47,25 +46,11 @@ def test_series_tz_localize_ambiguous_bool(self): def test_series_tz_localize_matching_index(self): # Matching the index of the result with that of the original series - ts_list = date_range( - start="2021-01-01T02:00:00", periods=3, freq="1D" - ).to_list() - tz_list = date_range( - start="2021-01-01T02:00:00", periods=3, freq="1D", tz="Europe/Berlin" - ).to_list() - df = DataFrame( - data=list(itertools.islice(itertools.cycle(ts_list), 9)), - index=[2, 4, 5, 6, 7, 8, 11, 14, 15], - columns=["pure_datetime"], - ) - df["categorical_datetime"] = df["pure_datetime"].astype(CategoricalDtype()) - ser = df["categorical_datetime"] - expected = Series( - data=list(itertools.islice(itertools.cycle(tz_list), 9)), - index=[2, 4, 5, 6, 7, 8, 11, 14, 15], - name="categorical_datetime", - ) - result = ser.dt.tz_localize("Europe/Berlin") + # GH 43080 + dt_series = Series(date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"),index=[2, 6, 7, 8, 11]) + cat_series = dt_series.astype(CategoricalDtype()) + result = cat_series.dt.tz_localize('Europe/Berlin') + expected = Series(date_range(start="2021-01-01T02:00:00", periods=5, freq="1D",tz='Europe/Berlin'),index=[2, 6, 7, 8, 11]) tm.assert_series_equal(result, expected) @pytest.mark.parametrize("tz", ["Europe/Warsaw", "dateutil/Europe/Warsaw"]) From b96fb98c03524ab72cead494f8e879b84c9fb9cd Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Fri, 27 Aug 2021 23:01:50 +0530 Subject: [PATCH 05/20] Changing Test Case and updating whatsnew --- pandas/tests/series/methods/test_tz_localize.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 7e85521b97145..70e6f1d2cd0fb 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -1,5 +1,3 @@ - - import pytest import pytz @@ -47,10 +45,18 @@ def test_series_tz_localize_ambiguous_bool(self): def test_series_tz_localize_matching_index(self): # Matching the index of the result with that of the original series # GH 43080 - dt_series = Series(date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"),index=[2, 6, 7, 8, 11]) + dt_series = Series( + date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"), + index=[2, 6, 7, 8, 11], + ) cat_series = dt_series.astype(CategoricalDtype()) - result = cat_series.dt.tz_localize('Europe/Berlin') - expected = Series(date_range(start="2021-01-01T02:00:00", periods=5, freq="1D",tz='Europe/Berlin'),index=[2, 6, 7, 8, 11]) + result = cat_series.dt.tz_localize("Europe/Berlin") + expected = Series( + date_range( + start="2021-01-01T02:00:00", periods=5, freq="1D", tz="Europe/Berlin" + ), + index=[2, 6, 7, 8, 11], + ) tm.assert_series_equal(result, expected) @pytest.mark.parametrize("tz", ["Europe/Warsaw", "dateutil/Europe/Warsaw"]) From 5820ceeae405be9d7e28017cd477ea7a5675ca7a Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Sat, 28 Aug 2021 00:10:01 +0530 Subject: [PATCH 06/20] updating whatsnew --- doc/source/whatsnew/v1.3.3.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index c655ac5e929ed..d81a3980dc2dc 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,8 +25,8 @@ Fixed regressions Bug fixes ~~~~~~~~~ -- Fixed bug in :meth:`__new__` of :class:`CombinedDatetimelikeProperties` maintains index of Categorical Datetime series (:issue:`43080`) -- + +- Fixed bug in :func:`__new__` of :class:`CombinedDatetimelikeProperties` maintains index of Categorical Datetime series (:issue:`43080`) .. --------------------------------------------------------------------------- From 3308de4a1b901472df03904ae68df2f4564430a0 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Sat, 28 Aug 2021 00:22:24 +0530 Subject: [PATCH 07/20] updating whatsnew --- doc/source/whatsnew/v1.3.3.rst | 5 ----- 1 file changed, 5 deletions(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 1483e63063cd6..5af91994dc4ed 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,13 +25,8 @@ Fixed regressions Bug fixes ~~~~~~~~~ -<<<<<<< HEAD - Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with engine="numba" where index data was not being correctly passed into func (:issue:`43133`) - Fixed bug in :func:`__new__` of :class:`CombinedDatetimelikeProperties` maintains index of Categorical Datetime series (:issue:`43080`) -======= -- Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with ``engine="numba"`` where ``index`` data was not being correctly passed into ``func`` (:issue:`43133`) -- ->>>>>>> b9e90dc8acf003588678196e7dc8294114918bb2 .. --------------------------------------------------------------------------- From b1afd7bcfdd8f414109ed709c15cefec969ad8d7 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Sat, 28 Aug 2021 11:06:24 +0530 Subject: [PATCH 08/20] updating whatsnew --- doc/source/whatsnew/v1.3.3.rst | 4 ++-- doc/source/whatsnew/v1.4.0.rst | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/source/whatsnew/v1.3.3.rst b/doc/source/whatsnew/v1.3.3.rst index 5af91994dc4ed..3dee3aa5e7c7a 100644 --- a/doc/source/whatsnew/v1.3.3.rst +++ b/doc/source/whatsnew/v1.3.3.rst @@ -25,8 +25,8 @@ Fixed regressions Bug fixes ~~~~~~~~~ -- Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with engine="numba" where index data was not being correctly passed into func (:issue:`43133`) -- Fixed bug in :func:`__new__` of :class:`CombinedDatetimelikeProperties` maintains index of Categorical Datetime series (:issue:`43080`) +- Bug in :meth:`.DataFrameGroupBy.agg` and :meth:`.DataFrameGroupBy.transform` with ``engine="numba"`` where ``index`` data was not being correctly passed into ``func`` (:issue:`43133`) +- .. --------------------------------------------------------------------------- diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index fc488504f1fdf..adcf50a11f12b 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -310,7 +310,7 @@ Indexing - Bug in :meth:`Index.get_indexer_non_unique` when index contains multiple ``np.nan`` (:issue:`35392`) - Bug in :meth:`DataFrame.query` did not handle the degree sign in a backticked column name, such as \`Temp(°C)\`, used in an expression to query a dataframe (:issue:`42826`) - Bug in :meth:`DataFrame.drop` where the error message did not show missing labels with commas when raising ``KeyError`` (:issue:`42881`) -- +- Bug in :meth:`dt.tz_convert` resetting index in a :class:`Series` with :class:`CategoricalIndex` (:issue:`43080`) Missing ^^^^^^^ From 8f728485ebaa1a9d04ac9ae2e57ca520ff55f924 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Mon, 30 Aug 2021 17:31:46 +0530 Subject: [PATCH 09/20] Making the necessary changes --- doc/source/whatsnew/v1.4.0.rst | 4 ++-- pandas/tests/series/methods/test_tz_localize.py | 5 ++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index fe0735562c99a..47a88638e408a 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -276,7 +276,7 @@ Timedelta Timezones ^^^^^^^^^ -- +- Bug in :meth:`dt.tz_convert` resetting index in a :class:`Series` with :class:`CategoricalIndex` (:issue:`43080`) - Numeric @@ -313,7 +313,7 @@ Indexing - Bug in :meth:`Index.get_indexer_non_unique` when index contains multiple ``np.nan`` (:issue:`35392`) - Bug in :meth:`DataFrame.query` did not handle the degree sign in a backticked column name, such as \`Temp(°C)\`, used in an expression to query a dataframe (:issue:`42826`) - Bug in :meth:`DataFrame.drop` where the error message did not show missing labels with commas when raising ``KeyError`` (:issue:`42881`) -- Bug in :meth:`dt.tz_convert` resetting index in a :class:`Series` with :class:`CategoricalIndex` (:issue:`43080`) + Missing ^^^^^^^ diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 70e6f1d2cd0fb..0d7ec106e185e 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -47,10 +47,9 @@ def test_series_tz_localize_matching_index(self): # GH 43080 dt_series = Series( date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"), - index=[2, 6, 7, 8, 11], + index=[2, 6, 7, 8, 11], astype ="category" ) - cat_series = dt_series.astype(CategoricalDtype()) - result = cat_series.dt.tz_localize("Europe/Berlin") + result = dt_series.dt.tz_localize("Europe/Berlin") expected = Series( date_range( start="2021-01-01T02:00:00", periods=5, freq="1D", tz="Europe/Berlin" From d39865fc5ba58dbebb18697c93663b9f49a82702 Mon Sep 17 00:00:00 2001 From: Prerana Chakraborty <40196782+kurchi1205@users.noreply.github.com> Date: Mon, 30 Aug 2021 17:39:14 +0530 Subject: [PATCH 10/20] Update test_tz_localize.py --- pandas/tests/series/methods/test_tz_localize.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 0d7ec106e185e..4413bb9f41a98 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -4,7 +4,6 @@ from pandas._libs.tslibs import timezones from pandas import ( - CategoricalDtype, DatetimeIndex, NaT, Series, From 48b296f1875e110d48c6ac531c078d533234d5d0 Mon Sep 17 00:00:00 2001 From: Prerana Chakraborty <40196782+kurchi1205@users.noreply.github.com> Date: Mon, 30 Aug 2021 17:45:23 +0530 Subject: [PATCH 11/20] Update test_tz_localize.py --- pandas/tests/series/methods/test_tz_localize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 4413bb9f41a98..c707dc76d634a 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -46,7 +46,7 @@ def test_series_tz_localize_matching_index(self): # GH 43080 dt_series = Series( date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"), - index=[2, 6, 7, 8, 11], astype ="category" + index=[2, 6, 7, 8, 11], astype="category" ) result = dt_series.dt.tz_localize("Europe/Berlin") expected = Series( From 4645289a6b25b66d8e759ba816e21d1a705ea754 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Mon, 30 Aug 2021 17:51:21 +0530 Subject: [PATCH 12/20] Changes made --- pandas/tests/series/methods/test_tz_localize.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 0d7ec106e185e..a0c920370c88e 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -4,7 +4,6 @@ from pandas._libs.tslibs import timezones from pandas import ( - CategoricalDtype, DatetimeIndex, NaT, Series, @@ -47,7 +46,8 @@ def test_series_tz_localize_matching_index(self): # GH 43080 dt_series = Series( date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"), - index=[2, 6, 7, 8, 11], astype ="category" + index=[2, 6, 7, 8, 11], + astype="category", ) result = dt_series.dt.tz_localize("Europe/Berlin") expected = Series( From 444372a3285ccf9c18ef40b4f83a0ee3342cc3f5 Mon Sep 17 00:00:00 2001 From: Prerana Chakraborty <40196782+kurchi1205@users.noreply.github.com> Date: Mon, 30 Aug 2021 18:18:03 +0530 Subject: [PATCH 13/20] Update test_tz_localize.py --- pandas/tests/series/methods/test_tz_localize.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index c707dc76d634a..487f1a26a686a 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -46,7 +46,7 @@ def test_series_tz_localize_matching_index(self): # GH 43080 dt_series = Series( date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"), - index=[2, 6, 7, 8, 11], astype="category" + index=[2, 6, 7, 8, 11], dtype="category" ) result = dt_series.dt.tz_localize("Europe/Berlin") expected = Series( From 10a3cdaf586c1253c28dae3582f752713e0e2b65 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Mon, 30 Aug 2021 19:34:59 +0530 Subject: [PATCH 14/20] Commiting Again --- pandas/tests/series/methods/test_tz_localize.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pandas/tests/series/methods/test_tz_localize.py b/pandas/tests/series/methods/test_tz_localize.py index 894cf140b43bc..a32c1fb8df502 100644 --- a/pandas/tests/series/methods/test_tz_localize.py +++ b/pandas/tests/series/methods/test_tz_localize.py @@ -46,12 +46,8 @@ def test_series_tz_localize_matching_index(self): # GH 43080 dt_series = Series( date_range(start="2021-01-01T02:00:00", periods=5, freq="1D"), -<<<<<<< HEAD index=[2, 6, 7, 8, 11], - astype="category", -======= - index=[2, 6, 7, 8, 11], dtype="category" ->>>>>>> 444372a3285ccf9c18ef40b4f83a0ee3342cc3f5 + dtype="category", ) result = dt_series.dt.tz_localize("Europe/Berlin") expected = Series( From 9101359696d5e49274c076985066d3247cd4ae6a Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Wed, 1 Sep 2021 10:32:18 +0530 Subject: [PATCH 15/20] Change in whatsnew --- doc/source/whatsnew/v1.4.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 47a88638e408a..d066791a743ae 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -276,7 +276,7 @@ Timedelta Timezones ^^^^^^^^^ -- Bug in :meth:`dt.tz_convert` resetting index in a :class:`Series` with :class:`CategoricalIndex` (:issue:`43080`) +- Bug in :meth:`Series.dt.tz_convert` resetting index in a :class:`Series` with :class:`CategoricalIndex` (:issue:`43080`) - Numeric From 2966209a1df538430088264fdb1f807d7bd0b31c Mon Sep 17 00:00:00 2001 From: Prerana Chakraborty <40196782+kurchi1205@users.noreply.github.com> Date: Wed, 1 Sep 2021 14:55:30 +0530 Subject: [PATCH 16/20] Update v1.4.0.rst Committing again with no changes to solve timeout error --- doc/source/whatsnew/v1.4.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index d066791a743ae..460d2b7f86b98 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -313,6 +313,7 @@ Indexing - Bug in :meth:`Index.get_indexer_non_unique` when index contains multiple ``np.nan`` (:issue:`35392`) - Bug in :meth:`DataFrame.query` did not handle the degree sign in a backticked column name, such as \`Temp(°C)\`, used in an expression to query a dataframe (:issue:`42826`) - Bug in :meth:`DataFrame.drop` where the error message did not show missing labels with commas when raising ``KeyError`` (:issue:`42881`) +- Missing From d57c7d3db93157cc4dedfba3eb1afbf322a5c14a Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Wed, 1 Sep 2021 23:17:22 +0530 Subject: [PATCH 17/20] Pre-commiting --- doc/source/whatsnew/v1.4.0.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index d066791a743ae..d2683ebf4694a 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -313,6 +313,7 @@ Indexing - Bug in :meth:`Index.get_indexer_non_unique` when index contains multiple ``np.nan`` (:issue:`35392`) - Bug in :meth:`DataFrame.query` did not handle the degree sign in a backticked column name, such as \`Temp(°C)\`, used in an expression to query a dataframe (:issue:`42826`) - Bug in :meth:`DataFrame.drop` where the error message did not show missing labels with commas when raising ``KeyError`` (:issue:`42881`) +- Missing From 374c4765c7ea945aa6edbcd2cc9f6ec4ef910e14 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Wed, 1 Sep 2021 23:32:54 +0530 Subject: [PATCH 18/20] Pre-commiting --- doc/source/whatsnew/v1.4.0.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/whatsnew/v1.4.0.rst b/doc/source/whatsnew/v1.4.0.rst index 460d2b7f86b98..d2683ebf4694a 100644 --- a/doc/source/whatsnew/v1.4.0.rst +++ b/doc/source/whatsnew/v1.4.0.rst @@ -313,7 +313,7 @@ Indexing - Bug in :meth:`Index.get_indexer_non_unique` when index contains multiple ``np.nan`` (:issue:`35392`) - Bug in :meth:`DataFrame.query` did not handle the degree sign in a backticked column name, such as \`Temp(°C)\`, used in an expression to query a dataframe (:issue:`42826`) - Bug in :meth:`DataFrame.drop` where the error message did not show missing labels with commas when raising ``KeyError`` (:issue:`42881`) -- +- Missing From 0f02afa9a106edaadff56906eec524d7c71e2cd3 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Fri, 3 Sep 2021 12:00:35 +0530 Subject: [PATCH 19/20] New Test Case --- pandas/tests/series/accessors/test_dt_accessor.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pandas/tests/series/accessors/test_dt_accessor.py b/pandas/tests/series/accessors/test_dt_accessor.py index 61a22dad5d09b..0654327fa6a3e 100644 --- a/pandas/tests/series/accessors/test_dt_accessor.py +++ b/pandas/tests/series/accessors/test_dt_accessor.py @@ -691,6 +691,19 @@ def test_isocalendar(self, input_series, expected_output): ) tm.assert_frame_equal(result, expected_frame) + def test_hour_index(self): + dt_series = Series( + date_range(start="2021-01-01", periods=5, freq="h"), + index=[2, 6, 7, 8, 11], + dtype="category", + ) + result = dt_series.dt.hour + expected = Series( + [0, 1, 2, 3, 4], + index=[2, 6, 7, 8, 11], + ) + tm.assert_frame_equal(result, expected) + class TestSeriesPeriodValuesDtAccessor: @pytest.mark.parametrize( From ed380c94cc704821ec2c2d7ee53d1fd3676a7a21 Mon Sep 17 00:00:00 2001 From: Zerobugs_DesignLab Date: Fri, 3 Sep 2021 13:07:51 +0530 Subject: [PATCH 20/20] Test Case Modified --- pandas/tests/series/accessors/test_dt_accessor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/series/accessors/test_dt_accessor.py b/pandas/tests/series/accessors/test_dt_accessor.py index 0654327fa6a3e..eb7e1d4268605 100644 --- a/pandas/tests/series/accessors/test_dt_accessor.py +++ b/pandas/tests/series/accessors/test_dt_accessor.py @@ -702,7 +702,7 @@ def test_hour_index(self): [0, 1, 2, 3, 4], index=[2, 6, 7, 8, 11], ) - tm.assert_frame_equal(result, expected) + tm.assert_series_equal(result, expected) class TestSeriesPeriodValuesDtAccessor: