Skip to content

Commit 1a5c813

Browse files
committed
Improve comments, replace np.isscalar with lib.isscalar, and fix file modes
1 parent 549f672 commit 1a5c813

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

pandas/core/generic.py

100755100644
+4-4
Original file line numberDiff line numberDiff line change
@@ -2809,7 +2809,7 @@ def clip(self, lower=None, upper=None, out=None, axis=None):
28092809
----------
28102810
lower : float or array_like, default None
28112811
upper : float or array_like, default None
2812-
axis : int, optional
2812+
axis : int or string axis name, optional
28132813
Align object with lower and upper along the given axis.
28142814
28152815
Returns
@@ -2821,7 +2821,7 @@ def clip(self, lower=None, upper=None, out=None, axis=None):
28212821

28222822
# GH 2747 (arguments were reversed)
28232823
if lower is not None and upper is not None:
2824-
if np.isscalar(lower) and np.isscalar(upper):
2824+
if lib.isscalar(lower) and lib.isscalar(upper):
28252825
lower, upper = min(lower, upper), max(lower, upper)
28262826

28272827
result = self
@@ -2839,7 +2839,7 @@ def clip_upper(self, threshold, axis=None):
28392839
Parameters
28402840
----------
28412841
threshold : float or array_like
2842-
axis : int, optional
2842+
axis : int or string axis name, optional
28432843
Align object with threshold along the given axis.
28442844
28452845
See also
@@ -2867,7 +2867,7 @@ def clip_lower(self, threshold, axis=None):
28672867
Parameters
28682868
----------
28692869
threshold : float or array_like
2870-
axis : int, optional
2870+
axis : int or string axis name, optional
28712871
Align object with threshold along the given axis.
28722872
28732873
See also

pandas/tests/test_frame.py

100755100644
+2
Original file line numberDiff line numberDiff line change
@@ -11254,6 +11254,8 @@ def test_dataframe_clip(self):
1125411254
self.assertTrue((clipped_df.values[mask] == df.values[mask]).all() == True)
1125511255

1125611256
def test_clip_against_series(self):
11257+
# GH #6966
11258+
1125711259
df = DataFrame(np.random.randn(1000, 2))
1125811260
lb = Series(np.random.randn(1000))
1125911261
ub = lb + 1

pandas/tests/test_series.py

100755100644
+2
Original file line numberDiff line numberDiff line change
@@ -4885,6 +4885,8 @@ def test_clip_types_and_nulls(self):
48854885
self.assertEqual(list(isnull(s)), list(isnull(u)))
48864886

48874887
def test_clip_against_series(self):
4888+
# GH #6966
4889+
48884890
s = Series([1.0, 1.0, 4.0])
48894891
threshold = Series([1.0, 2.0, 3.0])
48904892

0 commit comments

Comments
 (0)