File tree Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Expand file tree Collapse file tree 3 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1004,7 +1004,7 @@ Reshaping
1004
1004
Sparse
1005
1005
^^^^^^
1006
1006
- Bug in :class: `SparseDataFrame ` arithmetic operations incorrectly casting inputs to float (:issue: `28107 `)
1007
- -
1007
+ - Bug in `` DataFrame.sparse `` returning a `` Series `` when there was a column named `` sparse `` rather than the accessor ( :issue: ` 30758 `)
1008
1008
-
1009
1009
1010
1010
ExtensionArray
Original file line number Diff line number Diff line change @@ -402,7 +402,7 @@ def _constructor(self) -> Type["DataFrame"]:
402
402
403
403
_constructor_sliced : Type [Series ] = Series
404
404
_deprecations : FrozenSet [str ] = NDFrame ._deprecations | frozenset ([])
405
- _accessors : Set [str ] = set ()
405
+ _accessors : Set [str ] = { "sparse" }
406
406
407
407
@property
408
408
def _constructor_expanddim (self ):
Original file line number Diff line number Diff line change @@ -116,3 +116,8 @@ def test_series_from_coo_incorrect_format_raises(self):
116
116
TypeError , match = "Expected coo_matrix. Got csr_matrix instead."
117
117
):
118
118
pd .Series .sparse .from_coo (m )
119
+
120
+ def test_with_column_named_sparse (self ):
121
+ # https://github.com/pandas-dev/pandas/issues/30758
122
+ df = pd .DataFrame ({"sparse" : pd .arrays .SparseArray ([1 , 2 ])})
123
+ assert isinstance (df .sparse , pd .core .arrays .sparse .accessor .SparseFrameAccessor )
You can’t perform that action at this time.
0 commit comments