# Buggy code
def _should_parse_dates(self, i):
    if isinstance(self.parse_dates, bool):
        return self.parse_dates
    else:
        if self.index_names is not None:
            name = self.index_names[i]
        else:
            name = None
        j = self.index_col[i]

        if is_scalar(self.parse_dates):
            return (j == self.parse_dates) or (
                name is not None and name == self.parse_dates
            )
        else:
            return (j in self.parse_dates) or (
                name is not None and name in self.parse_dates
            )


# Traceback (TypeError)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-146-082b3d7afa0a> in <module>()
1 import io
2 s = """A,B,\n1,2"""
----> 3 pd.read_csv(io.StringIO(s), parse_dates=["B"], names=["B"])

/usr/lib/python3/dist-packages/pandas/io/parsers.py in parser_f(filepath_or_buffer, sep, delimiter, header, names, index_col, usecols, squeeze, prefix, mangle_dupe_cols, dtype, engine, converters, true_values, false_values, skipinitialspace, skiprows, nrows, na_values, keep_default_na, na_filter, verbose, skip_blank_lines, parse_dates, infer_datetime_format, keep_date_col, date_parser, dayfirst, iterator, chunksize, compression, thousands, decimal, lineterminator, quotechar, quoting, escapechar, comment, encoding, dialect, tupleize_cols, error_bad_lines, warn_bad_lines, skipfooter, doublequote, delim_whitespace, low_memory, memory_map, float_precision)
676                     skip_blank_lines=skip_blank_lines)
677
--> 678         return _read(filepath_or_buffer, kwds)
679
680     parser_f.__name__ = name

/usr/lib/python3/dist-packages/pandas/io/parsers.py in _read(filepath_or_buffer, kwds)
444
445     try:
--> 446         data = parser.read(nrows)
447     finally:
448         parser.close()

/usr/lib/python3/dist-packages/pandas/io/parsers.py in read(self, nrows)
1034                 raise ValueError('skipfooter not supported for iteration')
1035
-> 1036         ret = self._engine.read(nrows)
1037
1038         # May alter columns / col_dict

/usr/lib/python3/dist-packages/pandas/io/parsers.py in read(self, nrows)
1887
1888                 values = self._maybe_parse_dates(values, i,
-> 1889                                                  try_parse_dates=True)
1890                 arrays.append(values)
1891

/usr/lib/python3/dist-packages/pandas/io/parsers.py in _maybe_parse_dates(self, values, index, try_parse_dates)
1946
1947     def _maybe_parse_dates(self, values, index, try_parse_dates=True):
-> 1948         if try_parse_dates and self._should_parse_dates(index):
1949             values = self._date_conv(values)
1950         return values

/usr/lib/python3/dist-packages/pandas/io/parsers.py in _should_parse_dates(self, i)
1319             else:
1320                 name = None
-> 1321             j = self.index_col[i]
1322
1323             if is_scalar(self.parse_dates):

TypeError: 'NoneType' object is not subscriptable

# Fixed code
def _should_parse_dates(self, i):
    if isinstance(self.parse_dates, bool):
        return self.parse_dates
    else:
        if self.index_names is not None:
            name = self.index_names[i]
        else:
            name = None
        j = i if self.index_col is None else self.index_col[i]

        if is_scalar(self.parse_dates):
            return (j == self.parse_dates) or (
                name is not None and name == self.parse_dates
            )
        else:
            return (j in self.parse_dates) or (
                name is not None and name in self.parse_dates
            )