Skip to content

Commit

Permalink
supress setwithcopy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
qianyun210603 committed Oct 3, 2023
1 parent 996df8a commit ebaf3df
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions qlib/data/dataset/processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ def __call__(self, df):
# So we use numpy to accelerate filling values
nan_select = np.isnan(df.values)
nan_select[:, ~df.columns.isin(cols)] = False
df[nan_select] = self.fill_value
# depress warning by references:
# https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas
# https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html#getting-and-setting-options
with pd.option_context("mode.chained_assignment", None):
df[nan_select] = self.fill_value

return df

Expand Down Expand Up @@ -318,7 +322,11 @@ def __call__(self, df):
X /= self.std_train
if self.clip_outlier:
X = np.clip(X, -3, 3)
df[self.cols] = X
# depress warning by references:
# https://stackoverflow.com/questions/20625582/how-to-deal-with-settingwithcopywarning-in-pandas
# https://pandas.pydata.org/pandas-docs/stable/user_guide/options.html#getting-and-setting-options
with pd.option_context("mode.chained_assignment", None):
df[self.cols] = X
return df


Expand Down

0 comments on commit ebaf3df

Please sign in to comment.