<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Trust only up to three standard deviations.
Which is expected, ~75 euros difference from the original price is the maximum of what
normally see as a customer
Step1:  this is to trim according to minimum and maximum value
Step2:  another idea is to trim according to the rate of change
Step3:  and indeed those changing more than 75 euros / day are outliers
TODO maybe later we can filter those when choosing windows directly, because now we neglect entire time series
<ASSISTANT_TASK:>
Python Code:
stds_threshold = std*3
stds_threshold
min(df_norm_prices.iloc[0])
Explanation: Trust only up to three standard deviations.
Which is expected, ~75 euros difference from the original price is the maximum of what
normally see as a customer
End of explanation
keep_inds = [ii for ii in range(len(df_norm_prices))
     if max(df_norm_prices.iloc[ii]) < stds_threshold and 
             -stds_threshold < min(df_norm_prices.iloc[ii])
    ]
len(keep_inds)
Explanation: this is to trim according to minimum and maximum value
End of explanation
keep_inds = [ii for ii in range(len(df_norm_prices))
     if np.all(
            np.absolute(df_norm_prices.iloc[ii][1:] - 
                np.roll(df_norm_prices.iloc[ii], 1)[1:]) < stds_threshold
        )
    ]
len(keep_inds)
Explanation: another idea is to trim according to the rate of change
End of explanation
df_seq_start_trimmed = df_with_seq_start.iloc[keep_inds]
df_seq_start_trimmed.shape
flatvals2 = df_norm_prices.iloc[keep_inds].values.flatten()
len(flatvals2)
plt.figure(figsize=(15,6))
sns.distplot(flatvals2)
plt.show()
csv_path = "../price_history_03_seq_start_suddens_trimmed.csv"
df_seq_start_trimmed.to_csv(csv_path, encoding='utf-8', quoting=csv.QUOTE_ALL)
Explanation: and indeed those changing more than 75 euros / day are outliers
TODO maybe later we can filter those when choosing windows directly, because now we neglect entire time series
End of explanation
<END_TASK>