Repository: dask/dask

Issue:
`.str.split(..., expand=True)` with `Int64Index` triggers pandas FutureWarning
<!-- Please include a self-contained copy-pastable example that generates the issue if possible.

Please be concise with code posted. See guidelines below on how to provide a good bug report:

- Craft Minimal Bug Reports http://matthewrocklin.com/blog/work/2018/02/28/minimal-bug-reports
- Minimal Complete Verifiable Examples https://stackoverflow.com/help/mcve

Bug reports that follow these guidelines are easier to diagnose, and so are often handled much more quickly.
-->

**Describe the issue**:

When using `.str.split(..., expand=True)` on a ddf (meta) with a non-RangeIndex, a pandas 1.5+ FutureWarning is raised regarding series slicing with integers changing to be label-based.

**Minimal Complete Verifiable Example**:

```python
[ins] In [1]: import dask.dataframe as dd
         ...: import pandas as pd

[ins] In [2]: df = pd.DataFrame({"a": ["a\nb"]})
         ...: ddf = dd.from_pandas(df, npartitions=1)

[ins] In [3]: df["a"].str.split("\n", n=1, expand=True)
Out[3]:
   0  1
0  a  b

[ins] In [4]: ddf["a"].str.split("\n", n=1, expand=True)
Out[4]:
Dask DataFrame Structure:
                    0       1
npartitions=1
0              object  object
0                 ...     ...
Dask Name: str-split, 3 graph layers

[ins] In [5]:

[ins] In [5]: # a non-RangeIndex seems triggers a warning
         ...: df = pd.DataFrame({"a": ["a\nb"]}, index=[0])
         ...: ddf = dd.from_pandas(df, npartitions=1)

[ins] In [6]: df["a"].str.split("\n", n=1, expand=True)
Out[6]:
   0  1
0  a  b

[ins] In [7]: ddf["a"].str.split("\n", n=1, expand=True)
/Users/jacobhayes/.virtualenvs/dyno_parsing-ba1482f5-py3.10.2/lib/python3.10/site-packages/dask/dataframe/accessor.py:268: FutureWarning: The behavior of `series[i:j]` with an integer-dtype index is deprecated. In a future version, this will be treated as *label-based* indexing, consistent with e.g. `series[i]` lookups. To retain the old behavior, use `series.iloc[i:j]`. To get the future behavior, use `series.loc[i:j]`.
  index=self._series._meta_nonempty[:1].index,
Out[7]:
Dask DataFrame Structure:
                    0       1
npartitions=1
0              object  object
0                 ...     ...
Dask Name: str-split, 3 graph layers
```

**Anything else we need to know?**:

**Environment**:

- Dask version: 2022.11.1
- Python version: 3.10.2
- Operating System: mac
- Install method (conda, pip, source): pip



Discussion:

Resolving patch:
diff --git a/dask/dataframe/accessor.py b/dask/dataframe/accessor.py
--- a/dask/dataframe/accessor.py
+++ b/dask/dataframe/accessor.py
@@ -265,7 +265,7 @@ def _split(self, method, pat=None, n=-1, expand=False):
                 delimiter = " " if pat is None else pat
                 meta = self._series._meta._constructor(
                     [delimiter.join(["a"] * (n + 1))],
-                    index=self._series._meta_nonempty[:1].index,
+                    index=self._series._meta_nonempty.iloc[:1].index,
                 )
                 meta = getattr(meta.str, method)(n=n, expand=expand, pat=pat)
         else:


Test patch:
diff --git a/dask/dataframe/tests/test_accessors.py b/dask/dataframe/tests/test_accessors.py
--- a/dask/dataframe/tests/test_accessors.py
+++ b/dask/dataframe/tests/test_accessors.py
@@ -294,6 +294,17 @@ def test_str_accessor_split_expand_more_columns():
     ds.str.split(n=10, expand=True).compute()
 
 
+@pytest.mark.parametrize("index", [None, [0]], ids=["range_index", "other index"])
+def test_str_split_no_warning(index):
+    df = pd.DataFrame({"a": ["a\nb"]}, index=index)
+    ddf = dd.from_pandas(df, npartitions=1)
+
+    pd_a = df["a"].str.split("\n", n=1, expand=True)
+    dd_a = ddf["a"].str.split("\n", n=1, expand=True)
+
+    assert_eq(dd_a, pd_a)
+
+
 def test_string_nullable_types(df_ddf):
     df, ddf = df_ddf
     assert_eq(ddf.string_col.str.count("A"), df.string_col.str.count("A"))