Tyler Van Hensbergen
11/19/2024, 10:36 PM.agg after a groupby , however, if I supply multiple expressions to .agg I get the error:
DaftError::ValueError MapGroups not supported via aggregation, use map_groups instead
But map_groups looks like it only accepts 1 expression.Kevin Wang
11/19/2024, 10:38 PMmap_groups function with the aggregation columns that you want, and then expand that struct out after the aggregation with df.select("struct_col.*")Tyler Van Hensbergen
11/19/2024, 10:42 PMTyler Van Hensbergen
11/19/2024, 11:16 PMKevin Wang
11/19/2024, 11:17 PMTyler Van Hensbergen
11/19/2024, 11:18 PMNotImplemented from rustKevin Wang
11/19/2024, 11:19 PMTyler Van Hensbergen
11/19/2024, 11:20 PMTyler Van Hensbergen
11/19/2024, 11:24 PMTyler Van Hensbergen
11/19/2024, 11:30 PMTyler Van Hensbergen
11/19/2024, 11:31 PM@daft.udf(
return_dtype=DT.struct(
{
"positions": DT.tensor(DT.float64()),
"expressions": DT.tensor(DT.float64()),
"masks": DT.list(DT.bool()),
}
)
)
def format_experiment_inputs(
x_diff: daft.Series,
y_diff: daft.Series,
expression: daft.Series,
length: int = 6,
):
return [
{
"positions": build_positions(x_diff, y_diff, length),
"expressions": build_expressions(expression, length),
"masks": build_missing_data_mask(x_diff, length),
}
]Tyler Van Hensbergen
11/19/2024, 11:31 PMTyler Van Hensbergen
11/19/2024, 11:32 PMmap_group calls and then join the outputs which is more overhead.jay
11/19/2024, 11:35 PMunimplemented!() without a useful message 😛
cc @Desmond Cheong as welljay
11/19/2024, 11:46 PMimport numpy as np
import daft
from daft import DataType as DT
@daft.udf(
return_dtype=DT.struct(
{
"positions": DT.tensor(DT.float64()),
"expressions": DT.tensor(DT.float64()),
"masks": DT.list(DT.bool()),
}
)
)
def format_experiment_inputs(
x_diff: daft.Series,
y_diff: daft.Series,
expression: daft.Series,
length: int = 6,
):
return [
{
"positions": np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
"expressions": np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]]),
"masks": [[True, True, False], None, None],
}
]
df = daft.from_pydict({"foo": [b"data1", b"data2", b"data3"]})
df = df.with_column("bar", format_experiment_inputs(df["foo"], df["foo"], df["foo"]))
df.collect()jay
11/19/2024, 11:50 PMnumpy -> Series story needs to be improved overall… Noticing some weird issues even without structs.
Sorry about that @Tyler Van Hensbergen we’ll straighten this out and get back to you shortly
@Desmond Cheong let’s sync up and come up with a good tracking issue for this so we can knock it out?Tyler Van Hensbergen
11/19/2024, 11:52 PM