Commit f8301a19 authored by Levin Zimmermann's avatar Levin Zimmermann

Restricted: Allow newer pandas versions

There are newer pandas versions which still support python2. The latest
one which still supports py2 (0.24.x) has initially been released in 2019
and should therefore be quite stable and better supported. We should
therefore prepare ERP5 so that it support those newer versions.

This patch mostly fixes movements within the internal pandas structure.
The patch still supports old object locations of previous pandas versions.

/reviewed-on nexedi/erp5!1738
/reviewed-by @jerome @klaus
parent b5f3e9d8
......@@ -489,14 +489,27 @@ else:
allow_type(pd.DatetimeIndex)
allow_type(pd.MultiIndex)
allow_type(pd.Index)
allow_type(pd.indexes.range.RangeIndex)
allow_type(pd.indexes.numeric.Int64Index)
try: # for pandas >= 0.20.x
allow_type(pd.RangeIndex)
except AttributeError: # BBB for pandas < 0.20.x
allow_type(pd.indexes.range.RangeIndex)
try: # for pandas >= 0.20.x
allow_type(pd.Int64Index)
except AttributeError: # BBB for pandas < 0.20.x
allow_type(pd.indexes.numeric.Int64Index)
allow_type(pd.core.groupby.DataFrameGroupBy)
allow_type(pd.core.groupby.SeriesGroupBy)
allow_type(pd.tseries.resample.TimedeltaIndexResampler)
allow_type(pd.tseries.resample.DatetimeIndexResampler)
allow_type(pd.tseries.resample.PeriodIndexResampler)
try: # for pandas >= 0.20.x
from pandas.core.resample import (
TimedeltaIndexResampler, DatetimeIndexResampler, PeriodIndexResampler
)
except ImportError: # BBB for pandas < 0.20.x
from pandas.tseries.resample import (
TimedeltaIndexResampler, DatetimeIndexResampler, PeriodIndexResampler
)
allow_type(TimedeltaIndexResampler)
allow_type(DatetimeIndexResampler)
allow_type(PeriodIndexResampler)
allow_class(pd.DataFrame)
......@@ -517,10 +530,15 @@ else:
ContainerAssertions[pd.DataFrame] = _check_access_wrapper(
pd.DataFrame, dict.fromkeys(dataframe_black_list, restrictedMethod))
try: # for pandas >= 0.20.x
pd_DatetimeIndex = pd.DatetimeIndex
except AttributeError: # BBB for pandas < 0.20.x
pd_DatetimeIndex = pd.tseries.index.DatetimeIndex
safetype.update(dict.fromkeys((
pd.DataFrame,
pd.Series,
pd.tseries.index.DatetimeIndex,
pd_DatetimeIndex,
pd.core.indexing._iLocIndexer,
pd.core.indexing._LocIndexer,
pd.MultiIndex,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment