Spaces:
Running
Running
Commit
•
ac404f6
1
Parent(s):
4f8876e
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,7 @@
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
|
|
4 |
|
5 |
#st.set_page_config(layout="wide")
|
6 |
|
@@ -86,6 +87,25 @@ col1, col2 = st.columns([col1_width, col2_width])
|
|
86 |
# Display the Forecasts values in the first column
|
87 |
col1.header('Valores previstos')
|
88 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
if not filtered_df.empty:
|
90 |
data_string = filtered_df['Forecasts'].iloc[0]
|
91 |
|
@@ -93,11 +113,15 @@ if not filtered_df.empty:
|
|
93 |
lines = data_string.split('\n')
|
94 |
|
95 |
# Iterate through the lines and extract the values
|
96 |
-
for line in lines[:-2]:
|
97 |
period, value = line.split()
|
98 |
num_float = float(value)
|
99 |
monetary_value = f'R$ {num_float:,.2f}' # Adding commas for thousands separator
|
100 |
-
|
|
|
|
|
|
|
|
|
101 |
else:
|
102 |
col1.warning('No data available for the selected filters.')
|
103 |
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import numpy as np
|
4 |
+
from datetime import datetime
|
5 |
|
6 |
#st.set_page_config(layout="wide")
|
7 |
|
|
|
87 |
# Display the Forecasts values in the first column
|
88 |
col1.header('Valores previstos')
|
89 |
|
90 |
+
def period_to_date(period):
|
91 |
+
# Define a list of month names
|
92 |
+
months = ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro']
|
93 |
+
|
94 |
+
# Handling the sequence up to 118
|
95 |
+
if period <= 118:
|
96 |
+
# Assuming 118 corresponds to December 2024 and counting backwards
|
97 |
+
year = 2024
|
98 |
+
month_index = 118 - period
|
99 |
+
return f"{months[-(month_index + 1)]}/{year}"
|
100 |
+
|
101 |
+
# Handling the datetime integer sequence
|
102 |
+
else:
|
103 |
+
# Convert period to datetime object assuming the period is a Julian date
|
104 |
+
date = datetime.fromordinal(period)
|
105 |
+
month_name = months[date.month - 1]
|
106 |
+
year = date.year
|
107 |
+
return f"{month_name}/{year}"
|
108 |
+
|
109 |
if not filtered_df.empty:
|
110 |
data_string = filtered_df['Forecasts'].iloc[0]
|
111 |
|
|
|
113 |
lines = data_string.split('\n')
|
114 |
|
115 |
# Iterate through the lines and extract the values
|
116 |
+
for line in lines[:-2]: # Skip the last two lines which might not contain forecast data
|
117 |
period, value = line.split()
|
118 |
num_float = float(value)
|
119 |
monetary_value = f'R$ {num_float:,.2f}' # Adding commas for thousands separator
|
120 |
+
|
121 |
+
# Convert period to date format
|
122 |
+
period_date = period_to_date(int(period))
|
123 |
+
|
124 |
+
col1.write(f"{period_date}: {monetary_value}")
|
125 |
else:
|
126 |
col1.warning('No data available for the selected filters.')
|
127 |
|