From 06f197ed57b2f9d40e357d535fa95112b2fca592 Mon Sep 17 00:00:00 2001 From: Kshitiz Date: Sun, 27 Aug 2023 03:54:42 +0530 Subject: [PATCH] Closes #54770 BUG: pd.SparseDtype('int', 0) == pd.SparseDtype('int', pd.NA) returns pd.NA --- pandas/core/dtypes/dtypes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pandas/core/dtypes/dtypes.py b/pandas/core/dtypes/dtypes.py index f43865465cb28..0401109375b7a 100644 --- a/pandas/core/dtypes/dtypes.py +++ b/pandas/core/dtypes/dtypes.py @@ -1686,7 +1686,7 @@ def __eq__(self, other: object) -> bool: if isinstance(other, type(self)): subtype = self.subtype == other.subtype - if self._is_na_fill_value: + if self._is_na_fill_value or other._is_na_fill_value: # this case is complicated by two things: # SparseDtype(float, float(nan)) == SparseDtype(float, np.nan) # SparseDtype(float, np.nan) != SparseDtype(float, pd.NaT)