Skip to content

Short term pandas 2.0 support: avoid pandas==2.0 installation. #159

@sandervh14

Description

@sandervh14

Task Title

Task: Short term pandas 2.0 support: avoid pandas==2.0 installation.

Task Description

On installing a fresh conda environment for a cobra experiment just now, I got this error during pandas preprocessing:

File ~/.conda/envs/cobra/lib/python3.9/site-packages/cobra/preprocessing/kbins_discretizer.py:330, in KBinsDiscretizer._transform_column(self, data, column_name, bins)
    324 data.loc[:, column_name_bin] = (data[column_name_bin]
    325                                 .cat.rename_categories(bin_labels))
    327 if data[column_name_bin].isnull().sum() > 0:
    328 
    329     # Add an additional bin for missing values
--> 330     data[column_name_bin].cat.add_categories(["Missing"], inplace=True)
    332     # Replace NULL with "Missing"
    333     # Otherwise these will be ignored in groupby
    334     data[column_name_bin].fillna("Missing", inplace=True)

(...)

TypeError: add_categories() got an unexpected keyword argument 'inplace'

Pandas 2.0 removed inplace arguments: https://pandas.pydata.org/docs/dev/whatsnew/v2.0.0.html

Add in the requirements.txt and readme.md a <=2.0.0 clarification for short term support, to avoid many cobra users struggling.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions