File size: 2,688 Bytes
4b68381
 
c318f99
 
 
 
 
 
4b68381
a8d856c
4b68381
17249dc
df022b3
3910b68
df022b3
 
 
 
3910b68
df022b3
3910b68
df022b3
 
 
 
 
 
3910b68
df022b3
 
 
a268f6c
 
 
 
 
 
 
 
 
 
 
3910b68
a8d856c
cfc693b
3910b68
c318f99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4b68381
a8d856c
 
4b68381
a8d856c
 
 
d9738cf
a8d856c
 
 
c318f99
 
 
 
 
 
 
 
 
 
 
 
 
 
 
a8d856c
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
import streamlit as st
import pandas as pd
import matplotlib.pyplot as plt
import numpy as np
import locale

# Set the locale to Brazilian Portuguese
locale.setlocale(locale.LC_ALL, 'pt_BR.UTF-8')

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())
    # Generate some example data
    x = np.linspace(0, 10, 100)
    y1 = np.sin(x)
    y2 = np.cos(x)
    y3 = np.tan(x)

    # Plot the lines using Matplotlib
    fig, ax = plt.subplots()
    ax.plot(x, y1, label='Green Line', color='green')
    ax.plot(x, y2, label='Red Line', color='red')
    ax.plot(x, y3, label='Yellow Line', color='yellow')

    # Set plot properties
    ax.legend()
    ax.set_xlabel('X-axis')
    ax.set_ylabel('Y-axis')

    # Display the Matplotlib plot in the Streamlit sidebar
    st.sidebar.pyplot(fig)

# Filter the DataFrame based on selected values
filtered_df = df[(df['Instituição'] == selected_instituicao) & (df['Conta'] == selected_conta)]

# Display the filtered DataFrame
st.write('Filtered DataFrame:')
st.write(filtered_df)

# Display the Forecasts values
if not filtered_df.empty:
    forecasts_values = filtered_df['Forecasts'].values

    data_string = forecasts_values

    # Split the string into lines
    lines = data_string.split('\n')

    # Iterate through the lines and extract the values
    for line in lines[:-2]:  # Exclude the last two elements (empty and the 'Name: Valor, dtype: float64' line)
        period, value = line.split()
        num_float = float(value)
    
        # Format as monetary value with dots and comma
        monetary_value = locale.currency(num_float, grouping=True)
    
        st.write(f"Período {period}: {monetary_value}")
else:
    st.warning('No data available for the selected filters.')