Commit 4517ca55 authored by Dr.李's avatar Dr.李

dropna value

parent ed1f44d9
......@@ -481,7 +481,7 @@ class SqlEngine(object):
)
df = pd.read_sql(query, self.engine).sort_values(['trade_date', 'code'])
return df
return pd.merge(df, codes[['trade_date', 'code']], how='inner')
def fetch_benchmark(self,
ref_date: str,
......
......@@ -106,6 +106,7 @@ def prepare_data(engine: SqlEngine,
df = pd.merge(df, benchmark_df, on=['trade_date', 'code'], how='left')
df = pd.merge(df, industry_df, on=['trade_date', 'code'])
df['weight'] = df['weight'].fillna(0.)
df.dropna(inplace=True)
return dates, df[['trade_date', 'code', 'dx']], df[
['trade_date', 'code', 'weight', 'isOpen', 'industry_code', 'industry'] + transformer.names]
......@@ -400,8 +401,10 @@ def fetch_predict_phase(engine,
else:
train_x = pd.merge(factor_df, target_df, on=['trade_date', 'code'], how='left')
risk_exp = None
train_x.dropna(inplace=True)
x_values = train_x[names].values.astype(float)
y_values = train_x['dx'].values.astype(float)
y_values = train_x[['dx']].values.astype(float)
date_label = pd.DatetimeIndex(train_x.trade_date).to_pydatetime()
dates = np.unique(date_label)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment