Quantcast
Channel: Node Development - KNIME Community Forum
Viewing all articles
Browse latest Browse all 81

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

$
0
0

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()

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 81

Trending Articles