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 date_parser deprecation warning #478

Merged
merged 2 commits into from
Dec 19, 2023
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
8 changes: 7 additions & 1 deletion storey/sources.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from datetime import datetime, timezone
from typing import Callable, Coroutine, Iterable, List, Optional, Union

import packaging.version
import pandas
import pandas as pd
import pyarrow
Expand Down Expand Up @@ -940,12 +941,17 @@ def _init(self):
super()._init()
self._dfs = []
for path in self._paths:
kwargs = {}
if packaging.version.Version(pandas.__version__).major >= 2:
kwargs["date_format"] = self._timestamp_format
else:
kwargs["date_parser"] = self._datetime_from_timestamp
df = pandas.read_csv(
path,
header=0,
parse_dates=self._dates_indices,
date_parser=self._datetime_from_timestamp,
storage_options=self._storage_options,
**kwargs,
)
self._validate_fields(df, path)
self._dfs.append(df)
Expand Down