Skip to content
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

fix: apply dayfirst in special read cases, also in the case of csv files #170

Merged
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
5 changes: 2 additions & 3 deletions timely_beliefs/beliefs/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -631,16 +631,15 @@ def read_csv( # noqa C901
if col not in kwargs.get("usecols", [])
]
ext = find_out_extension(path)
dayfirst = None
if ext.lower() == "csv":
df = pd.read_csv(path, **kwargs)
elif ext.lower() in ("xlsm", "xlsx", "xls"):
dayfirst = kwargs.pop("dayfirst", None)
df = pd.read_excel(path, **kwargs) # requires openpyxl
else:
raise TypeError(
f"Extension {ext} not recognized. Accepted file extensions are csv, xlsm, xlsx and xls."
)
dayfirst = kwargs.pop("dayfirst", None)
if filter_by_column:
# Filter the read-in data
for col, val in filter_by_column.items():
Expand Down Expand Up @@ -766,7 +765,7 @@ def interpret_special_read_cases(
sensor: "classes.Sensor",
resample: bool,
timezone: str | None,
dayfirst: bool,
dayfirst: bool | None,
split: str | None = None,
) -> pd.DataFrame:
"""Interpret the read-in data, either as event starts and event values (2 cols),
Expand Down
Loading