-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Fix: Pandas rolling removes imaginary part of complex #47028
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
Closed
Closed
Changes from 7 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
d1fd5c3
rolling type
2736431
add empty cases
cdc4c6e
add test
436bc99
resolve conflict
186096e
Merge branch 'main' into bug_rolling_complex
09e9635
:Merge branch 'main' of https://github.com/weikhor/pandas into bug_ro…
ac9fd04
use aggregation
7389a95
Merge branch 'main' of https://github.com/weikhor/pandas into bug_rol…
098dc16
test rolling
25c6700
Merge branch 'main' into bug_rolling_complex
dc9cd7e
count
1aaa3a7
Merge branch 'bug_rolling_complex' of https://github.com/weikhor/pand…
beaa1ae
remove type dependency
1dcfa05
add buffer source array is read-only
6e4259b
revert
115feaf
update complex
7bdde24
update complex
c2dbf37
Merge branch 'main' into bug_rolling_complex
796d2bd
Merge branch 'main' of https://github.com/weikhor/pandas into bug_rol…
9f275de
add test
2cae983
Merge branch 'main' into bug_rolling_complex
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So
func_name
should now be tested instead ofapply
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @mroeschke, I not able to understand fully. If I not use apply.
Will get AssertionError depend on function from
arithmetic_win_operators
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly, the cython code may need modifying to support complex dtypes in this case if an AssertionError is raised (guessing since no traceback was provided)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mroeschke
The code I run
The 'arithmetic_win_operators' can be sum, mean, median, max, min, var, std, kurt, skew, count, sem (11 possible arithmetic function.
For example, if arithmetic_win_operators='sum', the error is raised that function sum does not support complex dtypes from cython function inside 'pandas/_libs/window/aggregations.pyx'
Some question. Thus, to make this work. I should write new roll sum function that support complex dtypes in cython. Is this right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create fused types (e.g. float + complex) that the current cython functions accept instead which should get this working for the existing functions. You can see the groupby cython code for an example.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mroeschke Hi
I not sure whether I do it correctly. I try to update
roll_mean
to support complex type in this filepandas/_libs/window/aggregations.pyx
The error is raised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will probably need cast this to float before passing in this C func, or just use a comparison operator to replace sigbit.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modify code in cython
pandas/_libs/window/aggregations.pyx
file to support complex type. Do casting complex values to float in arithmetic operation