Skip to content

Commit 86a6946

Browse files
author
Christopher Doris
committed
add conversion for pandas NA to missing
1 parent f9d553c commit 86a6946

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/PythonCall.jl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ include("concrete/datetime.jl")
4242
include("concrete/code.jl")
4343
include("concrete/ctypes.jl")
4444
include("concrete/numpy.jl")
45+
include("concrete/pandas.jl")
4546
# @py
4647
# anything below can depend on @py, anything above cannot
4748
include("py_macro.jl")
@@ -107,8 +108,9 @@ function __init__()
107108
init_gui()
108109
init_ipython()
109110
init_tables()
110-
init_numpy()
111111
init_ctypes()
112+
init_numpy()
113+
init_pandas()
112114
end
113115
@require PyCall="438e738f-606a-5dbb-bf0a-cddfbfd45ab0" init_pycall(PyCall)
114116
end

src/concrete/pandas.jl

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
pyconvert_rule_pandas_na(::Type{Nothing}, x::Py) = pyconvert_return(nothing)
2+
pyconvert_rule_pandas_na(::Type{Missing}, x::Py) = pyconvert_return(missing)
3+
4+
function init_pandas()
5+
pyconvert_add_rule("pandas._libs.missing:NAType", Missing, pyconvert_rule_pandas_na, PYCONVERT_PRIORITY_CANONICAL)
6+
pyconvert_add_rule("pandas._libs.missing:NAType", Nothing, pyconvert_rule_pandas_na)
7+
end

0 commit comments

Comments
 (0)