Skip to content

Commit 18eee84

Browse files
committed
implement only for float for now, check perf
1 parent 55ca1f1 commit 18eee84

File tree

1 file changed

+17
-6
lines changed

1 file changed

+17
-6
lines changed

pandas/_libs/algos.pyx

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
# cython: profile=True
12
import cython
23
from cython import Py_ssize_t
34

@@ -52,6 +53,10 @@ from pandas._libs.khash cimport (
5253
kh_resize_int64,
5354
khiter_t,
5455
)
56+
from pandas._libs.missing cimport (
57+
checknull,
58+
checknull_old,
59+
)
5560
from pandas._libs.util cimport (
5661
get_nat,
5762
numeric,
@@ -847,7 +852,7 @@ ctypedef fused fillna_t:
847852
@cython.boundscheck(False)
848853
@cython.wraparound(False)
849854
def fillna1d(fillna_t[:] arr,
850-
object value,
855+
fillna_t value,
851856
limit=None,
852857
bint inf_as_na=False
853858
) -> ndarray:
@@ -881,15 +886,21 @@ def fillna1d(fillna_t[:] arr,
881886

882887
N = len(arr)
883888
lim = validate_limit(N, limit)
889+
# if fillna_t == float32_t:#or fillna_t is float64_t:
890+
# check_func = util.is_nan
891+
# else:
884892
if inf_as_na:
885-
check_func = missing.checknull_old
893+
check_func = checknull_old
886894
else:
887-
check_func = missing.checknull
895+
check_func = checknull
888896
for i in range(N):
889897
val = arr[i]
890-
if check_func(val) and count < lim:
898+
if val != val and count < lim:
891899
arr[i] = value
892900
count+=1
901+
# if check_func(val) and count < lim:
902+
# arr[i] = value
903+
# count+=1
893904

894905

895906
@cython.boundscheck(False)
@@ -930,9 +941,9 @@ def fillna2d(fillna_t[:, :] arr,
930941
n, m = (<object>arr).shape
931942
lim = validate_limit(m, limit)
932943
if inf_as_na:
933-
check_func = missing.checknull_old
944+
check_func = checknull_old
934945
else:
935-
check_func = missing.checknull
946+
check_func = checknull
936947
for i in range(n):
937948
count = 0 # Limit is per axis
938949
for j in range(m):

0 commit comments

Comments
 (0)