LCA-ActivityBrowser / activity-browser

GUI for brightway2
GNU Lesser General Public License v3.0
134 stars 50 forks source link

Pandas deprecations and fixes #1128

Open marc-vdm opened 7 months ago

marc-vdm commented 7 months ago

Issue

FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use 'ser.iloc[pos]'

Happened when ds_.loc[col] = (key['database'][0], key['code'][0]) if j == 0 else key['database'][0] C:\Users\steub\miniforge3\envs\abm\lib\site-packages\activity_browser\bwutils\superstructure\dataframe.py:142

(see also #1076)

TODO:

marc-vdm commented 6 months ago

Another deprecation warning I saw in error log from a user:

<function SuperstructureManager.check_scenario_exchange_values at 0x000001C964D965E0> -- 0.10608720779418945

C:\Users\*\miniconda3\envs\ab\lib\site-packages\pandas\core\algorithms.py:1409: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.

  return arr.searchsorted(value, side=side, sorter=sorter)  # type: ignore[arg-type]

Happens during scenario import, user has pandas 2.1.1 py39h32e6231_1 conda-forge

marc-vdm commented 5 months ago

Yet another:

Updating activity in metadata: 'A2' (unit, GLO, None)('wood - BAU', '062d583ae68846fa97bb630e83575ee1')
C:\Users\meidemtvander\.conda\envs\abd\Lib\site-packages\activity_browser\ui\tables\models\inventory.py:118: FutureWarning: Downcasting behavior in `replace` is deprecated and will be removed in a future version. To retain the old behavior, explicitly call `result.infer_objects(copy=False)`. To opt-in to the future behavior, set `pd.set_option('future.no_silent_downcasting', True)`
  df.replace('', np.nan, inplace=True)

Happens when drag/dropping activity from a database to an (editable) activity

Using: pandas 2.2.0 py311hf63dbb6_0 conda-forge

marc-vdm commented 5 months ago

edit: resolved with pandas 2.2.1


Also: pandas=2.2.0 breaks the sorting we rely on in results. For now pandas is pinned <=2.1.4, see also #1218. See screenshot for expected and received orderings:

Expected: MicrosoftTeams-image (1)

Wrong order: MicrosoftTeams-image