Skip to content

Commit fd8e7bc

Browse files
committed
updates
2 parents 5b3f562 + facb52c commit fd8e7bc

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,3 +101,4 @@ Contributors
101101
- `@MollyCroke <https://github.com/MollyCroke>`_ | `contributions <https://github.com/pyjanitor-devs/pyjanitor/issues?q=is%3Aclosed+mentions%3AMollyCroke>`_
102102
- `@ericclessantostv <https://github.com/ericlessantostv>`_ | `contributions <https://github.com/pyjanitor-devs/pyjanitor/issues?q=is%3Aclosed+mentions%3Aericclessantostv>`_
103103
- `@fireddd <https://github.com/fireddd>`_ | `contributions <https://github.com/pyjanitor-devs/pyjanitor/issues?q=is%3Aclosed+mentions%3Afireddd>`_
104+
- `@Zeroto521 <https://github.com/Zeroto521>`_ | `contributions <https://github.com/pyjanitor-devs/pyjanitor/pulls?utf8=%E2%9C%93&q=is%3Aclosed+mentions%3Zeroto521>`_

CHANGELOG.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Changelog
22

33
## [Unreleased]
4+
45
- [DOC] Fix references and broken links in AUTHORS.rst. @loganthomas
56
- [DOC] Updated Broken links in the README and contributing docs. @nvamsikrishna05
67
- [INF] Update pre-commit hooks and remove mutable references. Issue #844. @loganthomas
@@ -14,11 +15,9 @@
1415
- [DOC] Delete Read the Docs project and remove all readthedocs.io references from the repo. Issue #863. @loganthomas
1516
- [DOC] Updated various documentation sources to reflect pyjanitor-dev ownership. @loganthomas
1617
- [INF] Fix `isort` automatic checks. Issue #845. @loganthomas
17-
<<<<<<< HEAD
1818
- [ENH] `complete` function now uses variable args (*args) - @samukweku
19-
=======
19+
- [EHN] Set `expand_column`'s `sep` default is `"|"`, same to `pandas.Series.str.get_dummies`. Issue #876. @Zeroto521
2020
- [ENH] Deprecate `limit` from fill_direction. fill_direction now uses kwargs. @samukweku
21-
>>>>>>> 37af6a69d9590c2f4115ecff3d108eb0ed051436
2221

2322
## [v0.21.0] - 2021-07-16
2423

janitor/functions.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,7 +1292,10 @@ def _fill_empty(df, column_names, value=None): # noqa: F811
12921292
@pf.register_dataframe_method
12931293
@deprecated_alias(column="column_name")
12941294
def expand_column(
1295-
df: pd.DataFrame, column_name: Hashable, sep: str, concat: bool = True
1295+
df: pd.DataFrame,
1296+
column_name: Hashable,
1297+
sep: str = "|",
1298+
concat: bool = True,
12961299
) -> pd.DataFrame:
12971300
"""Expand a categorical column with multiple labels into dummy-coded columns.
12981301
@@ -1319,7 +1322,8 @@ def expand_column(
13191322
13201323
:param df: A pandas DataFrame.
13211324
:param column_name: Which column to expand.
1322-
:param sep: The delimiter. Example delimiters include `|`, `, `, `,` etc.
1325+
:param sep: The delimiter, same to
1326+
:py:meth:`~pandas.Series.str.get_dummies`'s `sep`, default as `|`.
13231327
:param concat: Whether to return the expanded column concatenated to
13241328
the original dataframe (`concat=True`), or to return it standalone
13251329
(`concat=False`).

tests/functions/test_expand_column.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,17 @@ def test_expand_and_concat():
2525
column_name="col1", sep=", ", concat=True
2626
)
2727
assert df.shape[1] == 8
28+
29+
30+
@pytest.mark.functions
31+
def test_sep_default_parameter():
32+
"""Test that the default parameter is a pipe character `|`."""
33+
df = pd.DataFrame(
34+
{
35+
"col1": ["A|B", "B|C|D", "E|F", "A|E|F"],
36+
"col2": [1, 2, 3, 4],
37+
}
38+
)
39+
result = df.expand_column("col1")
40+
41+
assert result.shape[1] == 8

0 commit comments

Comments
 (0)