Skip to content

The rolling method of fireducks.pandas.frame.DataFrame does not support window argument of type timedelta, str or offset #66

@ButteryPaws

Description

@ButteryPaws

According to the Pandas documentation for pandas.DataFrame.rolling, the first argument rolling can be of type timedelta (e.g. pd.Timedelta(days=1)), str (e.g. 30min). These arguments are valid only when the index of the dataframe is of type pandas.DatetimeIndex and are immensely when working with time-series data.

Reproducible Code

import pandas as pd
import numpy as np

def get_rolling_sum(df: pd.DataFrame) -> pd.DataFrame:
    rolling_sum = df.rolling(window='15min', min_periods=5).sum()
    return rolling_sum

index = pd.date_range('2025-04-07 09:00:00', '2025-04-07 17:00:00', freq='min')
data = np.random.randn(len(index), 2)
df = pd.DataFrame(data=data, index=index)
rolling_sum_pandas = get_rolling_sum(df)

import fireducks.pandas as pd
df = pd.DataFrame(df)
rolling_sum_fireducks = get_rolling_sum(df)

The Error

Traceback (most recent call last):
  File "/home/user/src/temp.py", line 15, in <module>
    rolling_sum_fireducks = get_rolling_sum(df)
                            ^^^^^^^^^^^^^^^^^^^
  File "/home/user/src/temp.py", line 5, in get_rolling_sum
    rolling_sum = df.rolling('15min', min_periods=5).sum()
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.venv/lib/python3.12/site-packages/fireducks/pandas/rolling.py", line 124, in sum
    return self.aggregate("sum")
           ^^^^^^^^^^^^^^^^^^^^^
  File "/home/user/.venv/lib/python3.12/site-packages/fireducks/pandas/rolling.py", line 93, in aggregate
    if rolling_ns.min_periods > rolling_ns.window:
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: '>' not supported between instances of 'int' and 'str'

On experimenting with other arguments to window which are not integers, the error persists. It seems like the support for non-integer arguments, specifically those involving DatetimeIndex of the dataframe and time-related operations has not been implemented yet.

System specifications

Python version: 3.12.3
Pandas version: 2.2.3
Fireducks version: 1.2.5
NumPy version: 2.1.2

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions