def makeTable(df, width, ID1, ID2): ''' df: DataFrame, which contain the cartographical information width: float/int, giving the width of the table ID1: str, str provides the the ID of the first dataset ID2: str or None, use None if no second ID is provided, str provides the the ID of the second dataset ''' table = PreText(text="", width=width) if not ID2: table.text = str(df.loc[[ID1]].T) else: table.text = str(df.loc[ID1:ID2].T) return table
def stock2(ticker1, ticker2): pretext = PreText(text="", width=500) df = get_data(ticker1, ticker2) source = ColumnDataSource(data=df) source.tags = ['main_source'] p = figure( title="%s vs %s" % (ticker1, ticker2), plot_width=400, plot_height=400, tools="pan,wheel_zoom,box_select,reset", title_text_font_size="10pt", ) p.circle(ticker1 + "_returns", ticker2 + "_returns", size=2, nonselection_alpha=0.02, source=source ) stats = df.describe() pretext.text = str(stats) hist1 = hist_plot(df, ticker1) hist2 = hist_plot(df, ticker2) line1 = line_plot(ticker1, source) line2 = line_plot(ticker2, source, line1.x_range) return dict(scatterplot=p, statstext=pretext, hist1=hist1, hist2=hist2, line1=line1, line2=line2)
def stock(ticker1, ticker2): pretext = PreText(text="", width=500) df = get_data(ticker1, ticker2) source = ColumnDataSource(data=df) source.tags = ['main_source'] p = figure( title="%s vs %s" % (ticker1, ticker2), plot_width=400, plot_height=400, tools="pan,wheel_zoom,box_select,reset", title_text_font_size="10pt", ) p.circle(ticker1 + "_returns", ticker2 + "_returns", size=2, nonselection_alpha=0.02, source=source ) stats = df.describe() pretext.text = str(stats) row1 = HBox(children=[p, pretext]) hist1 = hist_plot(df, ticker1) hist2 = hist_plot(df, ticker2) row2 = HBox(children=[hist1, hist2]) line1 = line_plot(ticker1, source) line2 = line_plot(ticker2, source, line1.x_range) output = VBox(children=[row1, row2, line1, line2]) return output
def stock2(ticker1, ticker2): pretext = PreText(text="", width=500) df = get_data(ticker1, ticker2) source = ColumnDataSource(data=df) source.tags = ['main_source'] p = figure( title="%s vs %s" % (ticker1, ticker2), plot_width=400, plot_height=400, tools="pan,wheel_zoom,box_select,reset", title_text_font_size="10pt", ) p.circle(ticker1 + "_returns", ticker2 + "_returns", size=2, nonselection_alpha=0.02, source=source) stats = df.describe() pretext.text = str(stats) hist1 = hist_plot(df, ticker1) hist2 = hist_plot(df, ticker2) line1 = line_plot(ticker1, source) line2 = line_plot(ticker2, source, line1.x_range) return dict(scatterplot=p, statstext=pretext, hist1=hist1, hist2=hist2, line1=line1, line2=line2)
def stock(ticker1, ticker2): pretext = PreText(text="", width=500) df = get_data(ticker1, ticker2) source = ColumnDataSource(data=df) source.tags = ['main_source'] p = figure( title="%s vs %s" % (ticker1, ticker2), plot_width=400, plot_height=400, tools="pan,wheel_zoom,box_select,reset", title_text_font_size="10pt", ) p.circle(ticker1 + "_returns", ticker2 + "_returns", size=2, nonselection_alpha=0.02, source=source) stats = df.describe() pretext.text = str(stats) row1 = HBox(children=[p, pretext]) hist1 = hist_plot(df, ticker1) hist2 = hist_plot(df, ticker2) row2 = HBox(children=[hist1, hist2]) line1 = line_plot(ticker1, source) line2 = line_plot(ticker2, source, line1.x_range) output = VBox(children=[row1, row2, line1, line2]) return output
x='ds', y='trend', line_width=1, alpha=0.5, color='firebrick', line_dash="6 4") # ogarka p.xgrid.grid_line_color = None p.x_range.range_padding = 0.1 p.xaxis.major_label_orientation = 1 p.yaxis.formatter = NumeralTickFormatter(format="0,0") stats = PreText(text='', height=500, width=600) prep = pd.DataFrame(forecast_filtered_2, columns=['ds', 'yhat']) stats.text = str(prep[prep['ds'] >= '2018-03-14']) # main_row = row(p, stats) # series = row(p, stats) # layout = column(main_row, series) curdoc().add_root(row(p, stats)) curdoc().title = "Prognoza GMV - Zestawy" # show(p) # # wydruk sum dla prognozy i zapis do pliku .csv # print(forecast_filtered_2[['ds', 'yhat', 'yhat_lower', 'yhat_upper']]) # forecast_filtered_2[['ds', 'yhat', 'yhat_lower', 'yhat_upper']].to_csv('output_20180302.csv', sep=',') # print('mid: ' + str(round(sum(forecast_filtered_2['yhat']) + 10329770))) # print('low: ' + str(round(sum(forecast_filtered_2['yhat_lower']) + 10329770)))
ticker1.on_change('value', ticker1_change) X_Metadata_broad_sample=ticker1.value.split('__')[0] X_Metadata_mmoles_per_liter=ticker1.value.split('__')[1].split(' ')[0] df_to_disp=meta_lincs2[(meta_lincs2["Metadata_broad_sample"]==X_Metadata_broad_sample) &\ (meta_lincs2["Metadata_mmoles_per_liter"]==float(X_Metadata_mmoles_per_liter))].reset_index(drop=True) fS=create_figure(df_to_disp) stats2_df=drug_list_rank[(drug_list_rank["Metadata_broad_sample"]==X_Metadata_broad_sample) &\ (drug_list_rank["Metadata_mmoles_per_liter"]==float(X_Metadata_mmoles_per_liter))].T stats2.text = str(stats2_df) # set up layout # fS,notes=create_figure() # fS=[] # series = row(children=[ticker1]+[fS]) series = row(children=[column(children=[ticker1,stats2])]+[fS]) layoutt = column(series) # initialize # update() curdoc().add_root(layoutt) # curdoc().title = "Rosetta Eval"
question_2 = Div(text='<h2>Are there any noteworthy differences/anomalies ' + 'in the top 200 universities of the world?</h2>', width=1000, height=100) # on change switch values continent_select.on_change('value', drop_change) correlation_select.on_change('value', correlation_change) pyramid_year_select.on_change('value', year_change) pyramid_xaxis_slider.on_change('value', year_change) histogram_year_select.on_change('value', hist_year_change) map_dropdown.on_change('value', map_handler) gdp_correlation_select.on_change('value', gdp_correlation_change) # gets static plot and table string from helper.py static_col, static_table_data = helper.bar_chart_continent_split() static_table.text = str(static_table_data) # lays out the widgets and columss non_static_row = row(column_bar_split, table) static_row = row(static_col, static_table) map_column = column(map_dropdown, world_map_div) main_column = column(continent_select, non_static_row, static_row) main_column = column(question_1, main_column) correlation_column = column(correlation_select, correlation) pyramid_plot = gridplot([[pyramid_left, pyramid_right]], border_space=0) pyramid_plot_slider = row(pyramid_plot, pyramid_xaxis_slider) pyramid_column = column(pyramid_year_select, pyramid_plot_slider) pyramid_row = row(pyramid_column) correlations_200 = row(correlation_column, pyramid_row) correlations_200 = column(question_2, correlations_200)