I was wondering if there was a way to avoid conflicts with a function name between packages without using the package identifier every time. To explain what I mean, when I write the following:
using DataFramesMeta using ShiftedArrays rev_df = DataFrame(firm_id = ["A", "A", "A", "A", "B", "B", "B", "B"] , rev = [100, 200, 300, 400, 50, 67, 75, 90], yr = [2001,2002,2003,2004,2001,2002,2003,2004]) using IterTools new_rev_df = @chain rev_df begin groupby(:firm_id) @transform :rev_lag = lag(:rev) end
I get the output:
julia> new_rev_df = @chain rev_df begin groupby(:firm_id) @transform :rev_lag = lag(:rev) end WARNING: both IterTools and DataFramesMeta export "groupby"; uses of it in module Main must be qualified ERROR: UndefVarError: groupby not defined Stacktrace:  top-level scope @ REPL:2
Now this can be resolved by the following:
new_rev_lag = @chain rev_df begin DataFramesMeta.groupby(:firm_id) @transform :rev_lag = lag(:rev) end
This works because I’ve specified before groupby that I’m calling the function from DataFramesMeta.
My issue is, in my code I have to use
IterTools just once, whereas I have to use
DataFramesMeta's groupby() function many, many times. So having to write
DataFramesMeta.groupby() every time I want to do a grouping actually ends up being quite tedious.
Is there a way around this? The simplest I could think of was to load
IterTools when I need it, then “unload” the package so that there’s no conflict when the
DataFramesMeta's groupby() function needs to be used. As far as I can tell, Julia doesn’t let the user unload a package like this, although I might be missing something.
I’d appreciate some sort of workaround that anyone is aware of. Thanks!