Options

Change code to operators

Kumar_AyushKumar_Ayush Member Posts: 7 Newbie
def rm_main(data):
# Step 1: Get the last value in the "Time" column
data = pd.DataFrame(data)
last_time = data['Time-0-0'].iloc[-1]
# Step 2: Convert "Time" to timedelta and subtract last_time from each value in "End_Date_Time"
data["Time_Stamp"] = data.apply(lambda row : datetime.strptime(row["End_Date_Time"],"%Y/%m/%d %H:%M:%S")- timedelta(minutes=last_time),axis=1)
# Step 3: Iterate through all the rows and add "Time" to "Time_stamp"
data["Time_Stamp"] = data.apply(lambda row : row["Time_Stamp"] + timedelta(minutes=row['Time-0-0']),axis=1)
data["Time_Stamp"] = data["Time_Stamp"].apply(lambda x: x.replace(microsecond=0))
data["Time_Stamp"] = data["Time_Stamp"] - timedelta(hours=5, minutes=30)

return data

Answers

  • Options
    MartinLiebigMartinLiebig Administrator, Moderator, Employee, RapidMiner Certified Analyst, RapidMiner Certified Expert, University Professor Posts: 3,516 RM Data Scientist
    Hi there,
    I am sorry, but what is the question here?
    BR,
    Martin
    - Sr. Director Data Solutions, Altair RapidMiner -
    Dortmund, Germany
Sign In or Register to comment.