Closed
Description
the on=
argument of DataFrame.rolling
only works for datetime columns.
df = pd.DataFrame([
[18, 0],
[2, 0],
[1, 0],
[9, 1],
[8, 1],
], columns=['value', 'roll'])
df.roll = pd.to_datetime(df.roll, unit='s')
df.rolling('1s', on='roll').value.max()
returns:
0 18.0
1 18.0
2 18.0
3 9.0
4 9.0
Name: value, dtype: float64
as expected.
But
df.rolling(1, on='roll').value.max()
returns:
0 18.0
1 2.0
2 1.0
3 9.0
4 8.0
Name: value, dtype: float64
If this is intentional behavior, I'd be happy to change the docs to note this (the docs currently imply that on=
can be used for any column).