print(datadf) with tqdm(total=len(factordf)) as pbar: def calcfactor(window):…
- User
print(data_df) with tqdm(total=len(factor_df)) as pbar: def calc_factor(window): pbar.update(1) if window.isnull().sum() < 15: return np.nan return window.std()
codedef calc_series(series): return series.rolling(window=31, min_periods=15).apply(calc_factor) data_df["68_volatility_monthly_raw"] = data_df.groupby("stock_id")["daily_return"].transform(lambda x: calc_series(x))Add a condition for function "calc_factor": If the number of values 0 is greater than 10, then return np.nan
Assistant
python
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.