and if i identify the `value_col` to `c1` or `c2`,...
# daft-dev
c
and if i identify the
value_col
to
c1
or
c2
, it will raise the exception. @Sammy Sidhu
s
Do you have a small snippet for repro?
c
import daft df = daft.from_pylist([{"c1": 1, "c2": 11}, {"c1": 1, "c2": 11}, {"c1": 3, "c2": 10}, {"c1": 4, "c2": 8}, {"c1": 4, "c2": 8}]) df.pivot("c1", "c2", daft.lit(0), "count").collect()
Copy code
import daft
df = daft.from_pylist([{"c1": 1, "c2": 11}, {"c1": 1, "c2": 11}, {"c1": 3, "c2": 10}, {"c1": 4, "c2": 8}, {"c1": 4, "c2": 8}])
df.pivot("c1", "c2", daft.lit(0), "count").collect()
image.png
s
That's a good catch! I don't think we handle literals in pivot, but it should be fairly easy to implement our broadcasting like we do with our other kernels. I believe @Colin Ho implemented the initial version, I'll see what thoughts that they have. But I think we should just have to handle broadcasting for these two series here if they are length 1 https://github.com/Eventual-Inc/Daft/blob/c2d7d087b3f4af9004c9578fa27bbb7e1a223d40/src/daft-table/src/ops/pivot.rs#L88 Feel free to also take a stab at it 🙂
c
Yes, you can broadcast the series if they are length 1. This is the method you can use: https://github.com/Eventual-Inc/Daft/blob/main/src/daft-core/src/series/ops/broadcast.rs . You could do something like:
value_series.broadcast(self.len())?