Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,7 @@ import warnings
|
|
5 |
|
6 |
warnings.filterwarnings(action='ignore', category=UserWarning)
|
7 |
|
8 |
-
plt.rcParams['font.sans-serif'] = ['
|
9 |
plt.rcParams['axes.unicode_minus'] = False # 设置正常显示字符
|
10 |
|
11 |
def process_file(file):
|
@@ -38,7 +38,13 @@ def update_slider(choice):
|
|
38 |
return gr.update(visible=choice == "是")
|
39 |
|
40 |
def generate_output(file, column1, column2, choice, bins):
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
data_x = df[column1]
|
43 |
data_y = df[column2]
|
44 |
|
|
|
5 |
|
6 |
warnings.filterwarnings(action='ignore', category=UserWarning)
|
7 |
|
8 |
+
plt.rcParams['font.sans-serif'] = ['SimHei.ttf'] # 选择合适的中文字体
|
9 |
plt.rcParams['axes.unicode_minus'] = False # 设置正常显示字符
|
10 |
|
11 |
def process_file(file):
|
|
|
38 |
return gr.update(visible=choice == "是")
|
39 |
|
40 |
def generate_output(file, column1, column2, choice, bins):
|
41 |
+
# 读取CSV或Excel文件并创建DataFrame
|
42 |
+
if file.name.endswith('.csv'):
|
43 |
+
df = pd.read_csv(file.name)
|
44 |
+
elif file.name.endswith('.xlsx') or file.name.endswith('.xls'):
|
45 |
+
df = pd.read_excel(file.name)
|
46 |
+
else:
|
47 |
+
return "不支持的数据文件格式。"
|
48 |
data_x = df[column1]
|
49 |
data_y = df[column2]
|
50 |
|