@@ -475,8 +475,7 @@ def _adjust_to_origin(arg, origin, unit):
475
475
j_min = Timestamp .min .to_julian_date () - j0
476
476
if np .any (arg > j_max ) or np .any (arg < j_min ):
477
477
raise tslibs .OutOfBoundsDatetime (
478
- "{original} is Out of Bounds for "
479
- "origin='julian'" .format (original = original )
478
+ f"{ original } is Out of Bounds for origin='julian'"
480
479
)
481
480
else :
482
481
# arg must be numeric
@@ -485,27 +484,20 @@ def _adjust_to_origin(arg, origin, unit):
485
484
or is_numeric_dtype (np .asarray (arg ))
486
485
):
487
486
raise ValueError (
488
- "'{arg}' is not compatible with origin='{origin}'; "
489
- "it must be numeric with a unit specified " .format (
490
- arg = arg , origin = origin
491
- )
487
+ f"'{ arg } ' is not compatible with origin='{ origin } '; "
488
+ "it must be numeric with a unit specified"
492
489
)
493
490
494
491
# we are going to offset back to unix / epoch time
495
492
try :
496
493
offset = Timestamp (origin )
497
494
except tslibs .OutOfBoundsDatetime :
498
- raise tslibs .OutOfBoundsDatetime (
499
- "origin {origin} is Out of Bounds" .format (origin = origin )
500
- )
495
+ raise tslibs .OutOfBoundsDatetime (f"origin { origin } is Out of Bounds" )
501
496
except ValueError :
502
- raise ValueError (
503
- "origin {origin} cannot be converted "
504
- "to a Timestamp" .format (origin = origin )
505
- )
497
+ raise ValueError (f"origin { origin } cannot be converted to a Timestamp" )
506
498
507
499
if offset .tz is not None :
508
- raise ValueError ("origin offset {} must be tz-naive" . format ( offset ) )
500
+ raise ValueError (f "origin offset { offset } must be tz-naive" )
509
501
offset -= Timestamp (0 )
510
502
511
503
# convert the offset to the unit of the arg
@@ -808,19 +800,19 @@ def f(value):
808
800
required = ["year" , "month" , "day" ]
809
801
req = sorted (set (required ) - set (unit_rev .keys ()))
810
802
if len (req ):
803
+ required = "," .join (req )
811
804
raise ValueError (
812
805
"to assemble mappings requires at least that "
813
- "[year, month, day] be specified: [{required}] "
814
- "is missing" . format ( required = "," . join ( req ))
806
+ f "[year, month, day] be specified: [{ required } ] "
807
+ "is missing"
815
808
)
816
809
817
810
# keys we don't recognize
818
811
excess = sorted (set (unit_rev .keys ()) - set (_unit_map .values ()))
819
812
if len (excess ):
813
+ excess = "," .join (excess )
820
814
raise ValueError (
821
- "extra keys have been passed "
822
- "to the datetime assemblage: "
823
- "[{excess}]" .format (excess = "," .join (excess ))
815
+ f"extra keys have been passed to the datetime assemblage: [{ excess } ]"
824
816
)
825
817
826
818
def coerce (values ):
@@ -983,9 +975,9 @@ def _convert_listlike(arg, format):
983
975
except (ValueError , TypeError ):
984
976
if errors == "raise" :
985
977
msg = (
986
- "Cannot convert {element} to a time with given "
987
- "format {format}"
988
- ). format ( element = element , format = format )
978
+ f "Cannot convert { element } to a time with given "
979
+ f "format { format } "
980
+ )
989
981
raise ValueError (msg )
990
982
elif errors == "ignore" :
991
983
return arg
@@ -1011,9 +1003,7 @@ def _convert_listlike(arg, format):
1011
1003
if time_object is not None :
1012
1004
times .append (time_object )
1013
1005
elif errors == "raise" :
1014
- raise ValueError (
1015
- "Cannot convert arg {arg} to a time" .format (arg = arg )
1016
- )
1006
+ raise ValueError (f"Cannot convert arg { arg } to a time" )
1017
1007
elif errors == "ignore" :
1018
1008
return arg
1019
1009
else :
0 commit comments