Evitar decimales

This commit is contained in:
2024-09-05 19:13:31 +00:00
parent 885019f137
commit 67f7a72a02

3
app.py
View File

@@ -114,6 +114,9 @@ def extract(username: str, password: str):
if 'GRUPO' not in df.columns: if 'GRUPO' not in df.columns:
raise KeyError("Column 'GRUPO' not found in the DataFrame") raise KeyError("Column 'GRUPO' not found in the DataFrame")
# Remove decimals from the 'PERIODO' column (if present)
df['PERIODO'] = df['PERIODO'].apply(lambda x: str(x).replace('.0', '') if isinstance(x, (float, int)) else x)
# Convert the DataFrame to JSON # Convert the DataFrame to JSON
json_result = df[df['GRUPO'] != 'Promedio:'].to_json(orient='records') json_result = df[df['GRUPO'] != 'Promedio:'].to_json(orient='records')