kieferk / dfply

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

DFPLY not working.....at all #64

Closed jaybundy closed 5 years ago

jaybundy commented 5 years ago

This was never an issue. It should be deleted.

sharpe5 commented 5 years ago

I don't see any code that uses dfply, only code that uses pandas.

Could you post some example code that uses dfply?

On Tue, 21 Aug 2018 18:56 jaybundy, notifications@github.com wrote:

Sorry for being so new to this. But I can't get dfply to work....at all. It tells me select is not defined. I'm very frustrated. All I can find on the internet is praise for this package and not support for the fact that I can't get it to work. Below is some code.

from dfply import * import pandas as pd

flight_data = pd.read_csv('nycflights13.csv') flight_data.head()

AttributeError: module 'dfply' has no attribute 'select'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kieferk/dfply/issues/64, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOypLk2tFOu54EBaTLxh5ZyuJSaxpKtks5uTEmzgaJpZM4WGS-j .

sharpe5 commented 5 years ago

Try copying and pasting some of the example code that uses the built-in diamonds dataframe.

On Tue, 21 Aug 2018 19:59 Shane Tolmie, shane.tolmie@gmail.com wrote:

I don't see any code that uses dfply, only code that uses pandas.

Could you post some example code that uses dfply?

On Tue, 21 Aug 2018 18:56 jaybundy, notifications@github.com wrote:

Sorry for being so new to this. But I can't get dfply to work....at all. It tells me select is not defined. I'm very frustrated. All I can find on the internet is praise for this package and not support for the fact that I can't get it to work. Below is some code.

from dfply import * import pandas as pd

flight_data = pd.read_csv('nycflights13.csv') flight_data.head()

AttributeError: module 'dfply' has no attribute 'select'

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/kieferk/dfply/issues/64, or mute the thread https://github.com/notifications/unsubscribe-auth/ABOypLk2tFOu54EBaTLxh5ZyuJSaxpKtks5uTEmzgaJpZM4WGS-j .

jaybundy commented 5 years ago

Thanks for timely support. It doesn't seem to matter. Running the above code snippet will produce the error I included, even if I don't actually call the select function.

The actual example code I'm trying to execute comes from: https://towardsdatascience.com/dplyr-style-data-manipulation-with-pipes-in-python-380dcb137000

from dfply import * import pandas as pd

flight_data = pd.read_csv('nycflights13.csv') flight_data.head()

(flight_data >> select(X.origin, X.dest, X.hour))

Here is the full error message: File "/Users/Jay/Programming/VSCode/Python/Google_python_class/Other_python_lessons/dfply1.py", line 3, in from dfply import * File "/Users/Jay/Programming/VSCode/Python/Google_python_class/Other_python_lessons/dfply.py", line 11, in dfply.select(X.origin, X.dest, X.hour)) AttributeError: module 'dfply' has no attribute 'select'

jaybundy commented 5 years ago

Interestingly,

If I just run this code:

import os import pandas as pd import dfply

print(dfply)

I still get: AttributeError: module 'dfply' has no attribute 'select'

kieferk commented 5 years ago

Hello there. What version of python are you using? I don't think it would matter for this specifically, but dfply only works for python 3 now in case you're using python 2...

Can you open up a jupyter notebook or ipython console of and type: from dfply import *

Then see if select is in the namespace?

jaybundy commented 5 years ago

Version 3.7.0. Interestingly, I seem to be able to get the code to work fine using the interpreter interactively. But when I try to use the package in a script (I write scripts in VS Code), even trying to run "import dfply" only with absolutely no other lines of code, I still get the message:

AttributeError: module 'dfply' has no attribute 'select'

That's weird, because at that point I haven't referenced select at all (as in the original post). But I have the same problem with dplython. Works fine interactively, can't use it in a script, claims it doesn't have select...but in both cases select shows up in help as well as dir and seems to work fine interactively.

kieferk commented 5 years ago

That is odd for sure. In the code above you posted:

import os
import pandas as pd
import dfply

print(dfply)

Could you paste the exact error message you get here?

jaybundy commented 5 years ago

I believe I figured it out. I was naming the module I used to test the package dfply.py...which obviously broke the import. I'm so sorry to have troubled you guys over such a novice error. But I am very, very grateful for the persistent assistance. Happy Pythoning and Thanks!

sharpe5 commented 5 years ago

Ah, that makes sense.

I've done the same thing before but with a different package.

I think every single Python expert makes this mistake at least once in their learning curve.

Glad its sorted!