Skip to content
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

python3 support ? #1

Closed
stonebig opened this issue Nov 30, 2014 · 6 comments
Closed

python3 support ? #1

stonebig opened this issue Nov 30, 2014 · 6 comments

Comments

@stonebig
Copy link

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'
@stonebig stonebig changed the title issue at initialization (over pandas 0.15.1) issue at initialization (over pandas 0.15.1, python3.4.2 64 bit, windows) Nov 30, 2014
@stonebig
Copy link
Author

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 ()

@stonebig stonebig changed the title issue at initialization (over pandas 0.15.1, python3.4.2 64 bit, windows) python3 support ? Nov 30, 2014
@stonebig
Copy link
Author

see #2 and #3

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

@stonebig
Copy link
Author

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()

@jhorowitz-coursera
Copy link
Contributor

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!

@jhorowitz-coursera
Copy link
Contributor

@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.)

@stonebig
Copy link
Author

stonebig commented Dec 2, 2014

everything works ok.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants