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

removed unnecessary parallize_on_rows function from multiprocessing e… #31

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 5 additions & 7 deletions examples/pandas-multiprocessing-example.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# from: https://gist.github.com/ishiland/824ddd386fcd0b90fc55aea573a28b22
# written by ishiland: https://github.com/ishiland
# Minor edits by torreyma: https://github.com/torreyma
# derived from: https://stackoverflow.com/a/53135031/3641153
# minor edits by torreyma: https://github.com/torreyma
#
from geosupport import Geosupport, GeosupportError
import pandas as pd
Expand All @@ -14,7 +15,8 @@

# For Windows:
g = Geosupport(geosupport_path="C:\\Program Files (x86)\\Geosupport Desktop Edition")
# On linux, geosupport location is set in environment variables GEOFILES and LD_LIBRARY_PATH.
# On linux: comment above line and uncomment line below. Set environment variables GEOFILES and LD_LIBRARY_PATH to indicate location of the fls/ and lib/ directories.
# g = Geosupport()

cpus = cpu_count()

Expand Down Expand Up @@ -52,17 +54,13 @@ def run_on_subset(func, data_subset):
return data_subset.apply(func, axis=1)


def parallelize_on_rows(data, func, num_of_processes=cpus):
return parallelize(data, partial(run_on_subset, func), num_of_processes)


if __name__ == '__main__':

# read in csv
df = pd.read_csv('INPUT.csv')

# add 3 Geosupport columns - Latitude, Longitude and Geosupport message
df[['lat', 'lon', 'msg']] = parallelize_on_rows(df, geo_by_address)
df[['lat', 'lon', 'msg']] = parallelize(df, partial(run_on_subset, geo_by_address))

# output to csv with the 3 new columns.
df.to_csv('OUTPUT.csv')
Expand Down