Git Product home page Git Product logo

Comments (4)

bkamins avatar bkamins commented on August 12, 2024 1

Yes - I do not say that @linq is broken. I am making a feature request 😄. Incidentally this request is needed with Lazy.jl because of groupby name clash.

Let me explain the problem more explicitly. Assume you do not want to pollute a namespace for instance (which can be expected in production code) and use import instead of using. How would you use @linq then?

julia> import DataFrames, DataFramesMeta

julia> x = DataFrames.DataFrame(rand(3,4))
3×4 DataFrames.DataFrame
│ Row │ x1       │ x2       │ x3       │ x4       │
├─────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ 0.789172 │ 0.2509   │ 0.107305 │ 0.504798 │
│ 2   │ 0.173546 │ 0.847316 │ 0.292337 │ 0.880935 │
│ 3   │ 0.304413 │ 0.460651 │ 0.368497 │ 0.581835 │

julia> DataFramesMeta.@linq x |> DataFrames.groupby(:x1)
ERROR: MethodError: Cannot `convert` an object of type Expr to an object of type DataFramesMeta.SymbolParameter
This may have arisen from a call to the constructor DataFramesMeta.SymbolParameter(...),
since type constructors fall back to convert methods.

whereas with using you have:

julia> using DataFrames, DataFramesMeta

julia> @linq x |> groupby(:x1)
DataFrames.GroupedDataFrame  3 groups with keys: Symbol[:x1]
First Group:
1×4 DataFrames.SubDataFrame{Array{Int64,1}}
│ Row │ x1       │ x2     │ x3       │ x4       │
├─────┼──────────┼────────┼──────────┼──────────┤
│ 1   │ 0.789172 │ 0.2509 │ 0.107305 │ 0.504798 │
⋮
Last Group:
1×4 DataFrames.SubDataFrame{Array{Int64,1}}
│ Row │ x1       │ x2       │ x3       │ x4       │
├─────┼──────────┼──────────┼──────────┼──────────┤
│ 1   │ 0.304413 │ 0.460651 │ 0.368497 │ 0.581835 │

So in short a feature request is for @linq to properly resolve qualified function names in general (and groupby is only a special case - coincidentally referred to in the documentation).

Of course - you might get name clash of any function you use in general (there is no guarantee that some other package does not use the same name for something else) - so I would find this general qualified name resolution functionality desirable.

from dataframesmeta.jl.

tshort avatar tshort commented on August 12, 2024

If I'm reading it right, @linq works. It's use of Lazy that has the conflict. The main options I see are:

  1. Remove all uses of Lazy from the docs/examples, and encourage @linq.

  2. Pull in @> from Lazy.

from dataframesmeta.jl.

tshort avatar tshort commented on August 12, 2024

Got it. That is a problem with @linq. If you care to have a go at a fix, the following link shows where the appropriate code is. That needs to be generalized to handle qualified functions.

https://github.com/JuliaStats/DataFramesMeta.jl/blob/b016059cce76773ca0382dbaed15eb13e1d71f2d/src/linqmacro.jl#L70-L84

from dataframesmeta.jl.

bkamins avatar bkamins commented on August 12, 2024

In #95 I have proposed the fix.

from dataframesmeta.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.