Repository: sktime/sktime

Issue:
[BUG] ValueError when fitting Prophet and X.index.name=='ds' 
**Describe the bug**
The following error is raised when trying to fit Prophet using X where the name of X's DateTimeIndex is named "ds":
ValueError: 'ds' is both an index level and a column label, which is ambiguous.

It happens in the _merge_X method in the _ProphetAdapter, line 193, because after running line 191, X contains a column and an index called "ds".

A suggested solution would be to add this oneliner before line 189 of .forecasting.base.adapters._fbprophet.py:
```python
X.index.name = "index"
```
Note: This assumes that X never has a MultiIndex. Not sure if that ever happens though..

This way, the user is still allowed to call X's index "ds". Since "ds" is the standard name that Prophet users use for their DateTime column, this is the most intuitive and least restrictive solution.

**To Reproduce**
```python
import pandas as pd
from sktime.datasets import load_airline
from sktime.forecasting.fbprophet import Prophet
from sktime.forecasting.model_selection import ForecastingGridSearchCV
from sktime.forecasting.model_selection import ExpandingWindowSplitter

y_train = load_airline().to_timestamp(freq='M')

# Commenting out the following line makes everything run smoothly
y_train.index.name = 'ds'

X_train = pd.DataFrame({'x1':y_train+200, 'x2':y_train+100})

forecaster = Prophet(yearly_seasonality=False, weekly_seasonality=False, daily_seasonality=False)
forecaster.fit(y_train, X_train)
```

**Expected behavior**
No error

**Additional context**


**Versions**
<details>

System:
    python: 3.9.7 | packaged by conda-forge | (default, Sep 23 2021, 07:24:41) [MSC v.1916 64 bit (AMD64)]
executable: C:\Users\............\env\python.exe
   machine: Windows-10-10.0.19043-SP0

Python dependencies:
          pip: 21.2.4
   setuptools: 58.1.0
      sklearn: 1.0
       sktime: 0.7.0
  statsmodels: 0.12.2
        numpy: 1.21.2
        scipy: 1.7.1
       Cython: 0.29.24
       pandas: 1.3.3
   matplotlib: 3.4.3
       joblib: 1.0.1
        numba: 0.53.1
     pmdarima: 1.8.3
      tsfresh: None
</details>



Discussion:
@boukepostma, thank you for bringing this to our attention, FYI @mloning, @aiwalter.

A complication is that we are potentially looking towards extensions that allow multi-index rows (FYI @ltsaprounis, @satya-pattnaik).

How about the following alternative suggestion: if an index name is passed with a `pd.DataFrame` or a `pd.Series`, we always strip it off before it reaches anything.

That would require adding a restriction to our data container specification
(see here for the input type specifications https://github.com/alan-turing-institute/sktime/blob/main/examples/AA_datatypes_and_datasets.ipynb )
which says that the "official" input specification does not have index names.

This would results in inputs being assumed without index name, and outputs having no index name.
Of course, we can provide convenience input coercion functionality, so on input no error is raised but it's instead considered as (and coerced to) the same container without the index name.

Short question @boukepostma, you say:

> Since "ds" is the standard name that Prophet users use for their DateTime column, this is the most intuitive and least restrictive solution.

Do you know why this is the convention in prophet?
E.g., do you understand what is the benefit to this?
Thank you for looking into this bug! 

One of prophet's lead developers says the following about their column naming convention:
> (...) the convenience inside the package and in the documentation for having a fixed data representation is pretty high, whereas the difficulty of converting column names to ds and y outside the package is pretty low

https://github.com/facebook/prophet/issues/1737
oh, they have the index as a data frame column? That seems like a very odd design decision, why not use the data frame index which is made just for that?

Anyway, I've also thought about that, and how about instead just removing the index (by `del` or assigning `None`)?
Otherwise you might get problems if there is another column named `index`?

Would you like to make a PR with the fix?
Sure! I hope to have time later this week.



Resolving patch:
diff --git a/sktime/utils/validation/series.py b/sktime/utils/validation/series.py
--- a/sktime/utils/validation/series.py
+++ b/sktime/utils/validation/series.py
@@ -10,8 +10,8 @@
     "check_equal_time_index",
     "check_consistent_index_type",
 ]
-import pandas as pd
 import numpy as np
+import pandas as pd
 
 # We currently support the following types for input data and time index types.
 VALID_DATA_TYPES = (pd.DataFrame, pd.Series, np.ndarray)
@@ -56,6 +56,7 @@ def check_series(
     allow_numpy=True,
     allow_None=True,
     enforce_index_type=None,
+    allow_index_names=False,
     var_name="input",
 ):
     """Validate input data to be a valid mtype for Series.
@@ -76,6 +77,8 @@ def check_series(
         whether no error is raised if Z is None
     enforce_index_type : type, default = None
         type of time index
+    allow_index_names : bool, default = False
+        If False, names of Z.index will be set to None
     var_name : str, default = "input" - variable name printed in error messages
 
     Returns
@@ -139,6 +142,9 @@ def check_series(
             var_name=var_name,
         )
 
+    if not allow_index_names and not isinstance(Z, np.ndarray):
+        Z.index.names = [None for name in Z.index.names]
+
     return Z
 
 


Test patch: