d142111015 commited on
Commit
bb4e01b
·
verified ·
1 Parent(s): 41c918a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -420,8 +420,11 @@ def main():
420
  worksheet.insert_chart('E5', chart)
421
 
422
  elif chart_type == "Bar Chart":
423
- # Convert percentage values from string (e.g., "10%") to numeric for proper sorting
424
- df_triplet[frequency_col] = df_triplet[frequency_col].str.rstrip('%').astype(float)
 
 
 
425
 
426
  # Sort the DataFrame based on the numeric percentage values
427
  df_triplet = df_triplet.sort_values(by=frequency_col)
 
420
  worksheet.insert_chart('E5', chart)
421
 
422
  elif chart_type == "Bar Chart":
423
+ # Ensure all values in frequency_col are strings before processing
424
+ df_triplet[frequency_col] = df_triplet[frequency_col].astype(str)
425
+
426
+ # Remove the percentage sign and convert to numeric, handling non-convertible values (e.g., NaN)
427
+ df_triplet[frequency_col] = pd.to_numeric(df_triplet[frequency_col].str.rstrip('%'), errors='coerce')
428
 
429
  # Sort the DataFrame based on the numeric percentage values
430
  df_triplet = df_triplet.sort_values(by=frequency_col)