Skip to content

Commit

Permalink
docs(python): add example for arr.count_match() (pola-rs#7029)
Browse files Browse the repository at this point in the history
  • Loading branch information
moritzwilksch authored and josemasar committed Feb 21, 2023
1 parent 7081c91 commit d112ee9
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions py-polars/polars/internals/expr/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,23 @@ def count_match(
element
An expression that produces a single value
Examples
--------
>>> df = pl.DataFrame({"listcol": [[0], [1], [1, 2, 3, 2], [1, 2, 1], [4, 4]]})
>>> df.select(pl.col("listcol").arr.count_match(2).alias("number_of_twos"))
shape: (5, 1)
┌────────────────┐
│ number_of_twos │
│ --- │
│ u32 │
╞════════════════╡
│ 0 │
│ 0 │
│ 2 │
│ 1 │
│ 0 │
└────────────────┘
"""

return pli.wrap_expr(
Expand Down

0 comments on commit d112ee9

Please sign in to comment.