kedimestan commited on
Commit
ca1f7a3
·
verified ·
1 Parent(s): db9d1b2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -5,15 +5,15 @@ import matplotlib.pyplot as plt
5
  def update_dropdowns(file):
6
  if file is None:
7
  return gr.Dropdown(choices=[]), gr.Dropdown(choices=[])
8
- df = pd.read_csv(file.name)
9
  columns = list(df.columns)
10
  return gr.Dropdown(choices=columns), gr.Dropdown(choices=columns)
11
 
12
  def create_scatter_plot(file, x_col, y_col):
13
- if file is None or not x_col or not y_col:
14
  return None
15
 
16
- df = pd.read_csv(file.name)
17
 
18
  plt.figure(figsize=(10, 6))
19
  plt.scatter(df[x_col], df[y_col])
@@ -29,7 +29,7 @@ with gr.Blocks() as app:
29
  gr.Markdown("# CSV Veri Görselleştirme Aracı")
30
 
31
  with gr.Row():
32
- csv_file = gr.File(label="CSV Dosyası Yükle", type="file")
33
 
34
  with gr.Row():
35
  x_axis = gr.Dropdown(label="X Ekseni Parametresi", interactive=True)
@@ -40,14 +40,12 @@ with gr.Blocks() as app:
40
  with gr.Row():
41
  plot_output = gr.Image(label="Scatter Plot")
42
 
43
- # Dropdown'ları güncelleme
44
  csv_file.change(
45
  fn=update_dropdowns,
46
  inputs=csv_file,
47
  outputs=[x_axis, y_axis]
48
  )
49
 
50
- # Plot oluşturma
51
  plot_button.click(
52
  fn=create_scatter_plot,
53
  inputs=[csv_file, x_axis, y_axis],
 
5
  def update_dropdowns(file):
6
  if file is None:
7
  return gr.Dropdown(choices=[]), gr.Dropdown(choices=[])
8
+ df = pd.read_csv(file)
9
  columns = list(df.columns)
10
  return gr.Dropdown(choices=columns), gr.Dropdown(choices=columns)
11
 
12
  def create_scatter_plot(file, x_col, y_col):
13
+ if not file or not x_col or not y_col:
14
  return None
15
 
16
+ df = pd.read_csv(file)
17
 
18
  plt.figure(figsize=(10, 6))
19
  plt.scatter(df[x_col], df[y_col])
 
29
  gr.Markdown("# CSV Veri Görselleştirme Aracı")
30
 
31
  with gr.Row():
32
+ csv_file = gr.File(label="CSV Dosyası Yükle", type="filepath")
33
 
34
  with gr.Row():
35
  x_axis = gr.Dropdown(label="X Ekseni Parametresi", interactive=True)
 
40
  with gr.Row():
41
  plot_output = gr.Image(label="Scatter Plot")
42
 
 
43
  csv_file.change(
44
  fn=update_dropdowns,
45
  inputs=csv_file,
46
  outputs=[x_axis, y_axis]
47
  )
48
 
 
49
  plot_button.click(
50
  fn=create_scatter_plot,
51
  inputs=[csv_file, x_axis, y_axis],