@@ -534,26 +534,61 @@ def sdc_fillna_overload(self, inplace=False, value=None):
534
534
535
535
dtype = self .dtype
536
536
isnan = get_isnan (dtype )
537
+
537
538
if (
538
539
(isinstance (inplace , types .Literal ) and inplace .literal_value == True ) or # noqa
539
540
(isinstance (inplace , bool ) and inplace == True ) # noqa
540
541
):
542
+
543
+ def sdc_fillna_inplace_noop (self , inplace = False , value = None ):
544
+ return None
545
+
546
+ if isinstance (value , (types .NoneType , types .Omitted )) or value is None :
547
+ return sdc_fillna_inplace_noop
548
+
541
549
if isinstance (dtype , (types .Integer , types .Boolean )):
542
- def sdc_fillna_inplace_int_impl (self , inplace = False , value = None ):
550
+ return sdc_fillna_inplace_noop
551
+
552
+ if isinstance (dtype , types .Float ):
553
+ def sdc_fillna_inplace_float_impl (self , inplace = False , value = None ):
554
+ _value = np .nan if value is None else value
555
+ length = len (self )
556
+ for i in prange (length ):
557
+ if isnan (self [i ]):
558
+ self [i ] = _value
543
559
return None
544
560
545
- return sdc_fillna_inplace_int_impl
561
+ return sdc_fillna_inplace_float_impl
546
562
547
- def sdc_fillna_inplace_float_impl (self , inplace = False , value = None ):
548
- length = len (self )
549
- for i in prange (length ):
550
- if isnan (self [i ]):
551
- self [i ] = value
563
+ if isinstance (dtype , types .UnicodeType ):
564
+ # TO-DO: not supported, since no generic setitem for StringArray
552
565
return None
553
566
554
- return sdc_fillna_inplace_float_impl
555
-
556
567
else :
568
+
569
+ def sdc_fillna_noop (self , inplace = False , value = None ):
570
+ return copy (self )
571
+
572
+ if isinstance (value , (types .NoneType , types .Omitted )) or value is None :
573
+ return sdc_fillna_noop
574
+
575
+ if isinstance (dtype , (types .Integer , types .Boolean )):
576
+ return sdc_fillna_noop
577
+
578
+ if isinstance (dtype , types .Float ):
579
+ def sdc_fillna_impl (self , inplace = False , value = None ):
580
+ _value = np .nan if value is None else value
581
+ length = len (self )
582
+ filled_data = numpy .empty (length , dtype = dtype )
583
+ for i in prange (length ):
584
+ if isnan (self [i ]):
585
+ filled_data [i ] = _value
586
+ else :
587
+ filled_data [i ] = self [i ]
588
+ return filled_data
589
+
590
+ return sdc_fillna_impl
591
+
557
592
if isinstance (self .dtype , types .UnicodeType ):
558
593
def sdc_fillna_str_impl (self , inplace = False , value = None ):
559
594
n = len (self )
@@ -562,9 +597,9 @@ def sdc_fillna_str_impl(self, inplace=False, value=None):
562
597
for i in prange (n ):
563
598
s = self [i ]
564
599
if sdc .hiframes .api .isna (self , i ):
565
- num_chars += len (value )
600
+ num_chars += get_utf8_size (value )
566
601
else :
567
- num_chars += len (s )
602
+ num_chars += get_utf8_size (s )
568
603
569
604
filled_data = pre_alloc_string_array (n , num_chars )
570
605
for i in prange (n ):
@@ -576,24 +611,6 @@ def sdc_fillna_str_impl(self, inplace=False, value=None):
576
611
577
612
return sdc_fillna_str_impl
578
613
579
- if isinstance (dtype , (types .Integer , types .Boolean )):
580
- def sdc_fillna_int_impl (self , inplace = False , value = None ):
581
- return copy (self )
582
-
583
- return sdc_fillna_int_impl
584
-
585
- def sdc_fillna_impl (self , inplace = False , value = None ):
586
- length = len (self )
587
- filled_data = numpy .empty (length , dtype = dtype )
588
- for i in prange (length ):
589
- if isnan (self [i ]):
590
- filled_data [i ] = value
591
- else :
592
- filled_data [i ] = self [i ]
593
- return filled_data
594
-
595
- return sdc_fillna_impl
596
-
597
614
598
615
def nanmin (a ):
599
616
pass
0 commit comments