File tree 5 files changed +40
-4
lines changed
5 files changed +40
-4
lines changed Original file line number Diff line number Diff line change @@ -85,7 +85,7 @@ def frame_apply(
85
85
args = None ,
86
86
kwargs = None ,
87
87
) -> FrameApply :
88
- """construct and return a row or column based frame apply object"""
88
+ """Construct and return a row- or column- based frame apply object. """
89
89
axis = obj ._get_axis_number (axis )
90
90
klass : type [FrameApply ]
91
91
if axis == 0 :
@@ -693,7 +693,7 @@ def dtypes(self) -> Series:
693
693
return self .obj .dtypes
694
694
695
695
def apply (self ) -> DataFrame | Series :
696
- """compute the results"""
696
+ """Compute the results. """
697
697
# dispatch to agg
698
698
if is_list_like (self .f ):
699
699
return self .apply_multiple ()
@@ -1011,7 +1011,7 @@ def result_columns(self) -> Index:
1011
1011
def wrap_results_for_axis (
1012
1012
self , results : ResType , res_index : Index
1013
1013
) -> DataFrame | Series :
1014
- """return the results for the columns"""
1014
+ """Return the results for the columns. """
1015
1015
result : DataFrame | Series
1016
1016
1017
1017
# we have requested to expand
Original file line number Diff line number Diff line change 44
44
BaseMaskedArray ,
45
45
BaseMaskedDtype ,
46
46
)
47
+ from pandas .core .indexers import check_array_indexer
47
48
48
49
if TYPE_CHECKING :
49
50
import pyarrow
@@ -364,6 +365,17 @@ def map_string(s):
364
365
365
366
_HANDLED_TYPES = (np .ndarray , numbers .Number , bool , np .bool_ )
366
367
368
+ def __setitem__ (self , key , value ):
369
+ if lib .is_bool (value ):
370
+ key = check_array_indexer (self , key )
371
+ self ._data [key ] = value
372
+ self ._mask [key ] = False
373
+ elif value is libmissing .NA :
374
+ key = check_array_indexer (self , key )
375
+ self ._mask [key ] = True
376
+ else :
377
+ super ().__setitem__ (key , value )
378
+
367
379
def _coerce_to_array (self , value ) -> tuple [np .ndarray , np .ndarray ]:
368
380
return coerce_to_array (value )
369
381
Original file line number Diff line number Diff line change 39
39
NumericArray ,
40
40
NumericDtype ,
41
41
)
42
+ from pandas .core .indexers import check_array_indexer
42
43
from pandas .core .ops import invalid_comparison
43
44
from pandas .core .tools .numeric import to_numeric
44
45
@@ -275,6 +276,17 @@ def _from_sequence_of_strings(
275
276
scalars = to_numeric (strings , errors = "raise" )
276
277
return cls ._from_sequence (scalars , dtype = dtype , copy = copy )
277
278
279
+ def __setitem__ (self , key , value ):
280
+ if lib .is_float (value ):
281
+ key = check_array_indexer (self , key )
282
+ self ._data [key ] = value
283
+ self ._mask [key ] = False
284
+ elif value is libmissing .NA :
285
+ key = check_array_indexer (self , key )
286
+ self ._mask [key ] = True
287
+ else :
288
+ super ().__setitem__ (key , value )
289
+
278
290
def _coerce_to_array (self , value ) -> tuple [np .ndarray , np .ndarray ]:
279
291
return coerce_to_array (value , dtype = self .dtype )
280
292
Original file line number Diff line number Diff line change 46
46
NumericArray ,
47
47
NumericDtype ,
48
48
)
49
+ from pandas .core .indexers import check_array_indexer
49
50
from pandas .core .ops import invalid_comparison
50
51
from pandas .core .tools .numeric import to_numeric
51
52
@@ -342,6 +343,17 @@ def _from_sequence_of_strings(
342
343
scalars = to_numeric (strings , errors = "raise" )
343
344
return cls ._from_sequence (scalars , dtype = dtype , copy = copy )
344
345
346
+ def __setitem__ (self , key , value ):
347
+ if lib .is_integer (value ):
348
+ key = check_array_indexer (self , key )
349
+ self ._data [key ] = value
350
+ self ._mask [key ] = False
351
+ elif value is libmissing .NA :
352
+ key = check_array_indexer (self , key )
353
+ self ._mask [key ] = True
354
+ else :
355
+ super ().__setitem__ (key , value )
356
+
345
357
def _coerce_to_array (self , value ) -> tuple [np .ndarray , np .ndarray ]:
346
358
return coerce_to_array (value , dtype = self .dtype )
347
359
Original file line number Diff line number Diff line change 77
77
78
78
class BaseMaskedDtype (ExtensionDtype ):
79
79
"""
80
- Base class for dtypes for BasedMaskedArray subclasses.
80
+ Base class for dtypes for BaseMaskedArray subclasses.
81
81
"""
82
82
83
83
name : str
You can’t perform that action at this time.
0 commit comments