guille03 commited on
Commit
d6cce75
·
1 Parent(s): 4d4aeb8
Files changed (1) hide show
  1. analisis.py +13 -8
analisis.py CHANGED
@@ -79,25 +79,30 @@ class AnalizadorDatos:
79
 
80
  def generar_graficos(self, columnas_analisis: list) -> dict:
81
  """Genera gráficos para las columnas especificadas"""
82
- os.makedirs("graficos", exist_ok=True)
 
 
 
83
 
84
  for col in columnas_analisis:
85
  if col not in self.df.columns:
86
  continue
87
 
88
- output_path = f"graficos/{col}.png"
 
89
 
90
  if pd.api.types.is_numeric_dtype(self.df[col]):
91
  path = generar_histograma_r(self.df, col, output_path)
92
  if path:
93
  self.graficos[col] = {'tipo': 'histograma', 'path': path}
94
-
95
- # Gráfico adicional si hay una columna categórica adecuada
96
- categoricas = [c for c in self.df.columns
97
- if pd.api.types.is_categorical_dtype(self.df[c])
98
- or pd.api.types.is_object_dtype(self.df[c])]
99
  if categoricas and len(self.df[categoricas[0]].unique()) <= 10:
100
- path = generar_boxplot_r(self.df, col, categoricas[0], f"graficos/{col}_by_{categoricas[0]}.png")
 
101
  if path:
102
  self.graficos[f"{col}_by_{categoricas[0]}"] = {'tipo': 'boxplot', 'path': path}
103
  else:
 
79
 
80
  def generar_graficos(self, columnas_analisis: list) -> dict:
81
  """Genera gráficos para las columnas especificadas"""
82
+
83
+ # CAMBIO: Usar /tmp en lugar de "graficos"
84
+ graficos_dir = "/tmp/graficos"
85
+ os.makedirs(graficos_dir, exist_ok=True)
86
 
87
  for col in columnas_analisis:
88
  if col not in self.df.columns:
89
  continue
90
 
91
+ # CAMBIO: Usar os.path.join con el nuevo directorio
92
+ output_path = os.path.join(graficos_dir, f"{col}.png")
93
 
94
  if pd.api.types.is_numeric_dtype(self.df[col]):
95
  path = generar_histograma_r(self.df, col, output_path)
96
  if path:
97
  self.graficos[col] = {'tipo': 'histograma', 'path': path}
98
+
99
+ categoricas = [c for c in self.df.columns
100
+ if pd.api.types.is_categorical_dtype(self.df[c])
101
+ or pd.api.types.is_object_dtype(self.df[c])]
102
+
103
  if categoricas and len(self.df[categoricas[0]].unique()) <= 10:
104
+ boxplot_path = os.path.join(graficos_dir, f"{col}_by_{categoricas[0]}.png")
105
+ path = generar_boxplot_r(self.df, col, categoricas[0], boxplot_path)
106
  if path:
107
  self.graficos[f"{col}_by_{categoricas[0]}"] = {'tipo': 'boxplot', 'path': path}
108
  else: