python3 support ?
Closed this issue · 6 comments
import pandas as pd
from ply import install_ply, X, sym_call
install_ply(pd)
gives
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
<ipython-input-1-f35c480251ef> in <module>()
1 import pandas as pd
----> 2 from ply import install_ply, X, sym_call
3
4 install_ply(pd)
D:\result_tests\WinPython-64bit-3.4.2.3_build3\python-3.4.2.amd64\lib\site-packages\ply\__init__.py in <module>()
----> 1 from methods import install_ply
2 from symbolic import X, sym_call
ImportError: No module named 'methods'
it seems a "."-like thing
from .methods import install_ply
from .symbolic import X, sym_call
and
from . import symbolic
and then a few parenthesitizing
print ()
After that I still have something I dont understand when I use "where"
(flights
.groupby(['Year', 'Month', 'DayofMonth'])
.ply_select(
arr = X.ArrTime.mean(),
dep = X.DepTime.mean())
.ply_where(X.Year >= X.Year))
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-13-58a798c52b76> in <module>()
4 arr = X.ArrTime.mean(),
5 dep = X.DepTime.mean())
----> 6 .ply_where(X.Year >= X.Year))
TypeError: unorderable types: GetAttr() >= GetAttr()
No clue there
after a little reduce effort ply_where alone works :
flights.ply_where(flights.ArrTime < 1500, flights.ArrTime >1400).head()
this works:
(flights
.groupby(['Year', 'Month', 'DayofMonth'])
.ply_select(
arr = X.ArrTime.mean(),
dep = X.DepTime.mean())
)
but still no chance in combination:
(flights
.groupby(['Year', 'Month', 'DayofMonth'])
.ply_select(
arr = X.ArrTime.mean(),
dep = X.DepTime.mean())
.ply_where(X.arr < 1500, X.dep >1400))
gives:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-3-0cbf68ca069f> in <module>()
4 arr = X.ArrTime.mean(),
5 dep = X.DepTime.mean())
----> 6 .ply_where(X.arr < 1500, X.dep >1400))
TypeError: unorderable types: GetAttr() < int()
Yep, use of operators on symbolic expressions (like symbolicExpression + 3
) fails in Python 3. It turns out that this is because the current system needs Python to call symbolicExpression.__getattr__('__add__')
at some point in the evaluation of symbolicExpression + 3
, and for new-style classes (the only ones available in Python 3), this call is skipped. See https://docs.python.org/2/reference/datamodel.html#new-style-special-lookup for details on that.
The solution is to add the special methods (like __add__
) directly to ply.symbolic.Expression
. Kinda ugly, but that's life.
I'll take care of this. Thanks for all your debugging work!
@stonebig -- I just pushed a new version which should fix these issues. (I decided to drop in a version of https://pypi.python.org/pypi/six.) The relevant changes are in 115c79e. Please run
pip install pandas-ply --upgrade
and let me know if everything works ok.
(Thanks again for your help.)
everything works ok.