WeasyPrint
WeasyPrint copied to clipboard
TypeError: unsupported operand type(s) for +: 'float' and 'str'.
import streamlit as st
import time
import numpy as np
import pandas as pd
from io import StringIO
import datetime
import plotly.express as px
import warnings
warnings.filterwarnings('ignore')
st.set_page_config(page_title="Finance Dashboard", page_icon="📈",layout="wide")
st.title(" :bar_chart: Tableau des bords des finances")
st.markdown('<style>div.block-container{padding-top:1rem;}</style>',unsafe_allow_html=True)
#import database
file = st.file_uploader(":file_folder: Selectionne la BD Excel à analyser")
#test is the file is selected
if file is not None:
# Can be used wherever a "file-like" object is accepted:
dataframe=pd.read_excel(file)
#creating a filter for the data according to a period selected
col1, col2 = st.columns((2))
dataframe["MOIS"] = pd.to_datetime(dataframe["MOIS"])
# Getting the min and max date
startDate = pd.to_datetime(dataframe["MOIS"]).min()
endDate = pd.to_datetime(dataframe["MOIS"]).max()
with col1:
date1 = pd.to_datetime(st.date_input("Start Date", startDate))
with col2:
date2 = pd.to_datetime(st.date_input("End Date", endDate))
dataframes = dataframe[(dataframe["MOIS"] >= date1) & (dataframe["MOIS"] <= date2)].copy()
#Defining filters
st.sidebar.header("Choisis les filtres: ")
# Create filter for Prestataire
Prestataire = st.sidebar.multiselect("Selectionne les prestataires", dataframes["Prestataires"].unique())
if not Prestataire:
dataframe_2 = dataframes.copy()
else:
dataframe_2 = dataframes[dataframes["Prestataires"].isin(Prestataire)]
# Create filter for Assureur
Assureur = st.sidebar.multiselect("Choisir les assureurs", dataframe_2["Groupes"].unique())
if not Assureur:
dataframe_3 = dataframe_2.copy()
else:
dataframe_3 = dataframe_2[dataframe_2["Groupes"].isin(Assureur)]
# Create filter for Client
Client = st.sidebar.multiselect("Choisir les clients", dataframe_3["Clients"].unique())
if not Client:
dataframe_4 = dataframe_3.copy()
else:
dataframe_4 = dataframe_3[dataframe_3["Clients"].isin(Client)]
if not Prestataire and not Assureur and not Prestataire:
filtered_dataframes = dataframe_4
elif not Assureur and not Client:
filtered_dataframes = dataframes[dataframes["Prestataires"].isin(Prestataire)]
elif not Prestataire and not Client:
filtered_dataframes = dataframes[dataframes["Groupes"].isin(Assureur)]
elif Assureur and Client:
filtered_dataframes = dataframe_3[dataframes["Groupes"].isin(Assureur) & dataframe_3["Clients"].isin(Client)]
elif Prestataire and Client:
filtered_dataframes = dataframe_3[dataframes["Prestataires"].isin(Prestataire) & dataframe_3["Clients"].isin(Client)]
elif Prestataire and Assureur:
filtered_dataframes = dataframe_3[dataframes["Prestataires"].isin(Prestataire) & dataframe_3["Groupes"].isin(Assureur)]
elif Client:
filtered_dataframes = dataframe_3[dataframe_3["Clients"].isin(Client)]
else:
filtered_dataframes = dataframe_3[dataframe_3["Prestataires"].isin(Prestataire) & dataframe_3["Groupes"].isin(Assureur) & dataframe_3["Clients"].isin(Client)]
#creating aggregates to view
Claims_recus=filtered_dataframes["Claims reçus"].sum()
Montant_reçu=filtered_dataframes["Montant de la facture"].sum()
Reste_payer=filtered_dataframes["Reste à payer"].sum()
col1, col2, col3 = st.columns(3)
col1.metric("Nombre de claims reçus", Claims_recus)
col2.metric("Montant de la facture", Montant_reçu)
col3.metric("Reste à payer", Reste_payer)
number_of_result = filtered_dataframes.shape[0]
st.markdown(f'*Available Results: {number_of_result}*')
category_df = filtered_dataframes.groupby(by = ["Groupes"], as_index = False)["Reste à payer"].sum()
st.subheader("Reste à payer par clients")
st.subheader("Reste à payer par assureurs")
fig = px.bar(category_df, x = "Groupes", y = "Reste à payer",
template = "seaborn")
st.plotly_chart(fig,use_container_width=True, height = 200)
# rerun.
st.button("Re-run")
Hi!
Could you please share a backtrace? Installing the dependencies of your script doesn’t install WeasyPrint, so it’s hard for us to reproduce.
(And we’re not an AI, we’re real people, you can write a few words in introduction!)
Feel free to add a comment if there’s anything we can do for you!