I am new to Polars.
I want to iterate over the groups created by grouping over the column where each cell of that column contains a list of two dates. I used the following (sample) piece of code to achieve and it used to work fine with polars==0.20.18
version:
import polars as pl
import datetime
dt_str = [{'ts': datetime.date(2023, 7, 1), 'files': 'AGG_202307.xlsx',
'period_bins': [datetime.date(2023, 7, 1), datetime.date(2024, 1, 1)]},
{'ts': datetime.date(2023, 8, 1), 'files': 'AGG_202308.xlsx',
'period_bins': [datetime.date(2023, 7, 1), datetime.date(2024, 1, 1)]},
{'ts': datetime.date(2023, 11, 1), 'files': 'KFC_202311.xlsx',
'period_bins': [datetime.date(2023, 7, 1), datetime.date(2024, 1, 1)]},
{'ts': datetime.date(2024, 2, 1), 'files': 'KFC_202402.xlsx',
'period_bins': [datetime.date(2024, 1, 1), datetime.date(2024, 7, 1)]}]
dt = pl.from_dicts(dt_str)
df_groups = dt.group_by("period_bins")
print(df_groups.all().to_dicts())
But the above code does not work with polars==1.x
and gives the following error:
thread 'polars-0' panicked at crates/polars-row/src/encode.rs:289:15:
not implemented: Date32
thread 'polars-1' panicked at crates/polars-row/src/encode.rs:289:15:
not implemented: Date32
Traceback (most recent call last):
File "testpad.py", line 18, in <module>
print(df_groups.all().to_dicts())
File "python3.10/site-packages/polars/dataframe/group_by.py", line 430, in all
return self.agg(F.all())
File "python3.10/site-packages/polars/dataframe/group_by.py", line 228, in agg
self.df.lazy()
File "python3.10/site-packages/polars/lazyframe/frame.py", line 2027, in collect
return wrap_df(ldf.collect(callback))
pyo3_runtime.PanicException: not implemented: Date32
I would appreciate if someone could help me in figuring out and fixing this error. Thank you!
1