@@ -491,8 +491,7 @@ def _adjust_to_origin(arg, origin, unit):
491
491
j_min = Timestamp .min .to_julian_date () - j0
492
492
if np .any (arg > j_max ) or np .any (arg < j_min ):
493
493
raise tslibs .OutOfBoundsDatetime (
494
- "{original} is Out of Bounds for "
495
- "origin='julian'" .format (original = original )
494
+ f"{ original } is Out of Bounds for origin='julian'"
496
495
)
497
496
else :
498
497
# arg must be numeric
@@ -501,27 +500,20 @@ def _adjust_to_origin(arg, origin, unit):
501
500
or is_numeric_dtype (np .asarray (arg ))
502
501
):
503
502
raise ValueError (
504
- "'{arg}' is not compatible with origin='{origin}'; "
505
- "it must be numeric with a unit specified " .format (
506
- arg = arg , origin = origin
507
- )
503
+ f"'{ arg } ' is not compatible with origin='{ origin } '; "
504
+ "it must be numeric with a unit specified"
508
505
)
509
506
510
507
# we are going to offset back to unix / epoch time
511
508
try :
512
509
offset = Timestamp (origin )
513
510
except tslibs .OutOfBoundsDatetime :
514
- raise tslibs .OutOfBoundsDatetime (
515
- "origin {origin} is Out of Bounds" .format (origin = origin )
516
- )
511
+ raise tslibs .OutOfBoundsDatetime (f"origin { origin } is Out of Bounds" )
517
512
except ValueError :
518
- raise ValueError (
519
- "origin {origin} cannot be converted "
520
- "to a Timestamp" .format (origin = origin )
521
- )
513
+ raise ValueError (f"origin { origin } cannot be converted to a Timestamp" )
522
514
523
515
if offset .tz is not None :
524
- raise ValueError ("origin offset {} must be tz-naive" . format ( offset ) )
516
+ raise ValueError (f "origin offset { offset } must be tz-naive" )
525
517
offset -= Timestamp (0 )
526
518
527
519
# convert the offset to the unit of the arg
@@ -824,19 +816,19 @@ def f(value):
824
816
required = ["year" , "month" , "day" ]
825
817
req = sorted (set (required ) - set (unit_rev .keys ()))
826
818
if len (req ):
819
+ required = "," .join (req )
827
820
raise ValueError (
828
821
"to assemble mappings requires at least that "
829
- "[year, month, day] be specified: [{required}] "
830
- "is missing" . format ( required = "," . join ( req ))
822
+ f "[year, month, day] be specified: [{ required } ] "
823
+ "is missing"
831
824
)
832
825
833
826
# keys we don't recognize
834
827
excess = sorted (set (unit_rev .keys ()) - set (_unit_map .values ()))
835
828
if len (excess ):
829
+ excess = "," .join (excess )
836
830
raise ValueError (
837
- "extra keys have been passed "
838
- "to the datetime assemblage: "
839
- "[{excess}]" .format (excess = "," .join (excess ))
831
+ f"extra keys have been passed to the datetime assemblage: [{ excess } ]"
840
832
)
841
833
842
834
def coerce (values ):
@@ -999,9 +991,9 @@ def _convert_listlike(arg, format):
999
991
except (ValueError , TypeError ):
1000
992
if errors == "raise" :
1001
993
msg = (
1002
- "Cannot convert {element} to a time with given "
1003
- "format {format}"
1004
- ). format ( element = element , format = format )
994
+ f "Cannot convert { element } to a time with given "
995
+ f "format { format } "
996
+ )
1005
997
raise ValueError (msg )
1006
998
elif errors == "ignore" :
1007
999
return arg
@@ -1027,9 +1019,7 @@ def _convert_listlike(arg, format):
1027
1019
if time_object is not None :
1028
1020
times .append (time_object )
1029
1021
elif errors == "raise" :
1030
- raise ValueError (
1031
- "Cannot convert arg {arg} to a time" .format (arg = arg )
1032
- )
1022
+ raise ValueError (f"Cannot convert arg { arg } to a time" )
1033
1023
elif errors == "ignore" :
1034
1024
return arg
1035
1025
else :
0 commit comments