Counting Value Occurences in Time Range in DataFrames

If you want to preserve dates, you can use trunc instead of month

julia> df2 = transform(df, :d => (x -> trunc.(x, Dates.Month)) => :m);

julia> combine(groupby(df2, [:m, :v]), nrow)
5×3 DataFrame
 Row │ m           v       nrow
     │ Date        String  Int64
─────┼───────────────────────────
   1 │ 2020-02-01  A           4
   2 │ 2020-02-01  B           1
   3 │ 2020-02-01  C           3
   4 │ 2020-03-01  A           2
   5 │ 2020-03-01  B           1
1 Like