Skip to content

Simplify conditional branch in _read function in readers.py #45696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 30, 2022
Merged
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: 6 additions & 8 deletions pandas/io/parsers/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,13 +542,11 @@ def _read(
"""Generic reader of line files."""
# if we pass a date_parser and parse_dates=False, we should not parse the
# dates GH#44366
if (
kwds.get("date_parser", None) is not None
and kwds.get("parse_dates", None) is None
):
kwds["parse_dates"] = True
elif kwds.get("parse_dates", None) is None:
kwds["parse_dates"] = False
if kwds.get("parse_dates", None) is None:
if kwds.get("date_parser", None) is None:
kwds["parse_dates"] = False
else:
kwds["parse_dates"] = True

# Extract some of the arguments (pass chunksize on).
iterator = kwds.get("iterator", False)
Expand All @@ -564,7 +562,7 @@ def _read(
"The 'chunksize' option is not supported with the 'pyarrow' engine"
)
else:
chunksize = validate_integer("chunksize", kwds.get("chunksize", None), 1)
chunksize = validate_integer("chunksize", chunksize, 1)

nrows = kwds.get("nrows", None)

Expand Down