-
Notifications
You must be signed in to change notification settings - Fork 52
Open
Description
When using groupby with Bins in YAXArrays, the grouping works correctly only if the mapping function returns simple numeric types. If the function returns other types—such as strings produced by format—the bins produce empty groups or throw an error.
For example, I want to groupby year and month:
using Dates
using YAXArrays
using YAXArrays: YAXArrays as YAX
axlist = (
YAX.time(Date("1961-01-01"):Day(1):Date("1961-04-30")),
YAX.lon(1:10),
YAX.lat(1:15),
)
data = rand(120, 10, 15)
a = YAXArray(axlist, data)
# Method 1: works
groupby(a, YAX.time => Bins(x -> year(x) * 100 + month(x), [[196101, 196102], [196103, 196104]]))
# Method 2: failed
groupby(a, YAX.time => Bins(x -> format(x, "yyyymm"), [["196101", "196102"], ["196103", "196104"]]))
# Method 3: failed
groupby(a, YAX.time => Bins(yearmonth, [[(1961, 1), (1961, 2)], [(1961, 3), (1961, 4)]]))
Metadata
Metadata
Assignees
Labels
No labels