Hi all, I was reading the DataFramesMeta docu trying to solve a small issue that I have, but I couldnβt find the answer. Any help is welcome!
Basically, I have a df that looks like this:
df = DataFrame(
a = repeat(1:4, outer = 2),
b = ["a", "b", "c", "d", "e", "f", "g", "h"],
c = [23,76,9,90,123,67,13,5])
And what I am looking for is getting a df that only holds the maximum value of c
for each repeated value of a
, and the value of b
that correspond to that row. Something like this:
|a| b| c|
|-|---|---|
|1|"e"|123|
|2|"b"| 76|
|3|"g"| 13|
|4|"d"| 90|
I already know that I can use this line to get the first and last column:
@by(df, :a, :c= maximum(:c))
But I donβt really know how to add the corresponding line of b
for each value of a
. I tried a couple of things, but none worked.
Is there an easy way of doing this?
Thanks a lot!