Options

data upsampling with python pandas

Katharina_MULKatharina_MUL Member Posts: 1 Learner I
edited July 2019 in Help

Hello,

 

so I have a little problem. I'd like to upsample my data (timestamp+9 attributes) with python pandas in RapidMiner. In Jupyter it's working fine, but as soon as I'm using the code in the "Execute Python" operator, it won't work. In the result, there a missing values and my timestamp is gone.

One big issue could be the timestamp. The format is like " YYYY-MM-dd HH:mm:ss.SSS" and I'd like to upsample the data to 100 ms. So RapidMiner doesn't show me the format, since it's cutting off the miliseconds.

Do you have any ideas?

Thanks!

 

Code for Jupyter:

import pandas as pd
df = pd.read_csv('aufgefuellt.csv', header=0, sep =';', parse_dates=True)
df['Datum'] = pd.to_datetime(df['Datum'], format='%d-%m-%Y %H:%M:%S.%f')
df.set_index('Datum')
df1 = df.reset_index().set_index('Datum').resample('0.1S').mean()
del df1['index']
df2=df1

 

Code in RapidMiner:

import pandas as pd
def rm_main(data):
data['timestamp'] = pd.to_datetime(data['timestamp'], format='%Y-%m-%d %H:%M:%S.%f')
df1 = data.reset_index().set_index('timestamp').resample('0.1S').mean()
return df1

 

 

 

 

Tagged:
Sign In or Register to comment.