Exporting overloaded functions

Hello!

In Mymodule I have defined the following function.

function convert(t::Type{NamedArray}, df::DataFrame; valueCol = :Values, datatype = Union{Missing, Float64})

Then in mymodule I also export convert. When using Mymodule and calling convert:

df = DataFrame(a = [1,2,3])
dfn = convert(NamedArray, df)

I get the error:

“WARNING: both vreforec and Base export “convert”; uses of it in module Main must be qualified”
“ERROR: UndefVarError: convert not defined”

Hi
Both Base and MyModule modules have method named “convert” and name conflict occurs as Julia doesn’t know from wich module use a definition. In your case you want to extend the defintion:

function Base.convert(t::Type{NamedArray}, df::DataFrame; valueCol = :Values, datatype = Union{Missing, Float64})

More details in https://docs.julialang.org/en/v1/manual/modules/#Handling-name-conflicts

1 Like

This seems to be a case of type piracy: Style Guide · The Julia Language

You should probably use a different name than convert for this operation.