Can I read any file within the python script node....

import knime.scripting.io as knio

This example script creates an output table containing randomly drawn integers using numpy and pandas.

import pandas as pd
import numpy as np
#from sklearn.model_selection import train_test_split

df = pd.read_csv(‘C:\Users\sbatr\Downloads\discharge.csv’)

#df = df[(df[‘Battery’] == ‘B0005’) | (df[‘Battery’] == ‘B0006’)]
df = df[df[‘Battery’] == ‘B0005’]
df = df[df[‘Temperature_measured’] > 36] #choose battery B0005
#df[‘Time’] =pd.to_datetime(df[‘Time’], unit=‘s’)
#sorted_df=df.sort_values(by=[‘Battery’, ‘id_cycle’])
#dfb=sorted_df.groupby(‘Battery’).max()
#dfc = dfb.groupby([‘Battery’]).mean()
dfb = df.groupby([‘id_cycle’]).max()
dfb[‘Cumulated_T’] = dfb[‘Time’].cumsum()

knio.output_tables[0] = knio.Table.from_pandas(dfb)

#df1 = pd.DataFrame()

Dear @SJAAB,

what exactly is your question?

Is your code not working? I don’t see why it should not. I attached a working example (You will need to adjust the paths though).

And please format code.
Screenshot 2023-10-19 at 14.38.14

Steffen
SJAAB.knwf (79.3 KB)

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.