From 730ed790d720bf5184ae29021deef58ea41e179f Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 21 Jan 2020 17:04:08 -0800 Subject: [PATCH 1/9] Initial fixturization --- pandas/conftest.py | 9 +++++++ pandas/tests/io/json/test_pandas.py | 41 ++++++++++++----------------- pandas/tests/series/conftest.py | 10 ------- 3 files changed, 26 insertions(+), 34 deletions(-) diff --git a/pandas/conftest.py b/pandas/conftest.py index 0c964452df5da..2eb7589d66c02 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -867,6 +867,15 @@ def tick_classes(request): ), ) +@pytest.fixture +def datetime_series(): + """ + Fixture for Series of floats with DatetimeIndex + """ + s = tm.makeTimeSeries() + s.name = "ts" + return s + @pytest.fixture def float_frame(): diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index bb873c71e8a35..8881ba978ef9b 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -42,12 +42,9 @@ def assert_json_roundtrip_equal(result, expected, orient): @pytest.mark.filterwarnings("ignore:the 'numpy' keyword is deprecated:FutureWarning") class TestPandasContainer: - @pytest.fixture(scope="function", autouse=True) - def setup(self, datapath): - self.dirpath = datapath("io", "json", "data") - - self.ts = tm.makeTimeSeries() - self.ts.name = "ts" + @pytest.fixture(autouse=True) + def setup(self, datapath, monkeypatch): + monkeypatch.chdir(datapath("io", "json", "data")) self.series = tm.makeStringSeries() self.series.name = "series" @@ -67,10 +64,6 @@ def setup(self, datapath): yield - del self.dirpath - - del self.ts - del self.series del self.objSeries @@ -474,12 +467,12 @@ def test_v12_compat(self): df["modified"] = df["date"] df.iloc[1, df.columns.get_loc("modified")] = pd.NaT - v12_json = os.path.join(self.dirpath, "tsframe_v012.json") + v12_json = os.path.join("tsframe_v012.json") df_unser = pd.read_json(v12_json) tm.assert_frame_equal(df, df_unser) df_iso = df.drop(["modified"], axis=1) - v12_iso_json = os.path.join(self.dirpath, "tsframe_iso_v012.json") + v12_iso_json = os.path.join("tsframe_iso_v012.json") df_unser_iso = pd.read_json(v12_iso_json) tm.assert_frame_equal(df_iso, df_unser_iso) @@ -681,10 +674,10 @@ def test_series_roundtrip_empty(self, orient, numpy): tm.assert_series_equal(result, expected) @pytest.mark.parametrize("numpy", [True, False]) - def test_series_roundtrip_timeseries(self, orient, numpy): - data = self.ts.to_json(orient=orient) + def test_series_roundtrip_timeseries(self, orient, numpy, datetime_series): + data = datetime_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) - expected = self.ts.copy() + expected = datetime_series.copy() if orient in ("values", "records"): expected = expected.reset_index(drop=True) @@ -773,7 +766,7 @@ def test_path(self): df.to_json(path) read_json(path) - def test_axis_dates(self): + def test_axis_dates(self, datetime_series): # frame json = self.tsframe.to_json() @@ -781,12 +774,12 @@ def test_axis_dates(self): tm.assert_frame_equal(result, self.tsframe) # series - json = self.ts.to_json() + json = datetime_series.to_json() result = read_json(json, typ="series") - tm.assert_series_equal(result, self.ts, check_names=False) + tm.assert_series_equal(result, datetime_series, check_names=False) assert result.name is None - def test_convert_dates(self): + def test_convert_dates(self, datetime_series): # frame df = self.tsframe.copy() @@ -806,7 +799,7 @@ def test_convert_dates(self): tm.assert_frame_equal(result, expected) # series - ts = Series(Timestamp("20130101"), index=self.ts.index) + ts = Series(Timestamp("20130101"), index=datetime_series.index) json = ts.to_json() result = read_json(json, typ="series") tm.assert_series_equal(result, ts) @@ -901,8 +894,8 @@ def test_date_format_frame_raises(self): ("20130101 20:43:42.123456789", "ns"), ], ) - def test_date_format_series(self, date, date_unit): - ts = Series(Timestamp(date), index=self.ts.index) + def test_date_format_series(self, date, date_unit, datetime_series): + ts = Series(Timestamp(date), index=datetime_series.index) ts.iloc[1] = pd.NaT ts.iloc[5] = pd.NaT if date_unit: @@ -915,8 +908,8 @@ def test_date_format_series(self, date, date_unit): expected = expected.dt.tz_localize("UTC") tm.assert_series_equal(result, expected) - def test_date_format_series_raises(self): - ts = Series(Timestamp("20130101 20:43:42.123"), index=self.ts.index) + def test_date_format_series_raises(self, datetime_series): + ts = Series(Timestamp("20130101 20:43:42.123"), index=datetime_series.index) msg = "Invalid value 'foo' for option 'date_unit'" with pytest.raises(ValueError, match=msg): ts.to_json(date_format="iso", date_unit="foo") diff --git a/pandas/tests/series/conftest.py b/pandas/tests/series/conftest.py index ff0b0c71f88b0..87aefec559311 100644 --- a/pandas/tests/series/conftest.py +++ b/pandas/tests/series/conftest.py @@ -3,16 +3,6 @@ import pandas._testing as tm -@pytest.fixture -def datetime_series(): - """ - Fixture for Series of floats with DatetimeIndex - """ - s = tm.makeTimeSeries() - s.name = "ts" - return s - - @pytest.fixture def string_series(): """ From 1a96b4f80b7ef8e4a7f854377a8df1affb0cdab5 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 21 Jan 2020 17:10:04 -0800 Subject: [PATCH 2/9] parametrized series objects --- pandas/conftest.py | 25 +++++++++++++++++++++ pandas/tests/io/json/test_pandas.py | 34 ++++++++++------------------- pandas/tests/resample/conftest.py | 2 +- pandas/tests/resample/test_base.py | 24 ++++++++++---------- pandas/tests/series/conftest.py | 23 ------------------- 5 files changed, 49 insertions(+), 59 deletions(-) delete mode 100644 pandas/tests/series/conftest.py diff --git a/pandas/conftest.py b/pandas/conftest.py index 2eb7589d66c02..b3937441e433f 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -867,6 +867,12 @@ def tick_classes(request): ), ) + +@pytest.fixture +def empty_series(): + return pd.Series([], index=[], dtype=np.float64) + + @pytest.fixture def datetime_series(): """ @@ -876,6 +882,25 @@ def datetime_series(): s.name = "ts" return s +@pytest.fixture +def string_series(): + """ + Fixture for Series of floats with Index of unique strings + """ + s = tm.makeStringSeries() + s.name = "series" + return s + + +@pytest.fixture +def object_series(): + """ + Fixture for Series of dtype object with Index of unique strings + """ + s = tm.makeObjectSeries() + s.name = "objects" + return s + @pytest.fixture def float_frame(): diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 8881ba978ef9b..502e79e9b487e 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -46,13 +46,6 @@ class TestPandasContainer: def setup(self, datapath, monkeypatch): monkeypatch.chdir(datapath("io", "json", "data")) - self.series = tm.makeStringSeries() - self.series.name = "series" - - self.objSeries = tm.makeObjectSeries() - self.objSeries.name = "objects" - - self.empty_series = Series([], index=[], dtype=np.float64) self.empty_frame = DataFrame() self.frame = _frame.copy() @@ -64,11 +57,6 @@ def setup(self, datapath, monkeypatch): yield - del self.series - - del self.objSeries - - del self.empty_series del self.empty_frame del self.frame @@ -627,14 +615,14 @@ def test_series_non_unique_index(self): unser = read_json(s.to_json(orient="records"), orient="records", typ="series") tm.assert_numpy_array_equal(s.values, unser.values) - def test_series_default_orient(self): - assert self.series.to_json() == self.series.to_json(orient="index") + def test_series_default_orient(self, string_series): + assert string_series.to_json() == string_series.to_json(orient="index") @pytest.mark.parametrize("numpy", [True, False]) - def test_series_roundtrip_simple(self, orient, numpy): - data = self.series.to_json(orient=orient) + def test_series_roundtrip_simple(self, orient, numpy, string_series): + data = string_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) - expected = self.series.copy() + expected = string_series.copy() if orient in ("values", "records"): expected = expected.reset_index(drop=True) @@ -645,12 +633,12 @@ def test_series_roundtrip_simple(self, orient, numpy): @pytest.mark.parametrize("dtype", [False, None]) @pytest.mark.parametrize("numpy", [True, False]) - def test_series_roundtrip_object(self, orient, numpy, dtype): - data = self.objSeries.to_json(orient=orient) + def test_series_roundtrip_object(self, orient, numpy, dtype, object_series): + data = object_series.to_json(orient=orient) result = pd.read_json( data, typ="series", orient=orient, numpy=numpy, dtype=dtype ) - expected = self.objSeries.copy() + expected = object_series.copy() if orient in ("values", "records"): expected = expected.reset_index(drop=True) @@ -660,10 +648,10 @@ def test_series_roundtrip_object(self, orient, numpy, dtype): tm.assert_series_equal(result, expected) @pytest.mark.parametrize("numpy", [True, False]) - def test_series_roundtrip_empty(self, orient, numpy): - data = self.empty_series.to_json(orient=orient) + def test_series_roundtrip_empty(self, orient, numpy, empty_series): + data = empty_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) - expected = self.empty_series.copy() + expected = empty_series.copy() # TODO: see what causes inconsistency if orient in ("values", "records"): diff --git a/pandas/tests/resample/conftest.py b/pandas/tests/resample/conftest.py index bb4f7ced3350f..dde67f6786635 100644 --- a/pandas/tests/resample/conftest.py +++ b/pandas/tests/resample/conftest.py @@ -126,7 +126,7 @@ def series(index, _series_name, _static_values): @pytest.fixture -def empty_series(series): +def empty_series_dti(series): """Fixture for parametrization of empty Series with date_range, period_range and timedelta_range indexes""" return series[:0] diff --git a/pandas/tests/resample/test_base.py b/pandas/tests/resample/test_base.py index f8a1810e66219..805a48f50281b 100644 --- a/pandas/tests/resample/test_base.py +++ b/pandas/tests/resample/test_base.py @@ -93,13 +93,13 @@ def test_raises_on_non_datetimelike_index(): @all_ts @pytest.mark.parametrize("freq", ["M", "D", "H"]) -def test_resample_empty_series(freq, empty_series, resample_method): +def test_resample_empty_series(freq, empty_series_dti, resample_method): # GH12771 & GH12868 if resample_method == "ohlc": pytest.skip("need to test for ohlc from GH13083") - s = empty_series + s = empty_series_dti result = getattr(s.resample(freq), resample_method)() expected = s.copy() @@ -115,15 +115,15 @@ def test_resample_empty_series(freq, empty_series, resample_method): @all_ts @pytest.mark.parametrize("freq", ["M", "D", "H"]) @pytest.mark.parametrize("resample_method", ["count", "size"]) -def test_resample_count_empty_series(freq, empty_series, resample_method): +def test_resample_count_empty_series(freq, empty_series_dti, resample_method): # GH28427 - result = getattr(empty_series.resample(freq), resample_method)() + result = getattr(empty_series_dti.resample(freq), resample_method)() - if isinstance(empty_series.index, PeriodIndex): - index = empty_series.index.asfreq(freq=freq) + if isinstance(empty_series_dti.index, PeriodIndex): + index = empty_series_dti.index.asfreq(freq=freq) else: - index = empty_series.index._shallow_copy(freq=freq) - expected = pd.Series([], dtype="int64", index=index, name=empty_series.name) + index = empty_series_dti.index._shallow_copy(freq=freq) + expected = pd.Series([], dtype="int64", index=index, name=empty_series_dti.name) tm.assert_series_equal(result, expected) @@ -197,9 +197,9 @@ def test_resample_empty_dtypes(index, dtype, resample_method): # Empty series were sometimes causing a segfault (for the functions # with Cython bounds-checking disabled) or an IndexError. We just run # them to ensure they no longer do. (GH #10228) - empty_series = Series([], index, dtype) + empty_series_dti = Series([], index, dtype) try: - getattr(empty_series.resample("d"), resample_method)() + getattr(empty_series_dti.resample("d"), resample_method)() except DataError: # Ignore these since some combinations are invalid # (ex: doing mean with dtype of np.object) @@ -236,9 +236,9 @@ def test_resample_loffset_arg_type(frame, create_index, arg): @all_ts -def test_apply_to_empty_series(empty_series): +def test_apply_to_empty_series(empty_series_dti): # GH 14313 - s = empty_series + s = empty_series_dti for freq in ["M", "D", "H"]: result = s.resample(freq).apply(lambda x: 1) expected = s.resample(freq).apply(np.sum) diff --git a/pandas/tests/series/conftest.py b/pandas/tests/series/conftest.py deleted file mode 100644 index 87aefec559311..0000000000000 --- a/pandas/tests/series/conftest.py +++ /dev/null @@ -1,23 +0,0 @@ -import pytest - -import pandas._testing as tm - - -@pytest.fixture -def string_series(): - """ - Fixture for Series of floats with Index of unique strings - """ - s = tm.makeStringSeries() - s.name = "series" - return s - - -@pytest.fixture -def object_series(): - """ - Fixture for Series of dtype object with Index of unique strings - """ - s = tm.makeObjectSeries() - s.name = "objects" - return s From dfebc6b61b64217a9315ed9f7227bdccba00cb73 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 21 Jan 2020 17:11:58 -0800 Subject: [PATCH 3/9] Black --- pandas/conftest.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pandas/conftest.py b/pandas/conftest.py index b3937441e433f..96dd97fb5b6c8 100644 --- a/pandas/conftest.py +++ b/pandas/conftest.py @@ -882,6 +882,7 @@ def datetime_series(): s.name = "ts" return s + @pytest.fixture def string_series(): """ From d507eb4fedf34a4a977fcf03abac415e96858665 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Thu, 6 Feb 2020 16:36:14 -0800 Subject: [PATCH 4/9] simonjayhawkins feedback --- pandas/tests/io/json/test_pandas.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 52c2c1e38487d..f5f91d2afaafe 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -455,13 +455,11 @@ def test_v12_compat(self): df["modified"] = df["date"] df.iloc[1, df.columns.get_loc("modified")] = pd.NaT - v12_json = os.path.join("tsframe_v012.json") - df_unser = pd.read_json(v12_json) + df_unser = pd.read_json("tsframe_v012.json") tm.assert_frame_equal(df, df_unser) df_iso = df.drop(["modified"], axis=1) - v12_iso_json = os.path.join("tsframe_iso_v012.json") - df_unser_iso = pd.read_json(v12_iso_json) + df_unser_iso = pd.read_json("tsframe_iso_v012.json") tm.assert_frame_equal(df_iso, df_unser_iso) def test_blocks_compat_GH9037(self): @@ -622,7 +620,6 @@ def test_series_default_orient(self, string_series): def test_series_roundtrip_simple(self, orient, numpy, string_series): data = string_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) - expected = string_series.copy() if orient in ("values", "records"): expected = expected.reset_index(drop=True) @@ -638,7 +635,6 @@ def test_series_roundtrip_object(self, orient, numpy, dtype, object_series): result = pd.read_json( data, typ="series", orient=orient, numpy=numpy, dtype=dtype ) - expected = object_series.copy() if orient in ("values", "records"): expected = expected.reset_index(drop=True) @@ -651,7 +647,6 @@ def test_series_roundtrip_object(self, orient, numpy, dtype, object_series): def test_series_roundtrip_empty(self, orient, numpy, empty_series): data = empty_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) - expected = empty_series.copy() # TODO: see what causes inconsistency if orient in ("values", "records"): @@ -665,7 +660,6 @@ def test_series_roundtrip_empty(self, orient, numpy, empty_series): def test_series_roundtrip_timeseries(self, orient, numpy, datetime_series): data = datetime_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) - expected = datetime_series.copy() if orient in ("values", "records"): expected = expected.reset_index(drop=True) From 00568247009b9530195a071427ad14e790e5ff16 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Tue, 11 Feb 2020 17:31:14 -0800 Subject: [PATCH 5/9] fix ci failures --- pandas/tests/io/json/test_pandas.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 7b219cf3cfbcf..29ecb402226f7 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -621,6 +621,7 @@ def test_series_roundtrip_simple(self, orient, numpy, string_series): data = string_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) + expected = string_series if orient in ("values", "records"): expected = expected.reset_index(drop=True) if orient != "split": @@ -636,6 +637,7 @@ def test_series_roundtrip_object(self, orient, numpy, dtype, object_series): data, typ="series", orient=orient, numpy=numpy, dtype=dtype ) + expected = object_series if orient in ("values", "records"): expected = expected.reset_index(drop=True) if orient != "split": @@ -648,7 +650,7 @@ def test_series_roundtrip_empty(self, orient, numpy, empty_series): data = empty_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) - # TODO: see what causes inconsistency + expected = empty_series if orient in ("values", "records"): expected = expected.reset_index(drop=True) else: @@ -661,6 +663,7 @@ def test_series_roundtrip_timeseries(self, orient, numpy, datetime_series): data = datetime_series.to_json(orient=orient) result = pd.read_json(data, typ="series", orient=orient, numpy=numpy) + expected = datetime_series if orient in ("values", "records"): expected = expected.reset_index(drop=True) if orient != "split": From 9f57295729d84d0f8b19688c8c06f06f6aaa1847 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 12 Feb 2020 08:34:50 -0800 Subject: [PATCH 6/9] flake8 --- pandas/tests/io/json/test_pandas.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 29ecb402226f7..91a2458469f97 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -3,7 +3,6 @@ from datetime import timedelta from io import StringIO import json -import os import numpy as np import pytest From 4e8017840e01b5477a4741ecd3421855d1e645fa Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Mon, 16 Mar 2020 19:22:40 -0700 Subject: [PATCH 7/9] removed monkeypatch --- pandas/tests/io/json/test_pandas.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/pandas/tests/io/json/test_pandas.py b/pandas/tests/io/json/test_pandas.py index 6605fabc8e1e6..34d0239d36f95 100644 --- a/pandas/tests/io/json/test_pandas.py +++ b/pandas/tests/io/json/test_pandas.py @@ -3,6 +3,7 @@ from datetime import timedelta from io import StringIO import json +import os import numpy as np import pytest @@ -42,11 +43,8 @@ def assert_json_roundtrip_equal(result, expected, orient): @pytest.mark.filterwarnings("ignore:the 'numpy' keyword is deprecated:FutureWarning") class TestPandasContainer: @pytest.fixture(autouse=True) - def setup(self, datapath, monkeypatch): - monkeypatch.chdir(datapath("io", "json", "data")) - + def setup(self): self.empty_frame = DataFrame() - self.frame = _frame.copy() self.frame2 = _frame2.copy() self.intframe = _intframe.copy() @@ -437,7 +435,7 @@ def test_frame_mixedtype_orient(self): # GH10289 left = read_json(inp, orient="values", convert_axes=False) tm.assert_frame_equal(left, right) - def test_v12_compat(self): + def test_v12_compat(self, datapath): df = DataFrame( [ [1.56808523, 0.65727391, 1.81021139, -0.17251653], @@ -454,11 +452,14 @@ def test_v12_compat(self): df["modified"] = df["date"] df.iloc[1, df.columns.get_loc("modified")] = pd.NaT - df_unser = pd.read_json("tsframe_v012.json") + dirpath = datapath("io", "json", "data") + v12_json = os.path.join(dirpath, "tsframe_v012.json") + df_unser = pd.read_json(v12_json) tm.assert_frame_equal(df, df_unser) df_iso = df.drop(["modified"], axis=1) - df_unser_iso = pd.read_json("tsframe_iso_v012.json") + v12_iso_json = os.path.join(dirpath, "tsframe_iso_v012.json") + df_unser_iso = pd.read_json(v12_iso_json) tm.assert_frame_equal(df_iso, df_unser_iso) def test_blocks_compat_GH9037(self): From e60430b7d0be1165884b64f128cf9bbb086fa843 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 18 Mar 2020 16:32:20 -0700 Subject: [PATCH 8/9] reverted test_base change --- pandas/tests/resample/test_base.py | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/pandas/tests/resample/test_base.py b/pandas/tests/resample/test_base.py index ef587de38c1e2..ca12b64ac97c0 100644 --- a/pandas/tests/resample/test_base.py +++ b/pandas/tests/resample/test_base.py @@ -118,16 +118,11 @@ def test_resample_count_empty_series(freq, empty_series_dti, resample_method): # GH28427 result = getattr(empty_series_dti.resample(freq), resample_method)() - if isinstance(empty_series_dti.index, PeriodIndex): - index = empty_series_dti.index.asfreq(freq=freq) - else: - index = empty_series_dti.index._shallow_copy(freq=freq) - expected = pd.Series([], dtype="int64", index=index, name=empty_series_dti.name) index = _asfreq_compat(empty_series_dti.index, freq) expected = pd.Series([], dtype="int64", index=index, name=empty_series_dti.name) - tm.assert_series_equal(result, expected) + tm.assert_series_equal(result, expected) @all_ts From dc2d93e383b5c5e8bcdc5be5ee5137b11178b037 Mon Sep 17 00:00:00 2001 From: Will Ayd Date: Wed, 18 Mar 2020 16:32:55 -0700 Subject: [PATCH 9/9] black --- pandas/tests/resample/test_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/tests/resample/test_base.py b/pandas/tests/resample/test_base.py index ca12b64ac97c0..3384c2a94487b 100644 --- a/pandas/tests/resample/test_base.py +++ b/pandas/tests/resample/test_base.py @@ -122,7 +122,7 @@ def test_resample_count_empty_series(freq, empty_series_dti, resample_method): expected = pd.Series([], dtype="int64", index=index, name=empty_series_dti.name) - tm.assert_series_equal(result, expected) + tm.assert_series_equal(result, expected) @all_ts