Repository: pyjanitor-devs/pyjanitor

Issue:
[ENH] `expand_column` function should set `sep` default is `|`
# Brief Description

<!-- Please provide a brief description of what you'd like to propose. -->

Compare to `pandas.Series.str.get_dummies` and `janitor.expand_column` definition.

```python
    def expand_column(
        df: pd.DataFrame, column_name: Hashable, sep: str, concat: bool = True
    ) -> pd.DataFrame:
```

https://github.com/pandas-dev/pandas/blob/5f648bf1706dd75a9ca0d29f26eadfbb595fe52b/pandas/core/strings/accessor.py#L1971

```python
    def get_dummies(self, sep="|"):
```

`get_dummies`'s `sep` parameter default is `|`.
`expand_column`'s `sep` parameter requires the user to input.
And `expand_column` is a sugary syntax of `get_dummies`.

I always forget to add sep when I use this function.  So the result would get a `TypeError`: missing 'sep'.
Why not set `sep` to `|`, same parameter to `get_dummies`?

# Example API

<!-- One of the selling points of pyjanitor is the API. Hence, we guard the API very carefully, and want to
make sure that it is accessible and understandable to many people. Please provide a few examples of what the API
of the new function you're proposing will look like. We have provided an example that you should modify. -->

From

```python
    def expand_column(
        df: pd.DataFrame, column_name: Hashable, sep: str, concat: bool = True
    ) -> pd.DataFrame:
```

to

```python
    def expand_column(
        df: pd.DataFrame,
        column_name: Hashable,
        sep: str = "|",
        concat: bool = True,
    ) -> pd.DataFrame:
```


Discussion:
Not a bad idea @Zeroto521. Let's wait for others to chime in. You could also create a PR for this


Resolving patch:
diff --git a/janitor/functions.py b/janitor/functions.py
--- a/janitor/functions.py
+++ b/janitor/functions.py
@@ -1292,7 +1292,10 @@ def _fill_empty(df, column_names, value=None):  # noqa: F811
 @pf.register_dataframe_method
 @deprecated_alias(column="column_name")
 def expand_column(
-    df: pd.DataFrame, column_name: Hashable, sep: str, concat: bool = True
+    df: pd.DataFrame,
+    column_name: Hashable,
+    sep: str = "|",
+    concat: bool = True,
 ) -> pd.DataFrame:
     """Expand a categorical column with multiple labels into dummy-coded columns.
 
@@ -1319,7 +1322,8 @@ def expand_column(
 
     :param df: A pandas DataFrame.
     :param column_name: Which column to expand.
-    :param sep: The delimiter. Example delimiters include `|`, `, `, `,` etc.
+    :param sep: The delimiter, same to
+        :py:meth:`~pandas.Series.str.get_dummies`'s `sep`, default as `|`.
     :param concat: Whether to return the expanded column concatenated to
         the original dataframe (`concat=True`), or to return it standalone
         (`concat=False`).


Test patch:
diff --git a/tests/functions/test_expand_column.py b/tests/functions/test_expand_column.py
--- a/tests/functions/test_expand_column.py
+++ b/tests/functions/test_expand_column.py
@@ -25,3 +25,17 @@ def test_expand_and_concat():
         column_name="col1", sep=", ", concat=True
     )
     assert df.shape[1] == 8
+
+
+@pytest.mark.functions
+def test_sep_default_parameter():
+    """Test that the default parameter is a pipe character `|`."""
+    df = pd.DataFrame(
+        {
+            "col1": ["A|B", "B|C|D", "E|F", "A|E|F"],
+            "col2": [1, 2, 3, 4],
+        }
+    )
+    result = df.expand_column("col1")
+
+    assert result.shape[1] == 8