Skip to content

Commit 0a115d7

Browse files
committed
Added a doc-string example to clip
1 parent e377f26 commit 0a115d7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

pandas/core/generic.py

+31
Original file line numberDiff line numberDiff line change
@@ -2823,6 +2823,37 @@ def clip(self, lower=None, upper=None, out=None, axis=None):
28232823
Returns
28242824
-------
28252825
clipped : Series
2826+
2827+
Examples
2828+
--------
2829+
>>> df
2830+
0 1
2831+
0 0.335232 -1.256177
2832+
1 -1.367855 0.746646
2833+
2 0.027753 -1.176076
2834+
3 0.230930 -0.679613
2835+
4 1.261967 0.570967
2836+
>>> df.clip(-1.0, 0.5)
2837+
0 1
2838+
0 0.335232 -1.000000
2839+
1 -1.000000 0.500000
2840+
2 0.027753 -1.000000
2841+
3 0.230930 -0.679613
2842+
4 0.500000 0.500000
2843+
>>> t
2844+
0 -0.3
2845+
1 -0.2
2846+
2 -0.1
2847+
3 0.0
2848+
4 0.1
2849+
dtype: float64
2850+
>>> df.clip(t, t + 1, axis=0)
2851+
0 1
2852+
0 0.335232 -0.300000
2853+
1 -0.200000 0.746646
2854+
2 0.027753 -0.100000
2855+
3 0.230930 0.000000
2856+
4 1.100000 0.570967
28262857
"""
28272858
if out is not None: # pragma: no cover
28282859
raise Exception('out argument is not supported yet')

0 commit comments

Comments
 (0)