slowly working my way through RElearning dataframes ( from pandas ) and wanted to search a dataframe for a value. This is a search I will be doing many times so I thought the approach below might speed things up.
A GroupedDataFrame can behave as either an AbstractVector or AbstractDict depending on the type of index used. Integers (or arrays of them) trigger vector-like indexing while Tupless and NamedTuples trigger dictionary-like indexing.
And:
gd[i::Integer] โ Get the ith group.
gd[key::NamedTuple] โ Get the group corresponding to the given values of the grouping columns. >The fields of the NamedTuple must match the grouping columns columns passed to [groupby]>(Functions ยท DataFrames.jl) (including order).
gd[key::Tuple] โ Same as previous, but omitting the names on key.
Note the comma after test_value. Writing (test_value) doesnโt do anything:
julia> (test_value)
"B"
i.e. itโs the same as writing test_value without parens. If youโre confused about constructing tuples thatโs more of an issue for the base Julia docs rather than DataFrames though.
In particular using GitHub - andyferris/AcceleratedArrays.jl: Arrays with acceleration indices seems a good general solution if you have a condition on a single column. The only problem is that AcceleratedArrays.jl does not seem to be actively maintained currently, so we need to decide what to do about it.
A GroupedDataFrame 1 can behave as either an AbstractVector or AbstractDict depending on the type of index used. Integers (or arrays of them) trigger vector-like indexing while Tupless and NamedTuples trigger dictionary-like indexing.
I was using a Symbol โ:test_colโ which would seem to be pretty apposite for this case. I suppose part of my issue is that I donโt know what a Tupless is.
GroupedDataFrame can behave as either an AbstractVector or AbstractDict depending on the type of index used. Integers (or arrays of them) trigger vector-like indexing while **Tupless** and NamedTuples trigger dictionary-like
as always a worked example is really helpful. I donโt have a lot of time to learn julia and so having a reference point that I can store away that gives me context to rtfm. They also allow people like me, example driven, to stick with learning the language properly.
thanks for the apology but your help is invaluable AND I have a pretty thick skin, and head I learn from examples MORE than rtfm. Examples, like yours, raise questions which lead to me rtfm.
thanks again for everything you do.
theakson