Open reinzler opened 3 months ago
The example doesn't work if you don't have access to the Newton Raphson CSVs.
The example doesn't work if you don't have access to the Newton Raphson CSVs.
I reduced your code sample to the following:
import pandas as pd
from pandarallel import pandarallel
from spatialmath import SE3
# from Master10 import Master10DH
def ik(row):
# robot = Master10DH()
TEP = (SE3([row['x'], row['y'], row['z']]) * SE3.RPY([row['r'], row['p'], row['w']], unit="deg"))
return True, "Reason"
# sol1 = robot.ikine_NR(Tep)
# return (sol1.success, sol1.reason)
pandarallel.initialize(progress_bar=True, nb_workers=8)
df = pd.read_csv("data_300.csv")
try:
df[['solution', 'reason']] = df.parallel_apply(ik, axis=1)
except ValueError:
print("ValueError")
df['solution'] = df.parallel_apply(ik, axis=1)
Master10
seems to be a custom package for operating a robot, so I've commented that code out.
Upon inspection, it seems that if we DON'T use pandarallel, the code still runs twice.
It seems like you can fix your code by replacing df[['solution', 'reason']] = df.parallel_apply(ik, axis=1)
with df[['solution', 'reason']] = df.parallel_apply(ik, axis=1).tolist()
.
This is not a problem with pandarallel. Unless there is other information that suggests otherwise, this issue can be closed.
General
Bug description
The issue with pandarallel where a dataframe with 64000 rows is being processed twice can be described as follows:
Description: When using pandarallel to apply a function to a large dataframe with 64000 rows, the dataframe is processed twice instead of once. This results in redundant computation and potentially incorrect output. The dataframe is processed twice.![Снимок экрана 2024-04-04 143955](https://github.com/nalepae/pandarallel/assets/109457976/ba210954-7b4b-4503-ac96-d7adbceaf736)
Minimal but working code sample to ease bug fix for
pandarallel
team