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

Function plot_df

process.py:279–314  ·  view source on GitHub ↗
(df, tickers_numb=7, tail_numb=100)

Source from the content-addressed store, hash-verified

277
278
279def plot_df(df, tickers_numb=7, tail_numb=100):
280
281 df_count_sum = df.groupby('tickers')['count'].cumsum()
282 l0_index = df_count_sum.sort_values(ascending=False).index.get_level_values(0).unique()[0:tickers_numb]
283
284 df_count_sum = df_count_sum[l0_index]
285 df_count_bar = df['count'][l0_index]
286 df_count_sum = df_count_sum.groupby(level=0).tail(tail_numb)
287
288 df_graph_df = df_count_sum.reset_index().pivot('created', 'tickers', 'count')
289
290 fig, ax = plt.subplots()
291
292 dates = mdates.drange(df_graph_df.index[0], df_graph_df.index[-1], datetime.timedelta(minutes=30))
293
294 df_graph_df_diff = df_graph_df.diff()
295 """
296 amount_ticks = min(5, tickers_numb)
297 width = 1/amount_ticks
298 colors = ['red', 'green', 'blue', 'yellow', 'purple']
299 plots = []
300 for idx, col in enumerate(df_graph_df_diff.columns):
301 if(idx >= amount_ticks):
302 break
303 idxx = idx - int(amount_ticks/2)
304 plots.append(ax.bar(np.arange(20)+width*idxx , df_graph_df_diff[col].values, align='center', width=width, color=colors[idxx], label=str(col)))
305 """
306 #ax.set(xticks=np.arange(20), xticklabels=df_graph_df.index) #Same as plt.xticks
307
308 #fig.autofmt_xdate()
309 #plt.legend(handles=plots)
310 #df_graph_df.plot()
311 #ax.plot(df_graph_df, label=df_graph_df.columns)
312 df_graph_df.plot(ax=ax)
313
314 return fig
315
316
317def processed_df():

Callers 1

processed_dfFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected