diff --git a/pandas/tests/io/test_pickle.py b/pandas/tests/io/test_pickle.py index 04fd4835469a9..78b630bb5ada1 100644 --- a/pandas/tests/io/test_pickle.py +++ b/pandas/tests/io/test_pickle.py @@ -60,9 +60,7 @@ def compare_element(result, expected, typ, version=None): assert result == expected assert result.freq == expected.freq else: - comparator = getattr( - tm, "assert_{typ}_equal".format(typ=typ), tm.assert_almost_equal - ) + comparator = getattr(tm, f"assert_{typ}_equal", tm.assert_almost_equal) comparator(result, expected) @@ -77,7 +75,7 @@ def compare(data, vf, version): # use a specific comparator # if available - comparator = "compare_{typ}_{dt}".format(typ=typ, dt=dt) + comparator = f"compare_{typ}_{dt}" comparator = m.get(comparator, m["compare_element"]) comparator(result, expected, typ, version) @@ -234,7 +232,7 @@ def test_legacy_sparse_warning(datapath): @pytest.fixture def get_random_path(): - return "__{}__.pickle".format(tm.rands(10)) + return f"__{tm.rands(10)}__.pickle" class TestCompression: @@ -262,7 +260,7 @@ def compress_file(self, src_path, dest_path, compression): elif compression == "xz": f = _get_lzma_file(lzma)(dest_path, "w") else: - msg = "Unrecognized compression type: {}".format(compression) + msg = f"Unrecognized compression type: {compression}" raise ValueError(msg) if compression != "zip": diff --git a/pandas/tests/series/indexing/test_indexing.py b/pandas/tests/series/indexing/test_indexing.py index 1b21e2419595f..fa5c75d5e4ad9 100644 --- a/pandas/tests/series/indexing/test_indexing.py +++ b/pandas/tests/series/indexing/test_indexing.py @@ -429,7 +429,7 @@ def test_basic_getitem_setitem_corner(datetime_series): @pytest.mark.parametrize("tz", ["US/Eastern", "UTC", "Asia/Tokyo"]) def test_setitem_with_tz(tz): orig = pd.Series(pd.date_range("2016-01-01", freq="H", periods=3, tz=tz)) - assert orig.dtype == "datetime64[ns, {0}]".format(tz) + assert orig.dtype == f"datetime64[ns, {tz}]" # scalar s = orig.copy() @@ -456,7 +456,7 @@ def test_setitem_with_tz(tz): [pd.Timestamp("2011-01-01", tz=tz), pd.Timestamp("2012-01-01", tz=tz)], index=[1, 2], ) - assert vals.dtype == "datetime64[ns, {0}]".format(tz) + assert vals.dtype == f"datetime64[ns, {tz}]" s[[1, 2]] = vals exp = pd.Series( @@ -481,7 +481,7 @@ def test_setitem_with_tz_dst(): # GH XXX tz = "US/Eastern" orig = pd.Series(pd.date_range("2016-11-06", freq="H", periods=3, tz=tz)) - assert orig.dtype == "datetime64[ns, {0}]".format(tz) + assert orig.dtype == f"datetime64[ns, {tz}]" # scalar s = orig.copy() @@ -508,7 +508,7 @@ def test_setitem_with_tz_dst(): [pd.Timestamp("2011-01-01", tz=tz), pd.Timestamp("2012-01-01", tz=tz)], index=[1, 2], ) - assert vals.dtype == "datetime64[ns, {0}]".format(tz) + assert vals.dtype == f"datetime64[ns, {tz}]" s[[1, 2]] = vals exp = pd.Series(