Pandas Data Re-arrangement
I am working on sport. The purpose is to record current eventdatetime and PreviousEventTime in a game. I have a sample dataset in the below link. https://drive.google.com/open?id=1
Solution 1:
First you have to load your dataset into pandas dataframe after we can use shift method.
last_val=df["Time"].iloc[-1]
df['second_eventime']=df['Time'].shift(-1) #This will leave last column value as blank
df.iloc[-1, df.columns.get_loc('second_eventime')] = last_val #To Maintain the value at last row
Post a Comment for "Pandas Data Re-arrangement"