Apr-02-2024, 06:03 PM
Error:shape: (614_076, 5)
┌──────────────────────────────┬───────────────────────────────┬──────┬────────┬──────┐
│ ts_event ┆ eastern_time ┆ side ┆ price ┆ size │
│ --- ┆ --- ┆ --- ┆ --- ┆ --- │
│ datetime[μs] ┆ str ┆ str ┆ f64 ┆ i64 │
╞══════════════════════════════╪═══════════════════════════════╪══════╪════════╪══════╡
│ +56135-10-13 20:00:02.663539 ┆ 03-01-2024 09:30:00.002663424 ┆ N ┆ 198.05 ┆ 34 │
│ +56135-10-13 20:00:02.663539 ┆ 03-01-2024 09:30:00.002663424 ┆ N ┆ 198.05 ┆ 4 │
│ +56135-10-13 20:00:03.314087 ┆ 03-01-2024 09:30:00.003314176 ┆ N ┆ 198.05 ┆ 46 │
│ +56135-10-13 20:00:03.314087 ┆ 03-01-2024 09:30:00.003314176 ┆ N ┆ 198.05 ┆ 34 │
│ +56135-10-13 20:00:03.314087 ┆ 03-01-2024 09:30:00.003314176 ┆ N ┆ 198.06 ┆ 5 │
│ … ┆ … ┆ … ┆ … ┆ … │
│ +56209-08-25 23:57:44.164197 ┆ 03-28-2024 09:59:59.864164096 ┆ N ┆ 180.47 ┆ 5 │
│ +56209-08-25 23:57:44.164197 ┆ 03-28-2024 09:59:59.864164096 ┆ B ┆ 180.48 ┆ 95 │
│ +56209-08-25 23:57:44.210570 ┆ 03-28-2024 09:59:59.864210688 ┆ B ┆ 180.48 ┆ 5 │
│ +56209-08-25 23:57:44.341235 ┆ 03-28-2024 09:59:59.864341248 ┆ B ┆ 180.49 ┆ 5 │
│ +56209-08-25 23:57:44.810835 ┆ 03-28-2024 09:59:59.864810752 ┆ N ┆ 180.49 ┆ 7 │
└──────────────────────────────┴───────────────────────────────┴──────┴────────┴──────┘
Traceback (most recent call last):
File "C:\Users\thpfs\Documents\Python\volwa.py", line 40, in <module>
out = df.rolling(index_column = 'ts_event', period = '35s', offset = '1s').agg(pl.col("size").sum())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\thpfs\AppData\Local\Programs\Python\Python312\Lib\site-packages\polars\dataframe\group_by.py", line 894, in agg
.collect(no_optimization=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\thpfs\AppData\Local\Programs\Python\Python312\Lib\site-packages\polars\lazyframe\frame.py", line 1943, in collect
return wrap_df(ldf.collect())
^^^^^^^^^^^^^
polars.exceptions.InvalidOperationError: argument in operation 'rolling' is not explicitly sorted
- If your data is ALREADY sorted, set the sorted flag with: '.set_sorted()'.
- If your data is NOT sorted, sort the 'expr/series/column' first.