Follwing code is working but producing always this error message.
A value is trying to be set on a copy of a slice from a DataFrame. Try using .loc[row_indexer,col_indexer] = value instead
def outliers_resultat_calcule (df):
max_995 = df.describe(percentiles=[.005, .5, .995]).loc[['max'],'RESULTAT_CALCULE']
max_995 = int(max_995)
min_005 = df.describe(percentiles=[.005, .5, .995]).loc[['min'],'RESULTAT_CALCULE']
min_005 = int(min_005)
for index, row in df.iterrows():
if row['RESULTAT_CALCULE'] > max_995:
row['RESULTAT_CALCULE'] = max_995
elif row['RESULTAT_CALCULE'] < min_005:
row['RESULTAT_CALCULE'] = min_005
df['Delta_Resultat_Calcule'] = df['RESULTAT_CALCULE'].shift(-1) - df['RESULTAT_CALCULE']
df['Delta_Resultat_Calcule'] = df['Delta_Resultat_Calcule'].shift(1)
return df
df_179_1 = outliers_resultat_calcule(df_179_1)