Spaces:
Sleeping
Sleeping
import streamlit as st | |
import pandas as pd | |
import numpy as np | |
df = pd.read_csv('last_results.csv') | |
image1 = 'images/rs_pmpa.PNG' | |
title_html = """ | |
<style> | |
@font-face { | |
font-family: 'Quicksand'; | |
src: url('font/Quicksand-VariableFont_wght.ttf') format('truetype'); | |
} | |
body { | |
font-family: 'Quicksand', sans-serif; | |
} | |
.custom-title { | |
color: darkgreen; | |
font-size: 30px; | |
font-weight: bold; | |
} | |
</style> | |
<span class='custom-title'>PREVISÕES DE RECEITAS</span> | |
""" | |
# Set a fixed width for the sidebar | |
st.markdown( | |
""" | |
<style> | |
.sidebar .sidebar-content { | |
width: 300px; | |
} | |
</style> | |
""", | |
unsafe_allow_html=True | |
) | |
with st.sidebar: | |
st.image(image1, use_column_width=True) | |
st.markdown(title_html, unsafe_allow_html=True) | |
selected_instituicao = st.selectbox('Seleciona Instituição', df['Instituição'].unique()) | |
selected_conta = st.selectbox('Seleciona Conta', df['Conta'].unique()) | |
# Filter the DataFrame based on selected values | |
filtered_df = df[(df['Instituição'] == selected_instituicao) & (df['Conta'] == selected_conta)] | |
# Display the Forecasts values as line plots | |
if not filtered_df.empty: | |
st.subheader('Gráfico com previsões') | |
# Create a list to store data for each period | |
data = [] | |
data_string = filtered_df['Forecasts'].iloc[0] | |
# Split the string into lines | |
lines = data_string.split('\n') | |
# Iterate through the lines and extract the values | |
for line in lines[:-2]: | |
period, value = line.split() | |
num_float = float(value) | |
monetary_value = f'R$ {num_float:,.2f}' # Adding commas for thousands separator | |
data.append({'Period': period, 'Monetary Value': num_float}) | |
# Create a DataFrame from the list | |
chart_data = pd.DataFrame(data) | |
# Sort the DataFrame by 'Period' | |
chart_data = chart_data.sort_values(by='Period') | |
# Display line chart with "period" on X-axis and "Monetary Value" on Y-axis | |
st.line_chart(chart_data.set_index('Period')) | |
else: | |
st.warning('No data available for the selected filters.') | |