|
| 1 | +# cython: profile=True |
1 | 2 | import cython
|
2 | 3 | from cython import Py_ssize_t
|
3 | 4 |
|
@@ -52,6 +53,10 @@ from pandas._libs.khash cimport (
|
52 | 53 | kh_resize_int64,
|
53 | 54 | khiter_t,
|
54 | 55 | )
|
| 56 | +from pandas._libs.missing cimport ( |
| 57 | + checknull, |
| 58 | + checknull_old, |
| 59 | +) |
55 | 60 | from pandas._libs.util cimport (
|
56 | 61 | get_nat,
|
57 | 62 | numeric,
|
@@ -847,7 +852,7 @@ ctypedef fused fillna_t:
|
847 | 852 | @cython.boundscheck(False)
|
848 | 853 | @cython.wraparound(False)
|
849 | 854 | def fillna1d(fillna_t[:] arr,
|
850 |
| - object value, |
| 855 | + fillna_t value, |
851 | 856 | limit=None,
|
852 | 857 | bint inf_as_na=False
|
853 | 858 | ) -> ndarray:
|
@@ -881,15 +886,21 @@ def fillna1d(fillna_t[:] arr,
|
881 | 886 |
|
882 | 887 | N = len(arr)
|
883 | 888 | 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: |
884 | 892 | if inf_as_na:
|
885 |
| - check_func = missing.checknull_old |
| 893 | + check_func = checknull_old |
886 | 894 | else:
|
887 |
| - check_func = missing.checknull |
| 895 | + check_func = checknull |
888 | 896 | for i in range(N):
|
889 | 897 | val = arr[i]
|
890 |
| - if check_func(val) and count < lim: |
| 898 | + if val != val and count < lim: |
891 | 899 | arr[i] = value
|
892 | 900 | count+=1
|
| 901 | + # if check_func(val) and count < lim: |
| 902 | + # arr[i] = value |
| 903 | + # count+=1 |
893 | 904 |
|
894 | 905 |
|
895 | 906 | @cython.boundscheck(False)
|
@@ -930,9 +941,9 @@ def fillna2d(fillna_t[:, :] arr,
|
930 | 941 | n, m = (<object>arr).shape
|
931 | 942 | lim = validate_limit(m, limit)
|
932 | 943 | if inf_as_na:
|
933 |
| - check_func = missing.checknull_old |
| 944 | + check_func = checknull_old |
934 | 945 | else:
|
935 |
| - check_func = missing.checknull |
| 946 | + check_func = checknull |
936 | 947 | for i in range(n):
|
937 | 948 | count = 0 # Limit is per axis
|
938 | 949 | for j in range(m):
|
|
0 commit comments