Skip to content

Commit 10c3f82

Browse files
ShaharNavehMateusz Górski
authored and
Mateusz Górski
committed
CLN: f-string at pandas/_libs/tslib.pyx (pandas-dev#29593)
1 parent b844a94 commit 10c3f82

File tree

1 file changed

+5
-9
lines changed

1 file changed

+5
-9
lines changed

pandas/_libs/tslib.pyx

+5-9
Original file line numberDiff line numberDiff line change
@@ -266,20 +266,16 @@ def format_array_from_datetime(ndarray[int64_t] values, object tz=None,
266266
elif basic_format:
267267

268268
dt64_to_dtstruct(val, &dts)
269-
res = '%d-%.2d-%.2d %.2d:%.2d:%.2d' % (dts.year,
270-
dts.month,
271-
dts.day,
272-
dts.hour,
273-
dts.min,
274-
dts.sec)
269+
res = (f'{dts.year}-{dts.month:02d}-{dts.day:02d} '
270+
f'{dts.hour:02d}:{dts.min:02d}:{dts.sec:02d}')
275271

276272
if show_ns:
277273
ns = dts.ps // 1000
278-
res += '.%.9d' % (ns + 1000 * dts.us)
274+
res += f'.{ns + dts.us * 1000:09d}'
279275
elif show_us:
280-
res += '.%.6d' % dts.us
276+
res += f'.{dts.us:06d}'
281277
elif show_ms:
282-
res += '.%.3d' % (dts.us / 1000)
278+
res += f'.{dts.us // 1000:03d}'
283279

284280
result[i] = res
285281

0 commit comments

Comments
 (0)