Skip to content

Commit

Permalink
Fix date_parser deprecation warning (#478)
Browse files Browse the repository at this point in the history
  • Loading branch information
gtopper authored Dec 19, 2023
1 parent a6d37a1 commit 3677bc4
Showing 1 changed file with 7 additions and 1 deletion.
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

0 comments on commit 3677bc4

Please sign in to comment.