-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
transform in groupby throws TypeError when run with python -O option #2057
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
Comments
That's not cool. Do you have a self-contained reproduction you could post here? |
Well, sort of. I tried to reproduce and discovered another strange behavior. Here is the code for the strange behavior:
'python TestGroupbyTransformO.py' produces the expected oucome: ---begin console output------------------------------------- Input data frame: Calculating medians for each column: Data frame with medians: ---end console output------------------------------------------- 'python -O TestGroupbyTransformO.py' produces this: ---begin console output------------------------------------------ Input data frame: Calculating medians for each column: Data frame with medians:
File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 3831, in _appl ---end console output------------------------------------------------------------------------------------ This is not what I observe in my more complex problem. It has a bigger frame and a more complicated function, but it does calculate several quantiles per column during the first steps (I tried to isolate those steps and discovered the above behavior). Normal run produces something like this: ---begin console output----------------------------------- Entered with (1996L,) The -O run produces this: ---begin console output----------------------------- ---end console output----------------------------- As you can see, in my program the -O run never enters with the full shape (1996, 21) and doesn't seem to even get beyond quantile calculations:
I realize it's convoluted but I hope it helps. The original program is more complex and so far I haven't been able to simply reproduce the behavior I observe. But I did find another puzzling behavior! :-) |
wow, this is annoying. Apparently |
Yep, among other things. But that's the point! Faster code. -OO also removes docstrings. I am not sure how much it helps though. If it's hard to fix, fughetaboutit :-) |
Continuing #2057, s/assert/raise AssertionError/g
I have a script that works fine when run without any options but generates the following traceback when run with 'python -O':
File "C:\Python27\lib\site-packages\pandas\core\groupby.py", line 1745, in transform
return self._transform_item_by_item(obj, wrapper)
File "C:\Python27\lib\site-packages\pandas\core\groupby.py", line 1777, in _transform_item_by_item
raise TypeError('Transform function invalid for data types')
TypeError: Transform function invalid for data types
I have Python 2.7.3 and pandas 0.9.0:
Python 2.7.3 (default, Apr 10 2012, 23:24:47) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
The text was updated successfully, but these errors were encountered: