Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,7 +22,7 @@ def encrypt_data_a(pp):
|
|
| 22 |
for col in integer_columns:
|
| 23 |
dataset_1[col] = dataset_1[col].apply(lambda x: phe1.encrypt(public_key, int(x)))
|
| 24 |
|
| 25 |
-
return dataset_1.head().to_markdown(), gr.Dropdown(choices=list(dataset_1.columns))
|
| 26 |
|
| 27 |
def display_csv_b():
|
| 28 |
global dataset_2
|
|
@@ -39,16 +39,23 @@ def encrypt_data_b(pp):
|
|
| 39 |
for col in integer_columns:
|
| 40 |
dataset_2[col] = dataset_2[col].apply(lambda x: phe1.encrypt(public_key, int(x)))
|
| 41 |
|
| 42 |
-
return dataset_2.head().to_markdown(), gr.Dropdown(choices=list(dataset_2.columns))
|
| 43 |
|
| 44 |
|
| 45 |
-
def join_data(column_a, column_b, pp):
|
| 46 |
global joined_data
|
| 47 |
joined_data = pd.merge(dataset_1, dataset_2, left_on=column_a, right_on=column_b, how="inner")
|
| 48 |
-
return joined_data.head().to_markdown(), gr.Dropdown(choices=list(joined_data.columns))
|
| 49 |
|
| 50 |
|
| 51 |
-
def process_data(agg_column, agg_type):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 52 |
if agg_type == "Average" or agg_type == "Sum":
|
| 53 |
|
| 54 |
encrypted_column_values = joined_data[agg_column].tolist()
|
|
@@ -103,22 +110,34 @@ with gr.Blocks() as app:
|
|
| 103 |
|
| 104 |
join_button = gr.Button("Perform Join")
|
| 105 |
joined_output = gr.Markdown()
|
|
|
|
| 106 |
agg_column = gr.Dropdown(label="Select Aggregation Column")
|
| 107 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
join_button.click(
|
| 109 |
join_data,
|
| 110 |
-
inputs=[column_a, column_b, agg_column],
|
| 111 |
-
outputs=[joined_output, agg_column]
|
| 112 |
)
|
| 113 |
|
| 114 |
-
agg_type = gr.Dropdown(label="Select Aggregation Function", choices=["Sum", "Average", "Count"], value="Average")
|
| 115 |
process_button = gr.Button("Aggregation Result")
|
| 116 |
|
| 117 |
result_output = gr.Textbox(label="Aggregation Result")
|
| 118 |
|
| 119 |
process_button.click(
|
| 120 |
process_data,
|
| 121 |
-
inputs=[agg_column, agg_type],
|
| 122 |
outputs=[result_output]
|
| 123 |
)
|
| 124 |
|
|
|
|
| 22 |
for col in integer_columns:
|
| 23 |
dataset_1[col] = dataset_1[col].apply(lambda x: phe1.encrypt(public_key, int(x)))
|
| 24 |
|
| 25 |
+
return dataset_1.head().to_markdown(), gr.Dropdown(choices=list(dataset_1.columns))
|
| 26 |
|
| 27 |
def display_csv_b():
|
| 28 |
global dataset_2
|
|
|
|
| 39 |
for col in integer_columns:
|
| 40 |
dataset_2[col] = dataset_2[col].apply(lambda x: phe1.encrypt(public_key, int(x)))
|
| 41 |
|
| 42 |
+
return dataset_2.head().to_markdown(), gr.Dropdown(choices=list(dataset_2.columns))
|
| 43 |
|
| 44 |
|
| 45 |
+
def join_data(column_a, column_b, pp, gg):
|
| 46 |
global joined_data
|
| 47 |
joined_data = pd.merge(dataset_1, dataset_2, left_on=column_a, right_on=column_b, how="inner")
|
| 48 |
+
return joined_data.head().to_markdown(), gr.Dropdown(choices=list(joined_data.columns)), gr.Dropdown(choices=list(joined_data.columns))
|
| 49 |
|
| 50 |
|
| 51 |
+
def process_data(agg_column, agg_type, cond_column, cond_operator, cond_value):
|
| 52 |
+
|
| 53 |
+
global joined_data
|
| 54 |
+
|
| 55 |
+
if cond_value:
|
| 56 |
+
hashed_cond_value = OPRF.get_hash(str(cond_value), hash_key)
|
| 57 |
+
joined_data = joined_data[joined_data[cond_column] == hashed_cond_value]
|
| 58 |
+
|
| 59 |
if agg_type == "Average" or agg_type == "Sum":
|
| 60 |
|
| 61 |
encrypted_column_values = joined_data[agg_column].tolist()
|
|
|
|
| 110 |
|
| 111 |
join_button = gr.Button("Perform Join")
|
| 112 |
joined_output = gr.Markdown()
|
| 113 |
+
|
| 114 |
agg_column = gr.Dropdown(label="Select Aggregation Column")
|
| 115 |
|
| 116 |
+
agg_type = gr.Dropdown(label="Select Aggregation Function", choices=["Sum", "Average", "Count"], value="Average")
|
| 117 |
+
|
| 118 |
+
with gr.Row():
|
| 119 |
+
with gr.Column():
|
| 120 |
+
cond_column = gr.Dropdown(label="Select Condition Column")
|
| 121 |
+
|
| 122 |
+
with gr.Column():
|
| 123 |
+
cond_operator = gr.Dropdown(label="Select Function", choices=["<", ">", "="], value="<")
|
| 124 |
+
|
| 125 |
+
with gr.Column():
|
| 126 |
+
cond_value = gr.Textbox(label="Enter Value")
|
| 127 |
+
|
| 128 |
join_button.click(
|
| 129 |
join_data,
|
| 130 |
+
inputs=[column_a, column_b, agg_column, cond_column],
|
| 131 |
+
outputs=[joined_output, agg_column, cond_column]
|
| 132 |
)
|
| 133 |
|
|
|
|
| 134 |
process_button = gr.Button("Aggregation Result")
|
| 135 |
|
| 136 |
result_output = gr.Textbox(label="Aggregation Result")
|
| 137 |
|
| 138 |
process_button.click(
|
| 139 |
process_data,
|
| 140 |
+
inputs=[agg_column, agg_type, cond_column, cond_operator, cond_value],
|
| 141 |
outputs=[result_output]
|
| 142 |
)
|
| 143 |
|