🎉Community Raffle - Win $25

An exclusive raffle opportunity for active members like you! Complete your profile, answer questions and get your first accepted badge to enter the raffle.
Join and Win

Change code to operators

User: "Kumar_Ayush"
New Altair Community Member
Updated by Jocelyn
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

Find more posts tagged with

Sort by:
1 - 1 of 11