Skip to content

Commit

Permalink
Fix Series.str_concat (#1785)
Browse files Browse the repository at this point in the history
  • Loading branch information
zundertj committed Nov 15, 2021
1 parent 4c4a783 commit f0c2aef
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions py-polars/polars/eager/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2967,11 +2967,12 @@ def str_concat(self, delimiter: str = "-") -> "Series": # type: ignore
Series of dtype Utf8
Examples
>>> assert pl.Series([1, None, 2]).str_concat("-")[0] == "1-null-2"
>>> pl.Series([1, None, 2]).str_concat("-")[0]
"1-null-2"
"""
return self.to_frame().select(
pl.col(self.name).delimiter(delimiter) # type: ignore
pl.col(self.name).str_concat(delimiter) # type: ignore
)[self.name]


Expand Down
5 changes: 5 additions & 0 deletions py-polars/tests/test_series.py
Original file line number Diff line number Diff line change
Expand Up @@ -744,3 +744,8 @@ def test_abs():
s = pl.Series([1, -2, 3, -4])
assert s.abs().to_list() == [1, 2, 3, 4]
assert np.abs(s).to_list() == [1, 2, 3, 4]


def test_str_concat():
s = pl.Series(["1", None, "2"])
assert s.str_concat()[0] == "1-null-2"

0 comments on commit f0c2aef

Please sign in to comment.