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

__main__ imposition in code #215

Closed
wants to merge 1 commit into from
Closed

Conversation

karunakar2
Copy link

Make sure if a novice tries to access the module, he should be aware of encapsulating code within main execution context, pretty much similar to that of requirements of multiprocessing in general. This will reduce wasting of time and delving into multiporcessing more.

Make sure if a novice tries to access the module, he should be aware of encapsulating code within __main__ execution context, pretty much similar to that of requirements of multiprocessing in general. This will reduce wasting of time and delving into multiporcessing more.
@till-m
Copy link
Collaborator

till-m commented Dec 21, 2022

I'm not sure why this is necessary. Could you explain?

@karunakar2
Copy link
Author

karunakar2 commented Dec 21, 2022

I'm not sure why this is necessary. Could you explain?

Hi Till,
Wondering if you could run a simple script on windows, without notebook, plain python with out the 'main' part. doesn't work for me.

import pandas as pd
from pandarallel import pandarallel
pandarallel.initialize()

def testFn(x):
    return (x.sepal_length*x.sepal_width)/(x.petal_length*x.petal_width)

#internet based iris data
myDf = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
print(myDf.head())

res = myDf.parallel_applymap(testFn,axis=1)
print(res)

@karunakar2
Copy link
Author

I'm not sure why this is necessary. Could you explain?

Hi Till, Wondering if you could run a simple script on windows, without notebook, plain python with out the 'main' part. doesn't work for me. import pandas as pd from pandarallel import pandarallel pandarallel.initialize()

def testFn(x): return (x.sepal_length_x.sepal_width)/(x.petal_length_x.petal_width)

#internet based iris data myDf = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv') print(myDf.head())

res = myDf.parallel_applymap(testFn,axis=1) print(res)

Please ignore if the intentions are only to use on jupyter notebooks. Thanks

@till-m
Copy link
Collaborator

till-m commented Jan 7, 2023

Apologies for getting back to you so late.
I think the problem here is using applymap instead of apply. Try this code:

import pandas as pd
from pandarallel import pandarallel
pandarallel.initialize()

def testFn(x):
    return (x.sepal_length*x.sepal_width)/(x.petal_length*x.petal_width)

#internet based iris data
myDf = pd.read_csv('https://raw.githubusercontent.com/mwaskom/seaborn-data/master/iris.csv')
print(myDf.head())

res = myDf.parallel_apply(testFn,axis=1)
print(res)

@till-m till-m closed this Jan 16, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants