It’s useful to consult the documentation in these situations:
https://dataframes.juliadata.org/stable/lib/indexing/#Indexing-GroupedDataFrames
In particular:
A
GroupedDataFramecan behave as either anAbstractVectororAbstractDictdepending on the type of index used. Integers (or arrays of them) trigger vector-like indexing whileTupless andNamedTuples trigger dictionary-like indexing.
And:
gd[i::Integer]→ Get theith group.gd[key::NamedTuple]→ Get the group corresponding to the given values of the grouping columns. >The fields of theNamedTuplemust match the grouping columns columns passed to [groupby]>(Functions · DataFrames.jl) (including order).gd[key::Tuple]→ Same as previous, but omitting the names onkey.
So:
julia> search_test_col[(test_value,)]
1×1 SubDataFrame
Row │ test_col
│ String
─────┼──────────
1 │ B
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.