Repository: mlflow/mlflow

Issue:
[BUG] `TypeError: describe() got an unexpected keyword argument 'datetime_is_numeric'` in pandas 2.0.0rc0
### Issues Policy acknowledgement

- [X] I have read and agree to submit bug reports in accordance with the [issues policy](https://www.github.com/mlflow/mlflow/blob/master/ISSUE_POLICY.md)

### Willingness to contribute

No. I cannot contribute a bug fix at this time.

### MLflow version

- Client: 2.1.1
- Tracking server: 2.1.1


### System information

- **OS Platform and Distribution (e.g., Linux Ubuntu 16.04)**:
- **Python version**:
- **yarn version, if running the dev UI**:


### Describe the problem

`datetime_is_numeric` for `pandas.DataFrame.describe` has been removed in pandas 2.0.0rc0. MLflow needs to avoid using the argument if pandas >= 2.0.0 is installed.

### Tracking information

_No response_

### Code to reproduce issue

<!-- PLEASE KEEP BACKTICKS AND CHECK PREVIEW -->
```
pandas_dataframe.describe(datetime_is_numeric=True)
```


### Stack trace

```
mlflow.exceptions.MlflowException: Failed to run step 'register' of recipe 'regression'. An error was encountered while running step 'ingest': Traceback (most recent call last):
  File "/home/runner/work/mlflow/mlflow/mlflow/recipes/step.py", line 139, in run
    self.step_card = self._run(output_directory=output_directory)
  File "/home/runner/work/mlflow/mlflow/mlflow/recipes/steps/ingest/__init__.py", line 112, in _run
    ingested_dataset_profile = get_pandas_data_profiles(
  File "/home/runner/work/mlflow/mlflow/mlflow/recipes/utils/step.py", line 129, in get_pandas_data_profiles
    return pandas_renderer.get_html(truncated_input)
  File "/home/runner/work/mlflow/mlflow/mlflow/recipes/cards/pandas_renderer.py", line 278, in get_html
    proto = convert_to_comparison_proto(inputs)
  File "/home/runner/work/mlflow/mlflow/mlflow/recipes/cards/pandas_renderer.py", line 209, in convert_to_comparison_proto
    proto = convert_to_dataset_feature_statistics(df)
  File "/home/runner/work/mlflow/mlflow/mlflow/recipes/cards/pandas_renderer.py", line 93, in convert_to_dataset_feature_statistics
    pandas_describe = df.describe(datetime_is_numeric=True, include="all")
TypeError: describe() got an unexpected keyword argument 'datetime_is_numeric'
```

### Other info / logs

<!-- PLEASE KEEP BACKTICKS AND CHECK PREVIEW -->
```
REPLACE_ME
```


### What component(s) does this bug affect?

- [ ] `area/artifacts`: Artifact stores and artifact logging
- [ ] `area/build`: Build and test infrastructure for MLflow
- [ ] `area/docs`: MLflow documentation pages
- [ ] `area/examples`: Example code
- [ ] `area/model-registry`: Model Registry service, APIs, and the fluent client calls for Model Registry
- [ ] `area/models`: MLmodel format, model serialization/deserialization, flavors
- [X] `area/recipes`: Recipes, Recipe APIs, Recipe configs, Recipe Templates
- [ ] `area/projects`: MLproject format, project running backends
- [ ] `area/scoring`: MLflow Model server, model deployment tools, Spark UDFs
- [ ] `area/server-infra`: MLflow Tracking server backend
- [ ] `area/tracking`: Tracking Service, tracking client APIs, autologging

### What interface(s) does this bug affect?

- [ ] `area/uiux`: Front-end, user experience, plotting, JavaScript, JavaScript dev server
- [ ] `area/docker`: Docker use across MLflow's components, such as MLflow Projects and MLflow Models
- [ ] `area/sqlalchemy`: Use of SQLAlchemy in the Tracking Service or Model Registry
- [ ] `area/windows`: Windows support

### What language(s) does this bug affect?

- [ ] `language/r`: R APIs and clients
- [ ] `language/java`: Java APIs and clients
- [ ] `language/new`: Proposals for new client languages

### What integration(s) does this bug affect?

- [ ] `integrations/azure`: Azure and Azure ML integrations
- [ ] `integrations/sagemaker`: SageMaker integrations
- [ ] `integrations/databricks`: Databricks integrations


Discussion:
The lines that need to be fixed:

https://github.com/mlflow/mlflow/blob/9d5024b5dbbc559fd45293729794acbfec3f7967/mlflow/recipes/cards/pandas_renderer.py#L93

https://github.com/mlflow/mlflow/blob/9d5024b5dbbc559fd45293729794acbfec3f7967/mlflow/recipes/cards/pandas_renderer.py#L120
I think the following change should work:

```diff
diff --git a/mlflow/recipes/cards/pandas_renderer.py b/mlflow/recipes/cards/pandas_renderer.py
index 68f961bb9..dbd67bb4e 100644
--- a/mlflow/recipes/cards/pandas_renderer.py
+++ b/mlflow/recipes/cards/pandas_renderer.py
@@ -5,6 +5,7 @@ import base64
 import numpy as np
 import pandas as pd
 import sys
+from packaging.version import Version
 
 from typing import Union, Iterable, Tuple
 from mlflow.protos import facet_feature_statistics_pb2
@@ -116,9 +117,12 @@ def convert_to_dataset_feature_statistics(
             if converter:
                 date_time_converted = converter(current_column_value)
                 current_column_value = pd.DataFrame(date_time_converted)[0]
-                pandas_describe_key = current_column_value.describe(
-                    datetime_is_numeric=True, include="all"
+                kwargs = (
+                    {}
+                    if Version(pd.__version__) > Version("1.5")
+                    else {"datetime_is_numeric": True}
                 )
+                pandas_describe_key = current_column_value.describe(include="all", **kwargs)
                 quantiles[key] = current_column_value.quantile(quantiles_to_get)
 
             default_value = 0
```

Resolving patch:
diff --git a/mlflow/recipes/cards/pandas_renderer.py b/mlflow/recipes/cards/pandas_renderer.py
--- a/mlflow/recipes/cards/pandas_renderer.py
+++ b/mlflow/recipes/cards/pandas_renderer.py
@@ -5,6 +5,7 @@
 import numpy as np
 import pandas as pd
 import sys
+from packaging.version import Version
 
 from typing import Union, Iterable, Tuple
 from mlflow.protos import facet_feature_statistics_pb2
@@ -90,7 +91,8 @@ def convert_to_dataset_feature_statistics(
     fs_proto = facet_feature_statistics_pb2.FeatureNameStatistics
     feature_stats = facet_feature_statistics_pb2.DatasetFeatureStatistics()
     data_type_custom_stat = facet_feature_statistics_pb2.CustomStatistic()
-    pandas_describe = df.describe(datetime_is_numeric=True, include="all")
+    kwargs = {} if Version(pd.__version__) >= Version("2.0.0rc0") else {"datetime_is_numeric": True}
+    pandas_describe = df.describe(include="all", **kwargs)
     feature_stats.num_examples = len(df)
     quantiles_to_get = [x * 10 / 100 for x in range(10 + 1)]
     try:
@@ -116,9 +118,12 @@ def convert_to_dataset_feature_statistics(
             if converter:
                 date_time_converted = converter(current_column_value)
                 current_column_value = pd.DataFrame(date_time_converted)[0]
-                pandas_describe_key = current_column_value.describe(
-                    datetime_is_numeric=True, include="all"
+                kwargs = (
+                    {}
+                    if Version(pd.__version__) >= Version("2.0.0rc0")
+                    else {"datetime_is_numeric": True}
                 )
+                pandas_describe_key = current_column_value.describe(include="all", **kwargs)
                 quantiles[key] = current_column_value.quantile(quantiles_to_get)
 
             default_value = 0


Test patch: