New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: rolling apply multiple columns or whole dataframe #53235
Comments
That's what the parameter So, this is currently more of an limitation of the current API. and changing it,so Is |
Hi topper-123, thank you so much for your reply. The info for reference of numba is limited. I suppose this code should work, replacing the last row of code in the question. |
I am not familiar with the restrictions on when numba works with I looked through the issue list, and there is already #40374, which started out as a enhancement proposal, but ended up. as a doc issue, but is still open, though the related doc issue has been resolved. So IDK, can you rephrase this to be an enhancement proposal, requesting to |
Yes, it is! |
Nice. Would we then be able to roll over a DataFrame like requested here? |
Yes - I am aiming to add user-control as to whether the columns or the entire frame is passed to the UDF across the board, so in particular in rolling. |
For context, this was done because the current window aggregations (including apply) in cython were only written to accepts 1D inputs. At the time, it wasn't in my scope to rewrite them to 2D |
Hello @mb-hz and @mroeschke, My project team is looking for Pandas enhancement features for our grad school semester long project. We saw this task and would like to contribute if possible! |
Hello @mroeschke Has this issue been fixed on your end with your groupby.apply fix? I am currently working on trying to modify the Rolling class _apply function to do this, but don't want to double work. |
To go with the above comment, @rhshadrach where you mention aiming to add user control on this, would or does this fix this issue? |
@iangainey - adding user control on what is given to the passed callable (column-by-column or the entire frame at once) would close this issue. Currently there is no concrete proposal for this and it is something I plan to take up eventually - but would be happy if someone else takes it up. That being said, I would like such a proposal to encompass agg, apply, transform, filter (in some instances), and map across Series, DataFrame, groupby, rolling, and resample rather than going piece-meal creating a (more) inconsistent API. |
@rhshadrach Hi Richard, thanks for the response! I currently have a working fix in the scope of this issue for rolling.apply by adding user control with a multi_column = true parameter. Is it a requirement that the parameter to be all encompassing, or would you accept a solution that would only close this issue that could be incorporated into a bigger multi_column fix later on. |
Pandas version checks
I have checked that this issue has not already been reported.
I have confirmed this bug exists on the latest version of pandas.
I have confirmed this bug exists on the main branch of pandas.
Reproducible Example
Issue Description
If you do
for i in df.rolling(window=2, min_periods=1): print(i)
, you can see thati
includes both columns. However, when you use df.rolling with df.apply function, the function can not recognise both columns.Expected Behavior
I expect the rolling function can return multiple columns as it shows in for loop print, into apply function after it, when we use dataframe instead of series or array as the input.
Installed Versions
INSTALLED VERSIONS
commit : 2e218d1
python : 3.11.1.final.0
python-bits : 64
OS : Windows
OS-release : 10
Version : 10.0.19045
machine : AMD64
processor : Intel64 Family 6 Model 154 Stepping 4, GenuineIntel
byteorder : little
LC_ALL : None
LANG : None
LOCALE : English_United Kingdom.1252
pandas : 1.5.3
numpy : 1.23.5
pytz : 2022.7.1
dateutil : 2.8.2
setuptools : 65.5.0
pip : 23.0.1
Cython : 0.29.33
pytest : 7.2.2
hypothesis : None
sphinx : None
blosc : None
feather : None
xlsxwriter : None
lxml.etree : 4.9.2
html5lib : None
pymysql : None
psycopg2 : None
jinja2 : 3.1.2
IPython : 8.12.0
pandas_datareader: None
bs4 : 4.12.0
bottleneck : None
brotli : None
fastparquet : None
fsspec : None
gcsfs : None
matplotlib : 3.7.1
numba : None
numexpr : None
odfpy : None
openpyxl : 3.1.2
pandas_gbq : None
pyarrow : None
pyreadstat : None
pyxlsb : None
s3fs : None
scipy : 1.10.1
snappy : None
sqlalchemy : None
tables : None
tabulate : None
xarray : None
xlrd : None
xlwt : None
zstandard : None
tzdata : None
The text was updated successfully, but these errors were encountered: