I'm trying to run a multiprocess task in a function that receives the dataframe and the condition and return a new dataframe.
My problem is that I receiving the "not supported instances of 'str' and 'int'
" when I call the function.
import multiprocessing
import pandas as pd
def operation(data, condition):
.
. No problem in the function since I tested it isolated
.
.
return pd.DataFrame(result_of_operation)
if __name__ == '__main__':
data = pd.read_csv(r"C:\Users\max\test.csv", index_col=False, encoding='UTF-8')
column_names = ["A", "B", "C"]
new_df = pd.DataFrame(columns = column_names)
condition = ['orange', 'banana', 'apple']
with multiprocessing.Pool(8) as p:
for x in range(0, len(condition)):
new_df.append(p.map(operation, data, condition[x]),ignore_index=True)
I believe it is a problem with my map
operation since it works if I call the function by itself, like:
for x in range(0, len(condition)):
new_df.append(operation(data, condition[x]),ignore_index=True)