Hi,
After modyfing my data table in the Python Script (Labs) node i get an “Execute failed: Error during deserialization” error on the subsequent node (I tested Rule Engine and CSV Writer).
Does anyone have a hint for this?
Code:
import knime_io as knio
import numpy as np
import pandas as pd
# Limit values
RO5 = {"MW":500, "CLogP":5, "HBA":10, "HBD":5}
RO3 = {"MW":300, "CLogP":3, "HBA":3, "HBD":3}
VEBER = {"nRotB":10, "TPSA":140, "SumHB":12}
def calculate_violations(df: pd.DataFrame, prop:dict):
violations = np.zeros(df.shape[0]).astype(int)
for key, value in prop.items():
violations += list(map(int,(df[key] > value)))
return violations.astype(int)
print(knio.input_tables[0])
df = knio.input_tables[0].to_pandas()
#print(df.loc[:,"ExactMW"])
# Create new columns for SumHB, Ro5, Ro3, Veber's Violations
df = df.assign(SumHB = lambda x: x.HBD + x.HBA)
df = df.assign(Ro5 = calculate_violations(df, RO5))
df = df.assign(Ro3 = calculate_violations(df, RO3))
df = df.assign(Vebers = calculate_violations(df, VEBER))
print(df.loc[:,["SumHB","Ro5", "Ro3", "Vebers"]])
# Output the modified DataTable to Knime.
knio.output_tables[0] = knio.write_table(df)
ERROR:
Gianluca