@@ -29,7 +29,7 @@ cdef extern from "Python.h":
2929
3030import numpy as np
3131cimport numpy as cnp
32- from numpy cimport ndarray, uint8_t, uint64_t, int64_t
32+ from numpy cimport ndarray, uint8_t, uint64_t, int64_t, float64_t
3333cnp.import_array()
3434
3535from util cimport UINT64_MAX, INT64_MAX, INT64_MIN
@@ -694,7 +694,7 @@ cdef class TextReader:
694694 if ptr == NULL :
695695 if not os.path.exists(source):
696696 raise compat.FileNotFoundError(
697- ' File %s does not exist' % source)
697+ ' File {source} does not exist' .format( source = source) )
698698 raise IOError (' Initializing from file failed' )
699699
700700 self .parser.source = ptr
@@ -772,9 +772,10 @@ cdef class TextReader:
772772
773773 if name == ' ' :
774774 if self .has_mi_columns:
775- name = ' Unnamed: %d _level_%d ' % (i, level)
775+ name = (' Unnamed: {i}_level_{lvl}'
776+ .format(i = i, lvl = level))
776777 else :
777- name = ' Unnamed: %d ' % i
778+ name = ' Unnamed: {i} ' .format( i = i)
778779 unnamed_count += 1
779780
780781 count = counts.get(name, 0 )
@@ -849,8 +850,8 @@ cdef class TextReader:
849850 # 'data has %d fields'
850851 # % (passed_count, field_count))
851852
852- if self .has_usecols and self .allow_leading_cols and \
853- not callable (self .usecols):
853+ if ( self .has_usecols and self .allow_leading_cols and
854+ not callable (self .usecols)) :
854855 nuse = len (self .usecols)
855856 if nuse == passed_count:
856857 self .leading_cols = 0
@@ -1027,17 +1028,19 @@ cdef class TextReader:
10271028
10281029 if self .table_width - self .leading_cols > num_cols:
10291030 raise ParserError(
1030- " Too many columns specified: expected %s and found %s " %
1031- (self .table_width - self .leading_cols, num_cols))
1031+ " Too many columns specified: expected {expected} and "
1032+ " found {found}"
1033+ .format(expected = self .table_width - self .leading_cols,
1034+ found = num_cols))
10321035
10331036 results = {}
10341037 nused = 0
10351038 for i in range (self .table_width):
10361039 if i < self .leading_cols:
10371040 # Pass through leading columns always
10381041 name = i
1039- elif self .usecols and not callable (self .usecols) and \
1040- nused == len (self .usecols):
1042+ elif ( self .usecols and not callable (self .usecols) and
1043+ nused == len (self .usecols)) :
10411044 # Once we've gathered all requested columns, stop. GH5766
10421045 break
10431046 else :
@@ -1103,7 +1106,7 @@ cdef class TextReader:
11031106 col_res = _maybe_upcast(col_res)
11041107
11051108 if col_res is None :
1106- raise ParserError(' Unable to parse column %d ' % i )
1109+ raise ParserError(' Unable to parse column {i} ' .format( i = i) )
11071110
11081111 results[i] = col_res
11091112
@@ -1222,8 +1225,8 @@ cdef class TextReader:
12221225 elif dtype.kind == ' U' :
12231226 width = dtype.itemsize
12241227 if width > 0 :
1225- raise TypeError (" the dtype %s is not "
1226- " supported for parsing" % dtype)
1228+ raise TypeError (" the dtype {dtype} is not "
1229+ " supported for parsing" .format( dtype = dtype) )
12271230
12281231 # unicode variable width
12291232 return self ._string_convert(i, start, end, na_filter,
@@ -1241,12 +1244,12 @@ cdef class TextReader:
12411244 return self ._string_convert(i, start, end, na_filter,
12421245 na_hashset)
12431246 elif is_datetime64_dtype(dtype):
1244- raise TypeError (" the dtype %s is not supported "
1247+ raise TypeError (" the dtype {dtype} is not supported "
12451248 " for parsing, pass this column "
1246- " using parse_dates instead" % dtype)
1249+ " using parse_dates instead" .format( dtype = dtype) )
12471250 else :
1248- raise TypeError (" the dtype %s is not "
1249- " supported for parsing" % dtype)
1251+ raise TypeError (" the dtype {dtype} is not "
1252+ " supported for parsing" .format( dtype = dtype) )
12501253
12511254 cdef _string_convert(self , Py_ssize_t i, int64_t start, int64_t end,
12521255 bint na_filter, kh_str_t * na_hashset):
@@ -2058,7 +2061,7 @@ cdef kh_float64_t* kset_float64_from_list(values) except NULL:
20582061 khiter_t k
20592062 kh_float64_t * table
20602063 int ret = 0
2061- cnp. float64_t val
2064+ float64_t val
20622065 object value
20632066
20642067 table = kh_init_float64()
@@ -2101,7 +2104,7 @@ cdef raise_parser_error(object base, parser_t *parser):
21012104 Py_XDECREF(type )
21022105 raise old_exc
21032106
2104- message = ' %s . C error: ' % base
2107+ message = ' {base} . C error: ' .format( base = base)
21052108 if parser.error_msg != NULL :
21062109 if PY3:
21072110 message += parser.error_msg.decode(' utf-8' )
0 commit comments