Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions pandas/io/parsers/base_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def __init__(self, kwds) -> None:
parse_dates = bool(parse_dates)
elif not isinstance(parse_dates, list):
raise TypeError(
"Only booleans and lists are accepted "
"for the 'parse_dates' parameter"
"Only booleans and lists are accepted for the 'parse_dates' parameter"
)
self.parse_dates: bool | list = parse_dates
self.date_parser = kwds.pop("date_parser", lib.no_default)
Expand Down Expand Up @@ -244,7 +243,7 @@ def extract(r):
names.insert(single_ic, single_ic)

# Clean the column names (if we have an index_col).
if len(ic):
if ic:
col_names = [
r[ic[0]]
if ((r[ic[0]] is not None) and r[ic[0]] not in self.unnamed_cols)
Expand Down Expand Up @@ -368,7 +367,7 @@ def _agg_index(self, index) -> Index:
index_converter = converters.get(self.index_names[i]) is not None

try_num_bool = not (
cast_type and is_string_dtype(cast_type) or index_converter
(cast_type and is_string_dtype(cast_type)) or index_converter
)

arr, _ = self._infer_types(
Expand Down Expand Up @@ -716,7 +715,7 @@ def _get_empty_meta(
# if dtype == None, default will be object.
dtype_dict = defaultdict(lambda: dtype)
else:
dtype = cast(dict, dtype)
dtype = cast("dict", dtype)
dtype_dict = defaultdict(
lambda: None,
{columns[k] if is_integer(k) else k: v for k, v in dtype.items()},
Expand Down Expand Up @@ -895,15 +894,16 @@ def validate_parse_dates_presence(
if not isinstance(parse_dates, list):
return set()

columns_set = set(columns)
missing = set()
unique_cols = set()
for col in parse_dates:
if isinstance(col, str):
if col not in columns:
if col not in columns_set:
missing.add(col)
else:
unique_cols.add(col)
elif col in columns:
elif col in columns_set:
unique_cols.add(col)
else:
unique_cols.add(columns[col])
Expand Down