MCPcopy Create free account
hub / github.com/GonVas/tickerrain / timed_processing

Function timed_processing

test.py:146–162  ·  view source on GitHub ↗
(time_mins=360)

Source from the content-addressed store, hash-verified

144
145
146def timed_processing(time_mins=360):
147
148 df = pd.read_csv('all_data.csv')
149
150 df['tickers'] = df.apply(lambda row: process_tickers(row.body), axis=1)
151 df["ents"], df["sentiment"] = zip(*df.apply(nlp_processing, axis=1))
152 df['created'] = df['created'].apply(lambda created: pd.Timestamp(created, unit='s'))
153
154 data_df = df.filter(['tickers', 'score', 'sentiment', 'created'])
155 data_df['score'] = data_df.score.astype(np.int32)
156
157 ex_tickers = data_df.explode('tickers').dropna()
158 ex_tickers['sentiment'] = ex_tickers['sentiment'].apply(lambda row: row['compound'])
159 ex_tickers['count'] = 1
160 tks_group_6hours = ex_tickers.groupby(['tickers', pd.Grouper(key='created', freq=f'{time_mins}Min')])
161 timed_df = pd.concat([tks_group_6hours['count'].count(), tks_group_6hours['sentiment'].mean(), tks_group_6hours['score'].sum()], axis=1)
162 return timed_df.astype(np.float32)

Callers

nothing calls this directly

Calls 1

process_tickersFunction · 0.70

Tested by

no test coverage detected