def download(_):
     # For csv and html, the index must be removed to preserve the structure.
     if fmt in ["csv", "html", "excel"]:
         return dcc.send_data_frame(writer, filename, index=False)
     # For csv and html, the index must be removed to preserve the structure.
     if fmt in ["stata"]:
         a = dcc.send_data_frame(writer, filename, write_index=False)
         return a
     # For other formats, no modifications are needed.
     return dcc.send_data_frame(writer, filename)
    def _export_table_data(
        _data_requested: list,
        table_data: list,
        table_columns: list,
        button_ids: list,
        table_ids: list,
    ) -> Callable:

        ctx = dash.callback_context.triggered[0]
        export_clicks = {
            id_value["table_id"]: n_clicks
            for id_value, n_clicks in zip(button_ids, _data_requested)
        }
        table_to_extract = [
            x for x in export_clicks.keys() if x in ctx["prop_id"]
        ]
        if not table_to_extract or export_clicks[table_to_extract[0]] is None:
            raise PreventUpdate

        index = [x["table_id"] for x in table_ids].index(table_to_extract[0])
        table_data = table_data[index]
        table_columns = [x["name"] for x in table_columns[index]]

        return dcc.send_data_frame(
            pd.DataFrame(data=table_data, columns=table_columns).to_excel,
            "VolumetricAnalysis.xlsx",
            index=False,
        )
Пример #3
0
 def FUNCTION_DOWNLOAD_TABLE_COMPONENT_TAB1_BODY_CONTENT2(n, data):
     if n != 0 and data is not None:
         result = [
             dcc.send_data_frame(pd.DataFrame.from_dict(data).to_excel, "DataTable.xlsx", sheet_name="Sheet1", index=False),
             0
         ]
         return result
     else:
         raise PreventUpdate
Пример #4
0
        def func(n_clicks):
            global df2
            df2 = pd.DataFrame()
            header_list = ['expected', 'Predicted', 'F1Score']
            df2 = df2.reindex(columns=header_list)

            n = df.index[df['F1Score'] > float(0.8)]

            df2 = (df.iloc[n])
            df2['Predicted'] = df2['expected']
            return dcc.send_data_frame(df2.to_csv, "mydf_csv.csv")
Пример #5
0
def download_filtered_xlsx(n_clicks, jsonified_filtered_data):
    
    ## make sure that the button was clicked (we ignore the trigger event from altered data)
    changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
    
    if 'btn_filtered_xlsx' in changed_id:
        df_filter = pd.read_json(jsonified_filtered_data, orient='split')
        df_filter = df_filter.drop(columns = ['tree_dbh_vis'])
    
        return dcc.send_data_frame(df_filter.to_excel, "StreetTreesOfNYC_filtered.xlsx", sheet_name="Sheet_1")
    
    return
Пример #6
0
def download_graph_select_xlsx(n_clicks, tree_ids):
    
    ## make sure that the button was clicked (we ignore the trigger event from altered data)
    changed_id = [p['prop_id'] for p in dash.callback_context.triggered][0]
    
    if 'btn_graph_select_xlsx' in changed_id and tree_ids:
         
        df_filter = df[df['tree_id'].isin(tree_ids)]
        
        df_filter = df_filter.drop(columns = ['tree_dbh_vis'])
    
        return dcc.send_data_frame(df_filter.to_excel, "StreetTreesOfNYC_graph_select.xlsx", sheet_name="Sheet_1")
    
    return
Пример #7
0
def download_csv(n_clicks, subspace_data, qoi):
    # Parse data
    results = jsonpickle.decode(subspace_data)
    subspace = results['subspace']
    X_train = subspace.sample_points
    y_train = subspace.sample_outputs
    subdim = subspace.subspace_dimension
    W = subspace.get_subspace()[:, :subdim]
    u_train = X_train @ W

    # Build dataframe
    data = np.hstack([u_train, y_train.reshape(-1, 1)])
    cols = ['active dim. %d' % j for j in range(subdim)]
    cols.append(qoi)
    df = pd.DataFrame(data=data, columns=cols)

    return dcc.send_data_frame(df.to_csv, "reduced_results.csv")
def func(n_clicks):
    return dcc.send_data_frame(df.to_excel,
                               "mydf.xlxs",
                               sheet_name="Sheet_name_1")
Пример #9
0
def func(n_clicks):
    return dcc.send_data_frame(df.to_csv, "mydf.csv")
Пример #10
0
Файл: app.py Проект: Horoli/TIL
def download(n_clicks):
    return dcc.send_data_frame(df.to_csv, 'mydf.csv')
Пример #11
0
def download_all_xlsx(n_clicks):
    df_download = df.drop(columns = ['tree_dbh_vis'])
    return dcc.send_data_frame(df_download.to_excel, "StreetTreesOfNYC.xlsx", sheet_name="Sheet_1")
Пример #12
0
def download_all_csv(n_clicks):
    df_download = df.drop(columns = ['tree_dbh_vis'])
    return dcc.send_data_frame(df_download.to_csv, "StreetTreesOfNYC.csv")