Skip to content

Commit 3d193fa

Browse files
author
MomIsBestFriend
committed
Finished parsers.pyx
1 parent 6fc5aca commit 3d193fa

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

pandas/_libs/parsers.pyx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -637,19 +637,19 @@ cdef class TextReader:
637637
source = zip_file.open(file_name)
638638

639639
elif len(zip_names) == 0:
640-
raise ValueError('Zero files found in compressed '
641-
'zip file %s', source)
640+
raise ValueError(f'Zero files found in compressed '
641+
f'zip file {source}')
642642
else:
643-
raise ValueError('Multiple files found in compressed '
644-
'zip file %s', str(zip_names))
643+
raise ValueError(f'Multiple files found in compressed '
644+
f'zip file {zip_names}')
645645
elif self.compression == 'xz':
646646
if isinstance(source, str):
647647
source = _get_lzma_file(lzma)(source, 'rb')
648648
else:
649649
source = _get_lzma_file(lzma)(filename=source)
650650
else:
651-
raise ValueError('Unrecognized compression type: %s' %
652-
self.compression)
651+
raise ValueError(f'Unrecognized compression type: '
652+
f'{self.compression}')
653653

654654
if b'utf-16' in (self.encoding or b''):
655655
# we need to read utf-16 through UTF8Recoder.
@@ -703,8 +703,8 @@ cdef class TextReader:
703703
self.parser.cb_io = &buffer_rd_bytes
704704
self.parser.cb_cleanup = &del_rd_source
705705
else:
706-
raise IOError('Expected file path name or file-like object,'
707-
' got %s type' % type(source))
706+
raise IOError(f'Expected file path name or file-like object, '
707+
f'got {type(source)} type')
708708

709709
cdef _get_header(self):
710710
# header is now a list of lists, so field_count should use header[0]
@@ -744,8 +744,8 @@ cdef class TextReader:
744744
msg = "[%s], len of %d," % (
745745
','.join(str(m) for m in msg), len(msg))
746746
raise ParserError(
747-
'Passed header=%s but only %d lines in file'
748-
% (msg, self.parser.lines))
747+
f'Passed header={msg} but only '
748+
f'{self.parser.lines} lines in file')
749749

750750
else:
751751
field_count = self.parser.line_fields[hr]
@@ -779,7 +779,7 @@ cdef class TextReader:
779779
if not self.has_mi_columns and self.mangle_dupe_cols:
780780
while count > 0:
781781
counts[name] = count + 1
782-
name = '%s.%d' % (name, count)
782+
name = f'{name}.{count}'
783783
count = counts.get(name, 0)
784784

785785
if old_name == '':
@@ -1662,7 +1662,7 @@ cdef _to_fw_string(parser_t *parser, int64_t col, int64_t line_start,
16621662
char *data
16631663
ndarray result
16641664

1665-
result = np.empty(line_end - line_start, dtype='|S%d' % width)
1665+
result = np.empty(line_end - line_start, dtype=f'|S{width}')
16661666
data = <char*>result.data
16671667

16681668
with nogil:
@@ -2176,8 +2176,8 @@ def _concatenate_chunks(list chunks):
21762176
if warning_columns:
21772177
warning_names = ','.join(warning_columns)
21782178
warning_message = " ".join([
2179-
"Columns (%s) have mixed types." % warning_names,
2180-
"Specify dtype option on import or set low_memory=False."
2179+
f"Columns ({warning_names}) have mixed types."
2180+
f"Specify dtype option on import or set low_memory=False."
21812181
])
21822182
warnings.warn(warning_message, DtypeWarning, stacklevel=8)
21832183
return result

0 commit comments

Comments
 (0)