i need actual_new column from actual in pandas dataframe.
start time end time actual actual_new
4/1/2022 20:00 4/1/2022 21:00 0.749123 0.749123
4/1/2022 21:00 4/1/2022 22:00 0.749123 0.770175
4/1/2022 22:00 4/1/2022 23:00 0.749123 0.725439
4/1/2022 23:00 4/2/2022 0:00 0.749123 0.659649
4/2/2022 0:00 4/2/2022 1:00 0.749123 0.245614
4/2/2022 1:00 4/2/2022 2:00 0.749123 0.078947
4/1/2022 21:00 4/1/2022 22:00 0.770175 0.749123
4/1/2022 22:00 4/1/2022 23:00 0.770175 0.770175
4/1/2022 23:00 4/2/2022 0:00 0.770175 0.725439
4/2/2022 0:00 4/2/2022 1:00 0.770175 0.659649
4/2/2022 1:00 4/2/2022 2:00 0.770175 0.245614
4/2/2022 2:00 4/2/2022 3:00 0.770175 0.078947
4/1/2022 22:00 4/1/2022 23:00 0.725439 0.749123
4/1/2022 23:00 4/2/2022 0:00 0.725439 0.770175
4/2/2022 0:00 4/2/2022 1:00 0.725439 0.725439
4/2/2022 1:00 4/2/2022 2:00 0.725439 0.659649
4/2/2022 2:00 4/2/2022 3:00 0.725439 0.245614
4/2/2022 3:00 4/2/2022 4:00 0.725439 0.078947
4/1/2022 23:00 4/2/2022 0:00 0.659649 0.749123
4/2/2022 0:00 4/2/2022 1:00 0.659649 0.770175
4/2/2022 1:00 4/2/2022 2:00 0.659649 0.725439
4/2/2022 2:00 4/2/2022 3:00 0.659649 0.659649
4/2/2022 3:00 4/2/2022 4:00 0.659649 0.245614
4/2/2022 4:00 4/2/2022 5:00 0.659649 0.078947
4/2/2022 0:00 4/2/2022 1:00 0.245614 0.749123
4/2/2022 1:00 4/2/2022 2:00 0.245614 0.770175
4/2/2022 2:00 4/2/2022 3:00 0.245614 0.725439
4/2/2022 3:00 4/2/2022 4:00 0.245614 0.659649
4/2/2022 4:00 4/2/2022 5:00 0.245614 0.245614
4/2/2022 5:00 4/2/2022 6:00 0.245614 0.078947
4/2/2022 1:00 4/2/2022 2:00 0.078947 0.749123
4/2/2022 2:00 4/2/2022 3:00 0.078947 0.770175
4/2/2022 3:00 4/2/2022 4:00 0.078947 0.725439
4/2/2022 4:00 4/2/2022 5:00 0.078947 0.659649
4/2/2022 5:00 4/2/2022 6:00 0.078947 0.245614
4/2/2022 6:00 4/2/2022 7:00 0.078947 0.078947
CodePudding user response:
df['actual_new'] = list(df['actual'].unique())*int(df.shape[0]/len(uniques))
CodePudding user response:
Try this way:
df['actual_new'] = df['actual']
or
df['actual_new'] = df.apply(lambda x: x['actual'], axis = 1)