JuliaData / DataFrames.jl

In-memory tabular data in Julia
https://dataframes.juliadata.org/stable/
Other
1.72k stars 361 forks source link

Make row lookup easier #3051

Closed bkamins closed 3 months ago

bkamins commented 2 years ago

This is a speculative idea. Maybe we could define GroupedDataFrame to be callable like this:

(gdf::GroupedDataFrame)(idxs...) = gdf[idxs]

In this way instead of writing:

gdf[("val",)]

users could write gdf("val").

@nalimilan, @pdeffebach - what do you think?

Ref: https://discourse.julialang.org/t/any-plan-for-functionality-like-pandas-loc/81134

pdeffebach commented 3 months ago

I've still yet to dive deeply into DataFramesMeta.jl thinking it is probably overkill for what I usually need to do. However, it seems to be more simple and helpful than I gave it credit for.

I may be biased, but users should probably go to DataFramesMeta.jl first rather than after they learn DataFrames.jl src => fun => dest syntax. The latter is, in my view, a lot more complicated than DataFramesMeta.jl syntax. So I kind of disagree with your framing here. If users see @rlookup first and then never need to do anything with the base DataFrames.jl syntax, that's fine, and probably the goal.

nathanrboyer commented 3 months ago

I think you are right. I also think my misunderstanding, that DataFramesMeta.jl is an extension of DataFrames.jl for advanced power users, is a common one.

bkamins commented 3 months ago

that DataFramesMeta.jl is an extension of DataFrames.jl for advanced power users, is a common one.

I will add a blog post about it :), and also update the documentation of DataFrames.jl. @pdeffebach - probably one could also write something like this in DataFramesMeta.jl documentation to be more explicit (as per https://github.com/JuliaData/DataFramesMeta.jl/pull/393).

I am closing this issue - if we add some.