We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[DOC] Misleading docstring parameters for convert utility function of dask_to_pd and vice versa
#### Describe the issue linked to the documentation
The docstring of function `convert_dask_to_pandas` and `convert_pandas_to_dask` has been interchanged in terms of parameters and return object

```python
def convert_dask_to_pandas(obj):
    """Convert dask DataFrame to pandas DataFrame, preserving MultiIndex.

    Parameters
    ----------
    obj : pandas.DataFrame

    Returns
    -------
    dask DataFrame
        MultiIndex levels 0 .. -1 of X are converted to columns of name
        __index__[indexname], where indexname is name of multiindex level,
        or the integer index if the level has no name
        other columns and column names are identical to those of X
    """
```

Here the type of parameter for the function should be `dask.DataFrame` while the return type should be `pandas.DataFrame`. There's similar issue in the docstring of `convert_pandas_to_dask`.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sktime/datatypes/_adapter/dask_to_pd.py`
Content:
```
1 # copyright: sktime developers, BSD-3-Clause License (see LICENSE file)
2 """Converter utilities between dask and pandas, with multiindex convention.
3 
4 Converts between:
5 pd.DataFrames with ordinary (single-level) index or pd.Multiindex, and
6 dask DataFrame
7 
8 If pd.DataFrame has ordinary index, converts using dask compute/from_pandas
9 
10 if pd.DataFrame has MultiIndex, converts and back-converts
11 MultiIndex columns to DataFrame columns with the name:
12     __index__[indexname], if level has a name indexname
13     __index__[index_iloc], if level has no indexname and is index_iloc-th level
14 index is replaced by a string index where tuples are replaced with str coerced elements
15 """
16 import pandas as pd
17 
18 from sktime.datatypes._common import _req
19 from sktime.datatypes._common import _ret as ret
20 
21 
22 def _is_mi_col(x):
23     return isinstance(x, str) and x.startswith("__index__")
24 
25 
26 def get_mi_cols(obj):
27     """Get multiindex cols from a dask object.
28 
29     Parameters
30     ----------
31     obj : dask DataFrame
32 
33     Returns
34     -------
35     list of pandas index elements
36         all column index elements of obj that start with __index__
37         i.e., columns that are interpreted as multiindex columns  in the correspondence
38     """
39     return [x for x in obj.columns if _is_mi_col(x)]
40 
41 
42 def convert_dask_to_pandas(obj):
43     """Convert dask DataFrame to pandas DataFrame, preserving MultiIndex.
44 
45     Parameters
46     ----------
47     obj : pandas.DataFrame
48 
49     Returns
50     -------
51     dask DataFrame
52         MultiIndex levels 0 .. -1 of X are converted to columns of name
53         __index__[indexname], where indexname is name of multiindex level,
54         or the integer index if the level has no name
55         other columns and column names are identical to those of X
56     """
57     obj = obj.compute()
58 
59     def mi_name(x):
60         return x.split("__index__")[1]
61 
62     def mi_names(names):
63         new_names = [mi_name(x) for x in names]
64         for i, name in enumerate(new_names):
65             if name == str(i):
66                 new_names[i] = None
67         return new_names
68 
69     multi_cols = get_mi_cols(obj)
70 
71     # if has multi-index cols, move to pandas MultiIndex
72     if len(multi_cols) > 0:
73         obj = obj.set_index(multi_cols)
74 
75         names = obj.index.names
76         new_names = mi_names(names)
77         new_names = new_names
78 
79         obj.index.names = new_names
80 
81     return obj
82 
83 
84 def convert_pandas_to_dask(obj, npartitions=1, chunksize=None, sort=True):
85     """Convert pandas DataFrame to dask DataFrame, preserving MultiIndex.
86 
87     Parameters
88     ----------
89     obj : dask DataFrame
90     npartitions : int or None, optional, default = 1
91         npartitions passed to dask from_pandas when converting obj to dask
92     chunksize : int or None, optional, default = None
93         chunksize passed to dask from_pandas when converting obj to dask
94     sort : bool, optional, default = True
95         sort passed to dask from_pandas when converting obj to dask
96 
97     Returns
98     -------
99     pandas.DataFrame
100         MultiIndex levels 0 .. -1 of X are converted to columns of name
101         __index__[indexname], where indexname is name of multiindex level,
102         or the integer index if the level has no name
103         other columns and column names are identical to those of X
104     """
105     from dask.dataframe import from_pandas
106 
107     def dask_mi_names(names):
108         res = list(names).copy()
109         for i, name in enumerate(names):
110             if name is None:
111                 res[i] = str(i)
112         return [f"__index__{x}" for x in res]
113 
114     if isinstance(obj.index, pd.MultiIndex):
115         names = obj.index.names
116         new_names = dask_mi_names(names)
117         new_index = [str(x) for x in obj.index]
118 
119         obj = obj.copy()
120         obj.index.names = new_names
121         obj = obj.reset_index()
122         obj.index = new_index
123 
124     obj = from_pandas(obj, npartitions=npartitions, chunksize=chunksize, sort=sort)
125 
126     return obj
127 
128 
129 def check_dask_frame(
130     obj, return_metadata=False, var_name="obj", freq_set_check=False, scitype="Series"
131 ):
132     """Check dask frame, generic for sktime check format."""
133     import dask
134 
135     metadata = {}
136 
137     if not isinstance(obj, dask.dataframe.core.DataFrame):
138         msg = f"{var_name} must be a dask DataFrame, found {type(obj)}"
139         return ret(False, msg, None, return_metadata)
140 
141     # we now know obj is a dask DataFrame
142 
143     index_cols = get_mi_cols(obj)
144 
145     # check right number of cols depending on scitype
146     if scitype == "Series":
147         cols_msg = (
148             f"{var_name} must have exactly one index column, "
149             f"found {len(index_cols)}, namely: {index_cols}"
150         )
151         right_no_index_cols = len(index_cols) <= 1
152     elif scitype == "Panel":
153         cols_msg = (
154             f"{var_name} must have exactly two index columns, "
155             f"found {len(index_cols)}, namely: {index_cols}"
156         )
157         right_no_index_cols = len(index_cols) == 2
158     elif scitype == "Hierarchical":
159         cols_msg = (
160             f"{var_name} must have three or more index columns, "
161             f"found {len(index_cols)}, namely: {index_cols}"
162         )
163         right_no_index_cols = len(index_cols) >= 3
164     else:
165         return RuntimeError(
166             'scitype arg of check_dask_frame must be one of strings "Series", '
167             f'"Panel", or "Hierarchical", but found {scitype}'
168         )
169 
170     if not right_no_index_cols:
171         # dask series should have at most one __index__ col
172         return ret(False, cols_msg, None, return_metadata)
173 
174     if _req("is_empty", return_metadata):
175         metadata["is_empty"] = len(obj.index) < 1 or len(obj.columns) < 1
176     if _req("is_univariate", return_metadata):
177         metadata["is_univariate"] = len(obj.columns) == 1
178     if _req("n_features", return_metadata):
179         metadata["n_features"] = len(obj.columns)
180     if _req("feature_names", return_metadata):
181         metadata["feature_names"] = obj.columns.to_list()
182 
183     # check that columns are unique
184     if not obj.columns.is_unique:
185         msg = f"{var_name} must have unique column indices, but found {obj.columns}"
186         return ret(False, msg, None, return_metadata)
187 
188     # check whether the time index is of valid type
189     # if not is_in_valid_index_types(index):
190     #     msg = (
191     #         f"{type(index)} is not supported for {var_name}, use "
192     #         f"one of {VALID_INDEX_TYPES} or integer index instead."
193     #     )
194     #     return ret(False, msg, None, return_metadata)
195 
196     # Check time index is ordered in time
197     if not obj.index.is_monotonic_increasing.compute():
198         msg = (
199             f"The (time) index of {var_name} must be sorted "
200             f"monotonically increasing, but found: {obj.index}"
201         )
202         return ret(False, msg, None, return_metadata)
203 
204     if freq_set_check and isinstance(obj.index, pd.DatetimeIndex):
205         if obj.index.freq is None:
206             msg = f"{var_name} has DatetimeIndex, but no freq attribute set."
207             return ret(False, msg, None, return_metadata)
208 
209     # check whether index is equally spaced or if there are any nans
210     #   compute only if needed
211     if _req("is_equally_spaced", return_metadata):
212         # todo: logic for equal spacing
213         metadata["is_equally_spaced"] = True
214     if _req("has_nans", return_metadata):
215         metadata["has_nans"] = obj.isnull().values.any().compute()
216 
217     if scitype in ["Panel", "Hierarchical"]:
218         if _req("n_instances", return_metadata):
219             instance_cols = index_cols[:-1]
220             metadata["n_instances"] = len(obj[instance_cols].drop_duplicates())
221 
222     if scitype in ["Hierarchical"]:
223         if _req("n_panels", return_metadata):
224             panel_cols = index_cols[:-2]
225             metadata["n_panels"] = len(obj[panel_cols].drop_duplicates())
226 
227     return ret(True, None, metadata, return_metadata)
228
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sktime/datatypes/_adapter/dask_to_pd.py b/sktime/datatypes/_adapter/dask_to_pd.py
--- a/sktime/datatypes/_adapter/dask_to_pd.py
+++ b/sktime/datatypes/_adapter/dask_to_pd.py
@@ -44,11 +44,11 @@
 
     Parameters
     ----------
-    obj : pandas.DataFrame
+    obj : dask DataFrame
 
     Returns
     -------
-    dask DataFrame
+    pandas.DataFrame
         MultiIndex levels 0 .. -1 of X are converted to columns of name
         __index__[indexname], where indexname is name of multiindex level,
         or the integer index if the level has no name
@@ -86,7 +86,7 @@
 
     Parameters
     ----------
-    obj : dask DataFrame
+    obj : pandas.DataFrame
     npartitions : int or None, optional, default = 1
         npartitions passed to dask from_pandas when converting obj to dask
     chunksize : int or None, optional, default = None
@@ -96,7 +96,7 @@
 
     Returns
     -------
-    pandas.DataFrame
+    dask DataFrame
         MultiIndex levels 0 .. -1 of X are converted to columns of name
         __index__[indexname], where indexname is name of multiindex level,
         or the integer index if the level has no name

{"golden_diff": "diff --git a/sktime/datatypes/_adapter/dask_to_pd.py b/sktime/datatypes/_adapter/dask_to_pd.py\n--- a/sktime/datatypes/_adapter/dask_to_pd.py\n+++ b/sktime/datatypes/_adapter/dask_to_pd.py\n@@ -44,11 +44,11 @@\n \n     Parameters\n     ----------\n-    obj : pandas.DataFrame\n+    obj : dask DataFrame\n \n     Returns\n     -------\n-    dask DataFrame\n+    pandas.DataFrame\n         MultiIndex levels 0 .. -1 of X are converted to columns of name\n         __index__[indexname], where indexname is name of multiindex level,\n         or the integer index if the level has no name\n@@ -86,7 +86,7 @@\n \n     Parameters\n     ----------\n-    obj : dask DataFrame\n+    obj : pandas.DataFrame\n     npartitions : int or None, optional, default = 1\n         npartitions passed to dask from_pandas when converting obj to dask\n     chunksize : int or None, optional, default = None\n@@ -96,7 +96,7 @@\n \n     Returns\n     -------\n-    pandas.DataFrame\n+    dask DataFrame\n         MultiIndex levels 0 .. -1 of X are converted to columns of name\n         __index__[indexname], where indexname is name of multiindex level,\n         or the integer index if the level has no name\n", "issue": "[DOC] Misleading docstring parameters for convert utility function of dask_to_pd and vice versa\n#### Describe the issue linked to the documentation\r\nThe docstring of function `convert_dask_to_pandas` and `convert_pandas_to_dask` has been interchanged in terms of parameters and return object\r\n\r\n```python\r\ndef convert_dask_to_pandas(obj):\r\n    \"\"\"Convert dask DataFrame to pandas DataFrame, preserving MultiIndex.\r\n\r\n    Parameters\r\n    ----------\r\n    obj : pandas.DataFrame\r\n\r\n    Returns\r\n    -------\r\n    dask DataFrame\r\n        MultiIndex levels 0 .. -1 of X are converted to columns of name\r\n        __index__[indexname], where indexname is name of multiindex level,\r\n        or the integer index if the level has no name\r\n        other columns and column names are identical to those of X\r\n    \"\"\"\r\n```\r\n\r\nHere the type of parameter for the function should be `dask.DataFrame` while the return type should be `pandas.DataFrame`. There's similar issue in the docstring of `convert_pandas_to_dask`.\n", "before_files": [{"content": "# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\"\"\"Converter utilities between dask and pandas, with multiindex convention.\n\nConverts between:\npd.DataFrames with ordinary (single-level) index or pd.Multiindex, and\ndask DataFrame\n\nIf pd.DataFrame has ordinary index, converts using dask compute/from_pandas\n\nif pd.DataFrame has MultiIndex, converts and back-converts\nMultiIndex columns to DataFrame columns with the name:\n    __index__[indexname], if level has a name indexname\n    __index__[index_iloc], if level has no indexname and is index_iloc-th level\nindex is replaced by a string index where tuples are replaced with str coerced elements\n\"\"\"\nimport pandas as pd\n\nfrom sktime.datatypes._common import _req\nfrom sktime.datatypes._common import _ret as ret\n\n\ndef _is_mi_col(x):\n    return isinstance(x, str) and x.startswith(\"__index__\")\n\n\ndef get_mi_cols(obj):\n    \"\"\"Get multiindex cols from a dask object.\n\n    Parameters\n    ----------\n    obj : dask DataFrame\n\n    Returns\n    -------\n    list of pandas index elements\n        all column index elements of obj that start with __index__\n        i.e., columns that are interpreted as multiindex columns  in the correspondence\n    \"\"\"\n    return [x for x in obj.columns if _is_mi_col(x)]\n\n\ndef convert_dask_to_pandas(obj):\n    \"\"\"Convert dask DataFrame to pandas DataFrame, preserving MultiIndex.\n\n    Parameters\n    ----------\n    obj : pandas.DataFrame\n\n    Returns\n    -------\n    dask DataFrame\n        MultiIndex levels 0 .. -1 of X are converted to columns of name\n        __index__[indexname], where indexname is name of multiindex level,\n        or the integer index if the level has no name\n        other columns and column names are identical to those of X\n    \"\"\"\n    obj = obj.compute()\n\n    def mi_name(x):\n        return x.split(\"__index__\")[1]\n\n    def mi_names(names):\n        new_names = [mi_name(x) for x in names]\n        for i, name in enumerate(new_names):\n            if name == str(i):\n                new_names[i] = None\n        return new_names\n\n    multi_cols = get_mi_cols(obj)\n\n    # if has multi-index cols, move to pandas MultiIndex\n    if len(multi_cols) > 0:\n        obj = obj.set_index(multi_cols)\n\n        names = obj.index.names\n        new_names = mi_names(names)\n        new_names = new_names\n\n        obj.index.names = new_names\n\n    return obj\n\n\ndef convert_pandas_to_dask(obj, npartitions=1, chunksize=None, sort=True):\n    \"\"\"Convert pandas DataFrame to dask DataFrame, preserving MultiIndex.\n\n    Parameters\n    ----------\n    obj : dask DataFrame\n    npartitions : int or None, optional, default = 1\n        npartitions passed to dask from_pandas when converting obj to dask\n    chunksize : int or None, optional, default = None\n        chunksize passed to dask from_pandas when converting obj to dask\n    sort : bool, optional, default = True\n        sort passed to dask from_pandas when converting obj to dask\n\n    Returns\n    -------\n    pandas.DataFrame\n        MultiIndex levels 0 .. -1 of X are converted to columns of name\n        __index__[indexname], where indexname is name of multiindex level,\n        or the integer index if the level has no name\n        other columns and column names are identical to those of X\n    \"\"\"\n    from dask.dataframe import from_pandas\n\n    def dask_mi_names(names):\n        res = list(names).copy()\n        for i, name in enumerate(names):\n            if name is None:\n                res[i] = str(i)\n        return [f\"__index__{x}\" for x in res]\n\n    if isinstance(obj.index, pd.MultiIndex):\n        names = obj.index.names\n        new_names = dask_mi_names(names)\n        new_index = [str(x) for x in obj.index]\n\n        obj = obj.copy()\n        obj.index.names = new_names\n        obj = obj.reset_index()\n        obj.index = new_index\n\n    obj = from_pandas(obj, npartitions=npartitions, chunksize=chunksize, sort=sort)\n\n    return obj\n\n\ndef check_dask_frame(\n    obj, return_metadata=False, var_name=\"obj\", freq_set_check=False, scitype=\"Series\"\n):\n    \"\"\"Check dask frame, generic for sktime check format.\"\"\"\n    import dask\n\n    metadata = {}\n\n    if not isinstance(obj, dask.dataframe.core.DataFrame):\n        msg = f\"{var_name} must be a dask DataFrame, found {type(obj)}\"\n        return ret(False, msg, None, return_metadata)\n\n    # we now know obj is a dask DataFrame\n\n    index_cols = get_mi_cols(obj)\n\n    # check right number of cols depending on scitype\n    if scitype == \"Series\":\n        cols_msg = (\n            f\"{var_name} must have exactly one index column, \"\n            f\"found {len(index_cols)}, namely: {index_cols}\"\n        )\n        right_no_index_cols = len(index_cols) <= 1\n    elif scitype == \"Panel\":\n        cols_msg = (\n            f\"{var_name} must have exactly two index columns, \"\n            f\"found {len(index_cols)}, namely: {index_cols}\"\n        )\n        right_no_index_cols = len(index_cols) == 2\n    elif scitype == \"Hierarchical\":\n        cols_msg = (\n            f\"{var_name} must have three or more index columns, \"\n            f\"found {len(index_cols)}, namely: {index_cols}\"\n        )\n        right_no_index_cols = len(index_cols) >= 3\n    else:\n        return RuntimeError(\n            'scitype arg of check_dask_frame must be one of strings \"Series\", '\n            f'\"Panel\", or \"Hierarchical\", but found {scitype}'\n        )\n\n    if not right_no_index_cols:\n        # dask series should have at most one __index__ col\n        return ret(False, cols_msg, None, return_metadata)\n\n    if _req(\"is_empty\", return_metadata):\n        metadata[\"is_empty\"] = len(obj.index) < 1 or len(obj.columns) < 1\n    if _req(\"is_univariate\", return_metadata):\n        metadata[\"is_univariate\"] = len(obj.columns) == 1\n    if _req(\"n_features\", return_metadata):\n        metadata[\"n_features\"] = len(obj.columns)\n    if _req(\"feature_names\", return_metadata):\n        metadata[\"feature_names\"] = obj.columns.to_list()\n\n    # check that columns are unique\n    if not obj.columns.is_unique:\n        msg = f\"{var_name} must have unique column indices, but found {obj.columns}\"\n        return ret(False, msg, None, return_metadata)\n\n    # check whether the time index is of valid type\n    # if not is_in_valid_index_types(index):\n    #     msg = (\n    #         f\"{type(index)} is not supported for {var_name}, use \"\n    #         f\"one of {VALID_INDEX_TYPES} or integer index instead.\"\n    #     )\n    #     return ret(False, msg, None, return_metadata)\n\n    # Check time index is ordered in time\n    if not obj.index.is_monotonic_increasing.compute():\n        msg = (\n            f\"The (time) index of {var_name} must be sorted \"\n            f\"monotonically increasing, but found: {obj.index}\"\n        )\n        return ret(False, msg, None, return_metadata)\n\n    if freq_set_check and isinstance(obj.index, pd.DatetimeIndex):\n        if obj.index.freq is None:\n            msg = f\"{var_name} has DatetimeIndex, but no freq attribute set.\"\n            return ret(False, msg, None, return_metadata)\n\n    # check whether index is equally spaced or if there are any nans\n    #   compute only if needed\n    if _req(\"is_equally_spaced\", return_metadata):\n        # todo: logic for equal spacing\n        metadata[\"is_equally_spaced\"] = True\n    if _req(\"has_nans\", return_metadata):\n        metadata[\"has_nans\"] = obj.isnull().values.any().compute()\n\n    if scitype in [\"Panel\", \"Hierarchical\"]:\n        if _req(\"n_instances\", return_metadata):\n            instance_cols = index_cols[:-1]\n            metadata[\"n_instances\"] = len(obj[instance_cols].drop_duplicates())\n\n    if scitype in [\"Hierarchical\"]:\n        if _req(\"n_panels\", return_metadata):\n            panel_cols = index_cols[:-2]\n            metadata[\"n_panels\"] = len(obj[panel_cols].drop_duplicates())\n\n    return ret(True, None, metadata, return_metadata)\n", "path": "sktime/datatypes/_adapter/dask_to_pd.py"}], "after_files": [{"content": "# copyright: sktime developers, BSD-3-Clause License (see LICENSE file)\n\"\"\"Converter utilities between dask and pandas, with multiindex convention.\n\nConverts between:\npd.DataFrames with ordinary (single-level) index or pd.Multiindex, and\ndask DataFrame\n\nIf pd.DataFrame has ordinary index, converts using dask compute/from_pandas\n\nif pd.DataFrame has MultiIndex, converts and back-converts\nMultiIndex columns to DataFrame columns with the name:\n    __index__[indexname], if level has a name indexname\n    __index__[index_iloc], if level has no indexname and is index_iloc-th level\nindex is replaced by a string index where tuples are replaced with str coerced elements\n\"\"\"\nimport pandas as pd\n\nfrom sktime.datatypes._common import _req\nfrom sktime.datatypes._common import _ret as ret\n\n\ndef _is_mi_col(x):\n    return isinstance(x, str) and x.startswith(\"__index__\")\n\n\ndef get_mi_cols(obj):\n    \"\"\"Get multiindex cols from a dask object.\n\n    Parameters\n    ----------\n    obj : dask DataFrame\n\n    Returns\n    -------\n    list of pandas index elements\n        all column index elements of obj that start with __index__\n        i.e., columns that are interpreted as multiindex columns  in the correspondence\n    \"\"\"\n    return [x for x in obj.columns if _is_mi_col(x)]\n\n\ndef convert_dask_to_pandas(obj):\n    \"\"\"Convert dask DataFrame to pandas DataFrame, preserving MultiIndex.\n\n    Parameters\n    ----------\n    obj : dask DataFrame\n\n    Returns\n    -------\n    pandas.DataFrame\n        MultiIndex levels 0 .. -1 of X are converted to columns of name\n        __index__[indexname], where indexname is name of multiindex level,\n        or the integer index if the level has no name\n        other columns and column names are identical to those of X\n    \"\"\"\n    obj = obj.compute()\n\n    def mi_name(x):\n        return x.split(\"__index__\")[1]\n\n    def mi_names(names):\n        new_names = [mi_name(x) for x in names]\n        for i, name in enumerate(new_names):\n            if name == str(i):\n                new_names[i] = None\n        return new_names\n\n    multi_cols = get_mi_cols(obj)\n\n    # if has multi-index cols, move to pandas MultiIndex\n    if len(multi_cols) > 0:\n        obj = obj.set_index(multi_cols)\n\n        names = obj.index.names\n        new_names = mi_names(names)\n        new_names = new_names\n\n        obj.index.names = new_names\n\n    return obj\n\n\ndef convert_pandas_to_dask(obj, npartitions=1, chunksize=None, sort=True):\n    \"\"\"Convert pandas DataFrame to dask DataFrame, preserving MultiIndex.\n\n    Parameters\n    ----------\n    obj : pandas.DataFrame\n    npartitions : int or None, optional, default = 1\n        npartitions passed to dask from_pandas when converting obj to dask\n    chunksize : int or None, optional, default = None\n        chunksize passed to dask from_pandas when converting obj to dask\n    sort : bool, optional, default = True\n        sort passed to dask from_pandas when converting obj to dask\n\n    Returns\n    -------\n    dask DataFrame\n        MultiIndex levels 0 .. -1 of X are converted to columns of name\n        __index__[indexname], where indexname is name of multiindex level,\n        or the integer index if the level has no name\n        other columns and column names are identical to those of X\n    \"\"\"\n    from dask.dataframe import from_pandas\n\n    def dask_mi_names(names):\n        res = list(names).copy()\n        for i, name in enumerate(names):\n            if name is None:\n                res[i] = str(i)\n        return [f\"__index__{x}\" for x in res]\n\n    if isinstance(obj.index, pd.MultiIndex):\n        names = obj.index.names\n        new_names = dask_mi_names(names)\n        new_index = [str(x) for x in obj.index]\n\n        obj = obj.copy()\n        obj.index.names = new_names\n        obj = obj.reset_index()\n        obj.index = new_index\n\n    obj = from_pandas(obj, npartitions=npartitions, chunksize=chunksize, sort=sort)\n\n    return obj\n\n\ndef check_dask_frame(\n    obj, return_metadata=False, var_name=\"obj\", freq_set_check=False, scitype=\"Series\"\n):\n    \"\"\"Check dask frame, generic for sktime check format.\"\"\"\n    import dask\n\n    metadata = {}\n\n    if not isinstance(obj, dask.dataframe.core.DataFrame):\n        msg = f\"{var_name} must be a dask DataFrame, found {type(obj)}\"\n        return ret(False, msg, None, return_metadata)\n\n    # we now know obj is a dask DataFrame\n\n    index_cols = get_mi_cols(obj)\n\n    # check right number of cols depending on scitype\n    if scitype == \"Series\":\n        cols_msg = (\n            f\"{var_name} must have exactly one index column, \"\n            f\"found {len(index_cols)}, namely: {index_cols}\"\n        )\n        right_no_index_cols = len(index_cols) <= 1\n    elif scitype == \"Panel\":\n        cols_msg = (\n            f\"{var_name} must have exactly two index columns, \"\n            f\"found {len(index_cols)}, namely: {index_cols}\"\n        )\n        right_no_index_cols = len(index_cols) == 2\n    elif scitype == \"Hierarchical\":\n        cols_msg = (\n            f\"{var_name} must have three or more index columns, \"\n            f\"found {len(index_cols)}, namely: {index_cols}\"\n        )\n        right_no_index_cols = len(index_cols) >= 3\n    else:\n        return RuntimeError(\n            'scitype arg of check_dask_frame must be one of strings \"Series\", '\n            f'\"Panel\", or \"Hierarchical\", but found {scitype}'\n        )\n\n    if not right_no_index_cols:\n        # dask series should have at most one __index__ col\n        return ret(False, cols_msg, None, return_metadata)\n\n    if _req(\"is_empty\", return_metadata):\n        metadata[\"is_empty\"] = len(obj.index) < 1 or len(obj.columns) < 1\n    if _req(\"is_univariate\", return_metadata):\n        metadata[\"is_univariate\"] = len(obj.columns) == 1\n    if _req(\"n_features\", return_metadata):\n        metadata[\"n_features\"] = len(obj.columns)\n    if _req(\"feature_names\", return_metadata):\n        metadata[\"feature_names\"] = obj.columns.to_list()\n\n    # check that columns are unique\n    if not obj.columns.is_unique:\n        msg = f\"{var_name} must have unique column indices, but found {obj.columns}\"\n        return ret(False, msg, None, return_metadata)\n\n    # check whether the time index is of valid type\n    # if not is_in_valid_index_types(index):\n    #     msg = (\n    #         f\"{type(index)} is not supported for {var_name}, use \"\n    #         f\"one of {VALID_INDEX_TYPES} or integer index instead.\"\n    #     )\n    #     return ret(False, msg, None, return_metadata)\n\n    # Check time index is ordered in time\n    if not obj.index.is_monotonic_increasing.compute():\n        msg = (\n            f\"The (time) index of {var_name} must be sorted \"\n            f\"monotonically increasing, but found: {obj.index}\"\n        )\n        return ret(False, msg, None, return_metadata)\n\n    if freq_set_check and isinstance(obj.index, pd.DatetimeIndex):\n        if obj.index.freq is None:\n            msg = f\"{var_name} has DatetimeIndex, but no freq attribute set.\"\n            return ret(False, msg, None, return_metadata)\n\n    # check whether index is equally spaced or if there are any nans\n    #   compute only if needed\n    if _req(\"is_equally_spaced\", return_metadata):\n        # todo: logic for equal spacing\n        metadata[\"is_equally_spaced\"] = True\n    if _req(\"has_nans\", return_metadata):\n        metadata[\"has_nans\"] = obj.isnull().values.any().compute()\n\n    if scitype in [\"Panel\", \"Hierarchical\"]:\n        if _req(\"n_instances\", return_metadata):\n            instance_cols = index_cols[:-1]\n            metadata[\"n_instances\"] = len(obj[instance_cols].drop_duplicates())\n\n    if scitype in [\"Hierarchical\"]:\n        if _req(\"n_panels\", return_metadata):\n            panel_cols = index_cols[:-2]\n            metadata[\"n_panels\"] = len(obj[panel_cols].drop_duplicates())\n\n    return ret(True, None, metadata, return_metadata)\n", "path": "sktime/datatypes/_adapter/dask_to_pd.py"}]}