Skip to content

Commit

Permalink
docs(python): Change the example to series for series/array.py
Browse files Browse the repository at this point in the history
  • Loading branch information
reswqa committed Mar 29, 2024
1 parent 9c46183 commit 44226e9
Showing 1 changed file with 21 additions and 29 deletions.
50 changes: 21 additions & 29 deletions py-polars/polars/series/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,14 @@ def sum(self) -> Series:
Examples
--------
>>> df = pl.DataFrame(
... data={"a": [[1, 2], [4, 3]]},
... schema={"a": pl.Array(pl.Int64, 2)},
... )
>>> df.select(pl.col("a").arr.sum())
shape: (2, 1)
┌─────┐
│ a │
│ --- │
│ i64 │
╞═════╡
│ 3 │
│ 7 │
└─────┘
>>> s = pl.Series([[1, 2], [4, 3]], dtype=pl.Array(pl.Int64, 2))
>>> s.arr.sum()
shape: (2,)
Series: '' [i64]
[
3
7
]
"""

def std(self, ddof: int = 1) -> Series:
Expand Down Expand Up @@ -134,23 +128,21 @@ def unique(self, *, maintain_order: bool = False) -> Series:
maintain_order
Maintain order of data. This requires more work.
Returns
-------
Series
Series of data type :class:`List`.
Examples
--------
>>> df = pl.DataFrame(
... {
... "a": [[1, 1, 2]],
... },
... schema_overrides={"a": pl.Array(pl.Int64, 3)},
... )
>>> df.select(pl.col("a").arr.unique())
shape: (1, 1)
┌───────────┐
│ a │
│ --- │
│ list[i64] │
╞═══════════╡
│ [1, 2] │
└───────────┘
>>> s = pl.Series([[1, 1, 2], [3, 4, 5]], dtype=pl.Array(pl.Int64, 3))
>>> s.arr.unique()
shape: (2,)
Series: '' [list[i64]]
[
[1, 2]
[3, 4, 5]
]
"""

def n_unique(self) -> Series:
Expand Down

0 comments on commit 44226e9

Please sign in to comment.