Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLN: F-string formatting in pandas/_libs/*.pyx #29527

Merged
merged 16 commits into from
Nov 11, 2019
Prev Previous commit
Next Next commit
Finished tslib.pyx
  • Loading branch information
MomIsBestFriend committed Nov 10, 2019
commit 5ff5e400ffe3f31ed12d29fd42658c6ae1aece29
28 changes: 13 additions & 15 deletions pandas/_libs/tslib.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ def array_with_unit_to_datetime(ndarray values, object unit,

if ((fvalues < Timestamp.min.value).any()
or (fvalues > Timestamp.max.value).any()):
raise OutOfBoundsDatetime("cannot convert input with unit "
"'{unit}'".format(unit=unit))
raise OutOfBoundsDatetime(f"cannot convert input with unit "
f"'{unit}'")
result = (iresult * m).astype('M8[ns]')
iresult = result.view('i8')
iresult[mask] = NPY_NAT
Expand All @@ -384,8 +384,8 @@ def array_with_unit_to_datetime(ndarray values, object unit,
except OverflowError:
if is_raise:
raise OutOfBoundsDatetime(
"cannot convert input {val} with the unit "
"'{unit}'".format(val=val, unit=unit))
f"cannot convert input {val} with the unit "
f"'{unit}'")
elif is_ignore:
raise AssertionError
iresult[i] = NPY_NAT
Expand All @@ -400,25 +400,25 @@ def array_with_unit_to_datetime(ndarray values, object unit,
except ValueError:
if is_raise:
raise ValueError(
"non convertible value {val} with the unit "
"'{unit}'".format(val=val, unit=unit))
f"non convertible value {val} with the unit "
f"'{unit}'")
elif is_ignore:
raise AssertionError
iresult[i] = NPY_NAT
except OverflowError:
if is_raise:
raise OutOfBoundsDatetime(
"cannot convert input {val} with the unit "
"'{unit}'".format(val=val, unit=unit))
f"cannot convert input {val} with the unit "
f"'{unit}'")
elif is_ignore:
raise AssertionError
iresult[i] = NPY_NAT

else:

if is_raise:
raise ValueError("unit='{0}' not valid with non-numerical "
"val='{1}'".format(unit, val))
raise ValueError(f"unit='{unit}' not valid with non-numerical "
f"val='{val}'")
if is_ignore:
raise AssertionError

Expand Down Expand Up @@ -600,9 +600,8 @@ cpdef array_to_datetime(ndarray[object] values, str errors='raise',
iresult[i] = NPY_NAT
continue
elif is_raise:
raise ValueError("time data {val} doesn't "
"match format specified"
.format(val=val))
raise ValueError(f"time data {val} doesn't "
f"match format specified")
return values, tz_out

try:
Expand Down Expand Up @@ -657,8 +656,7 @@ cpdef array_to_datetime(ndarray[object] values, str errors='raise',
if is_coerce:
iresult[i] = NPY_NAT
else:
raise TypeError("{typ} is not convertible to datetime"
.format(typ=type(val)))
raise TypeError(f"{type(val)} is not convertible to datetime")

except OutOfBoundsDatetime:
if is_coerce:
Expand Down