Skip to content

Commit 58dccd3

Browse files
committed
Revert "patch ExtensionBlock fill_value, closes #27781, closes #29563 (#34158)"
This reverts commit a94b13a.
1 parent b600f8d commit 58dccd3

File tree

4 files changed

+1
-38
lines changed

4 files changed

+1
-38
lines changed

doc/source/whatsnew/v1.1.0.rst

-1
Original file line numberDiff line numberDiff line change
@@ -1130,7 +1130,6 @@ Sparse
11301130
- Creating a :class:`SparseArray` from timezone-aware dtype will issue a warning before dropping timezone information, instead of doing so silently (:issue:`32501`)
11311131
- Bug in :meth:`arrays.SparseArray.from_spmatrix` wrongly read scipy sparse matrix (:issue:`31991`)
11321132
- Bug in :meth:`Series.sum` with ``SparseArray`` raises ``TypeError`` (:issue:`25777`)
1133-
- Bug where :class:`DataFrame` containing :class:`SparseArray` filled with ``NaN`` when indexed by a list-like (:issue:`27781`, :issue:`29563`)
11341133
- The repr of :class:`SparseDtype` now includes the repr of its ``fill_value`` attribute. Previously it used ``fill_value``'s string representation (:issue:`34352`)
11351134
- Bug where empty :class:`DataFrame` could not be cast to :class:`SparseDtype` (:issue:`33113`)
11361135
- Bug in :meth:`arrays.SparseArray` was returning the incorrect type when indexing a sparse dataframe with an iterable (:issue:`34526`, :issue:`34540`)

pandas/core/internals/blocks.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -1636,10 +1636,7 @@ def _holder(self):
16361636
@property
16371637
def fill_value(self):
16381638
# Used in reindex_indexer
1639-
if is_sparse(self.values):
1640-
return self.values.dtype.fill_value
1641-
else:
1642-
return self.values.dtype.na_value
1639+
return self.values.dtype.na_value
16431640

16441641
@property
16451642
def _can_hold_na(self):

pandas/tests/extension/base/getitem.py

-28
Original file line numberDiff line numberDiff line change
@@ -399,31 +399,3 @@ def test_item(self, data):
399399

400400
with pytest.raises(ValueError, match=msg):
401401
s.item()
402-
403-
def test_boolean_mask_frame_fill_value(self, data):
404-
# https://github.com/pandas-dev/pandas/issues/27781
405-
df = pd.DataFrame({"A": data})
406-
407-
mask = np.random.choice([True, False], df.shape[0])
408-
result = pd.isna(df.iloc[mask]["A"])
409-
expected = pd.isna(df["A"].iloc[mask])
410-
self.assert_series_equal(result, expected)
411-
412-
mask = pd.Series(mask, index=df.index)
413-
result = pd.isna(df.loc[mask]["A"])
414-
expected = pd.isna(df["A"].loc[mask])
415-
self.assert_series_equal(result, expected)
416-
417-
def test_fancy_index_frame_fill_value(self, data):
418-
# https://github.com/pandas-dev/pandas/issues/29563
419-
df = pd.DataFrame({"A": data})
420-
421-
mask = np.random.choice(df.shape[0], df.shape[0])
422-
result = pd.isna(df.iloc[mask]["A"])
423-
expected = pd.isna(df["A"].iloc[mask])
424-
self.assert_series_equal(result, expected)
425-
426-
mask = pd.Series(mask, index=df.index)
427-
result = pd.isna(df.loc[mask]["A"])
428-
expected = pd.isna(df["A"].loc[mask])
429-
self.assert_series_equal(result, expected)

pandas/tests/extension/test_sparse.py

-5
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,6 @@ def data_for_twos(request):
4141
return SparseArray(np.ones(100) * 2)
4242

4343

44-
@pytest.fixture(params=[0, np.nan])
45-
def data_zeros(request):
46-
return SparseArray(np.zeros(100, dtype=int), fill_value=request.param)
47-
48-
4944
@pytest.fixture(params=[0, np.nan])
5045
def data_missing(request):
5146
"""Length 2 array with [NA, Valid]"""

0 commit comments

Comments
 (0)