gjoseph92 / stackstac

Turn a STAC catalog into a dask-based xarray
https://stackstac.readthedocs.io
MIT License
240 stars 49 forks source link

The argument 'infer_datetime_format' is deprecated #259

Closed BasileGoussard closed 1 month ago

BasileGoussard commented 1 month ago

The Pandas update has led to the deprecation of infer_datetime_format.
Reference (18 September 2022).

I used stackstac 0.4.4.

(I encountered some troubleshooting issues when using more recent versions of stackstac related to the errors_as_nodata=(RasterioIOError(".*"),), in stackstac.stack.)
I'm using Pandas 2.2.2, so I received the following message:

/Users/basilegoussard/Desktop/Software/miniconda3/envs/datafactory-poetry/lib/python3.10/site-packages/stackstac/prepare.py:364: UserWarning: The argument 'infer_datetime_format' is deprecated and will be removed in a future version. A strict version of it is now the default, see https://pandas.pydata.org/pdeps/0004-consistent-to-datetime-parsing.html. You can safely remove this argument.
  times = pd.to_datetime(

I can easily bypass the warning by commenting out the line in stackstac/prepare.py:364:

def to_coords(
    items: ItemSequence,
    asset_ids: List[str],
    spec: RasterSpec,
    xy_coords: Literal["center", "topleft", False] = "topleft",
    properties: Union[bool, str, Sequence[str]] = True,
    band_coords: bool = True,
) -> Tuple[Dict[str, Union[pd.Index, np.ndarray, list]], List[str]]:

    times = pd.to_datetime(
        [item["properties"]["datetime"] for item in items],
        # infer_datetime_format=True,
        errors="coerce",
    )
gjoseph92 commented 1 month ago

Duplicate of https://github.com/gjoseph92/stackstac/issues/213, which should be fixed in the latest release.