Skip to content

Commit

Permalink
v4.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
chen-001 committed Apr 25, 2024
1 parent 3a071d5 commit 9e2767e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions pure_ocean_breeze/jason/data/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from typing import Callable, Union, Dict, List, Tuple
import joblib
import mpire
import statsmodels.formula.api as smf

from pure_ocean_breeze.jason.state.homeplace import HomePlace
from pure_ocean_breeze.jason.state.decorators import do_on_dfs
Expand Down Expand Up @@ -1257,13 +1258,14 @@ def de_cross(
# y = pure_fallmount(y)
# xs = [pure_fallmount(i) for i in xs]
# return (y - xs)()
df=merge_many([y]+xs)
df=merge_many([y]+xs,how='inner')
xs_str='+'.join([f'fac{i+2}' for i in range(len(xs))])
def sing(date:pd.Timestamp):
df0=df[df.date==date].set_index(['date','code'])
ols=smf.ols('fac1~'+xs_str,data=df0).fit()
df0.fac1=ols.resid
return df0[['fac1']]
if df0.shape[0]>0:
ols=smf.ols('fac1~'+xs_str,data=df0).fit()
df0.fac1=ols.resid
return df0[['fac1']]
dates=list(set(df.date))
with mpire.WorkerPool(20) as pool:
dfs=pool.map(sing,dates)
Expand Down

0 comments on commit 9e2767e

Please sign in to comment.