kieferk / dfply

dplyr-style piping operations for pandas dataframes
GNU General Public License v3.0
889 stars 103 forks source link

NameError: name 'filter_by' is not defined #50

Open ravik020 opened 6 years ago

ravik020 commented 6 years ago

I am not able to call any of the functions in dfply package. The package has been imported and installed. I am using python 3.0 in JupyterLab notebook.

image

sharpe5 commented 6 years ago

Use mask() instead:

from dfply import *
# "diamonds" is a DataFrame supplied by dfply for testing purposes
diamonds >> mask(X.color == 'E')

This is one of the few instances where the Python API is different to the R API. The reason is a clash with an existing Python API in a different package.

ravik020 commented 6 years ago

No, what i meant to say is no functions are working from the dfply package. for instance, image

sharpe5 commented 6 years ago

I have been using dfply for years, and it works perfectly every time.

It looks like you are using the wrong syntax.

  1. Try some of the examples in the dfply readme at: https://github.com/kieferk/dfply

  2. Try upgrading from Python 3.0 to Python 3.6.

  3. Try this example:

from dfply import *
# Diamonds is a built in dataframe. Prints first three rows.
diamonds >> head(3) 
# Demo of different types of select. Prints column 1, then column "price", then columns "x" and "y".
diamonds >> select(1, X.price, ['x', 'y']) >> head(2) 
kieferk commented 6 years ago

Years! Has it really been around that long? Crazy.

If none of the functions work for you some other strange issue is going on. And for the record, yes as @sharpe5 says filter is a reserved name in python and so I switched the name to mask.

thalesmello commented 6 years ago

The reason it's not working is the dfply version in pip repository is from Aug 2017, whereas the filter_by alias was included merely five months ago.

Therefore, the package on pip should probably be updated.

sharpe5 commented 5 years ago

Can we close this issue for now?

ravik020 commented 5 years ago

Yes

On Sat, Sep 1, 2018, 2:53 AM sharpe5 notifications@github.com wrote:

Can we close this issue for now?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/kieferk/dfply/issues/50#issuecomment-417840977, or mute the thread https://github.com/notifications/unsubscribe-auth/Ac3t215q_JobmUDRqYW11f19bn9WRc9qks5uWjzbgaJpZM4TB-ic .