Skip to content

Commit

Permalink
Precommit done
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrocariellof committed Jul 1, 2024
1 parent 096cfaa commit 972d87e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 14 deletions.
7 changes: 3 additions & 4 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import warnings

import numpy as np
import numba

from pandas._libs import (
lib,
Expand Down Expand Up @@ -5424,14 +5423,14 @@ def isnull(self) -> Series:
"""
return super().isnull()

def isconstant(self, dropna = False):
def isconstant(self, dropna=False):
"""
Return if the series has constant values.
Parameters
----------
dropna : bool, default False
If True, NaN values will be ignored. If False, NaN values will be considered
If True, NaN values will be ignored. If False, NaN values will be considered
in the determination of whether the series has constant values.
Returns
Expand Down Expand Up @@ -5462,7 +5461,7 @@ def isconstant(self, dropna = False):
v = remove_na_arraylike(v)
if v.shape[0] == 0 or not notna(v).any():
return True
return (v[0] == v).all()
return (v[0] == v).all()

# error: Cannot determine type of 'notna'
@doc(NDFrame.notna, klass=_shared_doc_kwargs["klass"]) # type: ignore[has-type]
Expand Down
18 changes: 8 additions & 10 deletions pandas/tests/series/methods/test_isconstant.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import numpy as np
import pytest

from pandas import (
Series,
)
from pandas import Series


class TestSeriesIsConstant:
def test_isconstant(self):
Expand All @@ -28,11 +26,11 @@ def test_isconstant_with_nan(self):
result = s.isconstant()
assert result

s = Series([np.nan,np.nan])
s = Series([np.nan, np.nan])
result = s.isconstant()
assert result

s = Series([np.nan,1])
s = Series([np.nan, 1])
result = s.isconstant()
assert not result

Expand All @@ -45,11 +43,11 @@ def test_isconstant_with_nan_dropna(self):
result = s.isconstant(True)
assert result

s = Series([np.nan,np.nan])
s = Series([np.nan, np.nan])
result = s.isconstant(True)
assert result

s = Series([np.nan,1])
s = Series([np.nan, 1])
result = s.isconstant(True)
assert result

Expand All @@ -58,10 +56,10 @@ def test_isconstant_with_nan_dropna(self):
assert result

def test_isconstant_mixed_types(self):
s = Series([2, '2', 2])
s = Series([2, "2", 2])
result = s.isconstant()
assert not result

s = Series([2, 2.0, 2])
result = s.isconstant()
assert result
assert result

0 comments on commit 972d87e

Please sign in to comment.