@@ -811,15 +811,15 @@ def test_constructor_dtype_datetime64(self):
811
811
expected = Series (values2 , index = dates )
812
812
813
813
for dtype in ["s" , "D" , "ms" , "us" , "ns" ]:
814
- values1 = dates .view (np .ndarray ).astype ("M8[{0 }]" . format ( dtype ) )
814
+ values1 = dates .view (np .ndarray ).astype (f "M8[{ dtype } ]" )
815
815
result = Series (values1 , dates )
816
816
tm .assert_series_equal (result , expected )
817
817
818
818
# GH 13876
819
819
# coerce to non-ns to object properly
820
820
expected = Series (values2 , index = dates , dtype = object )
821
821
for dtype in ["s" , "D" , "ms" , "us" , "ns" ]:
822
- values1 = dates .view (np .ndarray ).astype ("M8[{0 }]" . format ( dtype ) )
822
+ values1 = dates .view (np .ndarray ).astype (f "M8[{ dtype } ]" )
823
823
result = Series (values1 , index = dates , dtype = object )
824
824
tm .assert_series_equal (result , expected )
825
825
@@ -952,7 +952,7 @@ def test_constructor_with_datetime_tz(self):
952
952
def test_construction_to_datetimelike_unit (self , arr_dtype , dtype , unit ):
953
953
# tests all units
954
954
# gh-19223
955
- dtype = "{ }[{}]". format ( dtype , unit )
955
+ dtype = f" { dtype } [{ unit } ]"
956
956
arr = np .array ([1 , 2 , 3 ], dtype = arr_dtype )
957
957
s = Series (arr )
958
958
result = s .astype (dtype )
@@ -1347,12 +1347,11 @@ def test_convert_non_ns(self):
1347
1347
def test_constructor_cant_cast_datetimelike (self , index ):
1348
1348
1349
1349
# floats are not ok
1350
- msg = "Cannot cast {}.*? to " .format (
1351
- # strip Index to convert PeriodIndex -> Period
1352
- # We don't care whether the error message says
1353
- # PeriodIndex or PeriodArray
1354
- type (index ).__name__ .rstrip ("Index" )
1355
- )
1350
+ # strip Index to convert PeriodIndex -> Period
1351
+ # We don't care whether the error message says
1352
+ # PeriodIndex or PeriodArray
1353
+ msg = f"Cannot cast { type (index ).__name__ .rstrip ('Index' )} .*? to "
1354
+
1356
1355
with pytest .raises (TypeError , match = msg ):
1357
1356
Series (index , dtype = float )
1358
1357
0 commit comments