-
-
Notifications
You must be signed in to change notification settings - Fork 18.9k
Description
Pandas version checks
-
I have checked that this issue has not already been reported.
-
I have confirmed this bug exists on the latest version of pandas.
-
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
import pandas as pd
pd.Series().rolling(17, win_type='triang', min_periods=1, center=True).mean()
Issue Description
Before version 2.0 pandas.Series.rolling used to import windowing functions from scipy.signal
, starting from 2.0 it uses scipy.signal.windows
.
I suppose the reason is that SciPy has deprecated import of windowing function from this module since 1.13.0.
The issue is that versions of SciPy prior 1.13.0 seem to be supported by pandas and work fine.
I propose making the import to take into account the installed version of SciPy.
Something like this:
from packaging import version
scipy = import_optional_dependency("scipy", extra="Scipy is required to generate window weight.")
scipy_ver = version.parse(scipy.__version__)
signal_module = 'scipy.signal' if scipy_ver < version.Version('1.13.0') else 'scipy.signal.windows'
signal = import_optional_dependency(signal_module, extra="Scipy is required to generate window weight.")
Expected Behavior
Rolling functions work with different versions of SciPy in different versions of Pandas.
Installed Versions
pandas : 1.5.3
numpy : 1.26.4
pytz : 2024.1
dateutil : 2.9.0.post0
setuptools : 59.6.0
pip : 22.0.2
Cython : None
pytest : None
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : None
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : None
IPython : None
pandas_datareader: None
bs4 : None
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : None
numba : None
numexpr : None
odfpy : None
openpyxl : None
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.13.0
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : 2024.1