Conversation
|
thanks @FBruzzesi ! I think plotly would only need to get some value from the aggregation, rather than a list dtypes? perhaps we could allow Something like this could help address the |
|
Not sure if this is the right place for this discussion but here we go 🙃
Yes correct!
Not the biggest fan of this if we are going to support
Correct again. |
yeah but it returns object dtype and I fear that'd create more issues for us down the line |
Yes that's not ideal, and yesterday I had issues converting to list type (e.g. Maybe let's sleep on this, but I would imagine that someone using narwhals should just be a bit more pedantic and do: (df
.group_by("a")
.agg(nw.col("b").unique()))
.with_columns(nw.col("b").cast(nw.List(...))) # force it to be list type
... # now can access .list namespace
) |
|
i'm not sure that people would think to do that explicit cast, and implementing the list namespace would be quite difficult for pandas we may be able to take inspiration from duckdb here, who have >>> rel = duckdb.read_parquet('../scratch/assets.parquet')
>>> duckdb.sql('select symbol, any_value(date) from rel group by symbol')
┌─────────┬─────────────────┐
│ symbol │ any_value(date) │
│ varchar │ date │
├─────────┼─────────────────┤
│ EWJ │ 2022-01-31 │
│ OGN │ 2022-01-31 │
│ PRU │ 2022-01-31 │
│ AEP │ 2022-01-31 │
│ ALLE │ 2022-01-31 │
│ IEFM.L │ 2022-01-31 │
│ EWG │ 2022-01-31 │
│ SEGA.L │ 2022-01-31 │
│ IAU │ 2022-01-31 │
│ XLV │ 2022-01-31 │
│ · │ · │
│ · │ · │
│ · │ · │
│ CNC │ 2022-01-31 │
│ CTAS │ 2022-01-31 │
│ DG │ 2022-01-31 │
│ IEF │ 2022-05-31 │
│ IEMG │ 2022-01-31 │
│ JPEA.L │ 2022-01-31 │
│ META │ 2022-01-31 │
│ HIGH.L │ 2022-03-17 │
│ HST │ 2022-01-31 │
│ VXX │ 2022-01-31 │
├─────────┴─────────────────┤
│ 100 rows (20 shown) │
└───────────────────────────┘So, my thinking was that If it's a top-level function ( |
|
Just for clarity, when you say:
does it mean that |
|
I haven't tried implementing it yet, but yes, I think so alternatively, we could add:
Alternatively, we could have our own |
|
I am going to close this for now, we can always come back to it |
What type of PR is this? (check all applicable)
Related issues
May come in handy for plotly
Checklist
If you have comments or can explain your changes, please do so below.
I was not able to add tests... I tried to nest a bunch of checks but also the order inside the list type is not guaranteed..
any idea?