Update app.py
Browse files
app.py
CHANGED
@@ -1,24 +1,15 @@
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
temp_file_path = tmp_file.name
|
15 |
-
|
16 |
-
# 一時ファイルのパスを返却
|
17 |
-
return temp_file_path
|
18 |
-
|
19 |
-
iface = gr.Interface(fn=process_csv,
|
20 |
-
inputs=gr.File(label="Upload CSV"),
|
21 |
-
outputs=gr.File(label="Download Processed CSV", type="file"), # 'type'を'file'に設定
|
22 |
-
description="Upload a CSV with 'name' and 'age' columns. This app will double the 'age' and let you download the processed CSV.")
|
23 |
|
24 |
iface.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import pandas as pd
|
3 |
+
def double_age(dataframe):
|
4 |
+
# 'age'列を2倍にする
|
5 |
+
dataframe['age'] = dataframe['age'] * 2
|
6 |
+
# 結果をCSV形式で返す
|
7 |
+
return dataframe.to_csv(index=False)
|
8 |
+
iface = gr.Interface(
|
9 |
+
fn=double_age,
|
10 |
+
inputs=gr.Dataframe(headers=["name", "age"], datatype=["str", "number"], row_count=5, col_count=(2, "fixed")),
|
11 |
+
outputs="text",
|
12 |
+
description="Upload a CSV file with 'name' and 'age' columns, and download the modified CSV file with 'age' doubled."
|
13 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
iface.launch()
|