I have a panda dataframe df with column DIFF_HOURS:
I do this code:
for i in range(0, 72, 6):
df.loc[(df['DIFF_HOURS'] > i) & (df['DIFF_HOURS'] <= (i 6))]['DIFF_HOURS'].apply(lambda x: i)
But how to modify df rows inplace please with respect indexes?
CodePudding user response:
Try adding assignment
df.loc[(df['DIFF_HOURS'] > i) & (df['DIFF_HOURS'] <= (i 6)), 'DIFF_HOURS'] = df.loc[(df['DIFF_HOURS'] > i) & (df['DIFF_HOURS'] <= (i 6))]['DIFF_HOURS'].apply(lambda x: i)