Skip to content

Commit 88f5479

Browse files
authored
Add MWE into docstring for toset. (#1037)
1 parent 75a9160 commit 88f5479

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

janitor/functions/toset.py

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Implementation of the `toset` function."""
12
from typing import Set
23
import pandas_flavor as pf
34
import pandas as pd
@@ -11,25 +12,20 @@ def toset(series: pd.Series) -> Set:
1112
(for str, int, float) or a pandas scalar
1213
(for Timestamp/Timedelta/Interval/Period)
1314
14-
Functional usage syntax:
15-
16-
17-
18-
import pandas as pd
19-
import janitor as jn
20-
21-
series = pd.Series(...)
22-
s = jn.functions.toset(series=series)
23-
24-
Method chaining usage example:
25-
26-
27-
28-
import pandas as pd
29-
import janitor
30-
31-
series = pd.Series(...)
32-
s = series.toset()
15+
Example:
16+
17+
>>> import pandas as pd
18+
>>> import janitor
19+
>>> s = pd.Series([1, 2, 3, 5, 5], index=["a", "b", "c", "d", "e"])
20+
>>> s
21+
a 1
22+
b 2
23+
c 3
24+
d 5
25+
e 5
26+
dtype: int64
27+
>>> s.toset()
28+
{1, 2, 3, 5}
3329
3430
:param series: A pandas series.
3531
:returns: A set of values.

0 commit comments

Comments
 (0)