Skip to content

Commit 6914ea2

Browse files
BehemkotAlexKirko
authored andcommitted
%s changed to fstring, single quotes in f string changed to double qu… (pandas-dev#30108)
1 parent 0e86c49 commit 6914ea2

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

pandas/_libs/tslibs/period.pyx

+13-14
Original file line numberDiff line numberDiff line change
@@ -1212,8 +1212,7 @@ cdef str period_format(int64_t value, int freq, object fmt=None):
12121212
elif freq_group == 4000: # WK
12131213
left = period_asfreq(value, freq, 6000, 0)
12141214
right = period_asfreq(value, freq, 6000, 1)
1215-
return '%s/%s' % (period_format(left, 6000),
1216-
period_format(right, 6000))
1215+
return f"{period_format(left, 6000)}/{period_format(right, 6000)}"
12171216
elif (freq_group == 5000 # BUS
12181217
or freq_group == 6000): # DAY
12191218
fmt = b'%Y-%m-%d'
@@ -1230,7 +1229,7 @@ cdef str period_format(int64_t value, int freq, object fmt=None):
12301229
elif freq_group == 12000: # NANOSEC
12311230
fmt = b'%Y-%m-%d %H:%M:%S.%n'
12321231
else:
1233-
raise ValueError(f'Unknown freq: {freq}')
1232+
raise ValueError(f"Unknown freq: {freq}")
12341233

12351234
return _period_strftime(value, freq, fmt)
12361235

@@ -1276,15 +1275,15 @@ cdef str _period_strftime(int64_t value, int freq, bytes fmt):
12761275
if i == 0:
12771276
repl = str(quarter)
12781277
elif i == 1: # %f, 2-digit year
1279-
repl = f'{(year % 100):02d}'
1278+
repl = f"{(year % 100):02d}"
12801279
elif i == 2:
12811280
repl = str(year)
12821281
elif i == 3:
1283-
repl = f'{(value % 1_000):03d}'
1282+
repl = f"{(value % 1_000):03d}"
12841283
elif i == 4:
1285-
repl = f'{(value % 1_000_000):06d}'
1284+
repl = f"{(value % 1_000_000):06d}"
12861285
elif i == 5:
1287-
repl = f'{(value % 1_000_000_000):09d}'
1286+
repl = f"{(value % 1_000_000_000):09d}"
12881287

12891288
result = result.replace(str_extra_fmts[i], repl)
12901289

@@ -1392,7 +1391,7 @@ def get_period_field_arr(int code, int64_t[:] arr, int freq):
13921391

13931392
func = _get_accessor_func(code)
13941393
if func is NULL:
1395-
raise ValueError(f'Unrecognized period code: {code}')
1394+
raise ValueError(f"Unrecognized period code: {code}")
13961395

13971396
sz = len(arr)
13981397
out = np.empty(sz, dtype=np.int64)
@@ -1579,8 +1578,8 @@ cdef class _Period:
15791578
freq = to_offset(freq)
15801579

15811580
if freq.n <= 0:
1582-
raise ValueError(f'Frequency must be positive, because it '
1583-
f'represents span: {freq.freqstr}')
1581+
raise ValueError("Frequency must be positive, because it "
1582+
f"represents span: {freq.freqstr}")
15841583

15851584
return freq
15861585

@@ -1614,8 +1613,8 @@ cdef class _Period:
16141613
return NotImplemented
16151614
elif op == Py_NE:
16161615
return NotImplemented
1617-
raise TypeError(f'Cannot compare type {type(self).__name__} '
1618-
f'with type {type(other).__name__}')
1616+
raise TypeError(f"Cannot compare type {type(self).__name__} "
1617+
f"with type {type(other).__name__}")
16191618

16201619
def __hash__(self):
16211620
return hash((self.ordinal, self.freqstr))
@@ -1633,8 +1632,8 @@ cdef class _Period:
16331632
if nanos % offset_nanos == 0:
16341633
ordinal = self.ordinal + (nanos // offset_nanos)
16351634
return Period(ordinal=ordinal, freq=self.freq)
1636-
raise IncompatibleFrequency(f'Input cannot be converted to '
1637-
f'Period(freq={self.freqstr})')
1635+
raise IncompatibleFrequency("Input cannot be converted to "
1636+
f"Period(freq={self.freqstr})")
16381637
elif util.is_offset_object(other):
16391638
freqstr = other.rule_code
16401639
base = get_base_alias(freqstr)

pandas/_libs/tslibs/strptime.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ class TimeRE(dict):
588588
else:
589589
return ''
590590
regex = '|'.join(re.escape(stuff) for stuff in to_convert)
591-
regex = f'(?P<{directive}>{regex})'
591+
regex = f"(?P<{directive}>{regex})"
592592
return regex
593593

594594
def pattern(self, format):

0 commit comments

Comments
 (0)