fschwartzer commited on
Commit
d89ec26
1 Parent(s): 9189920

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -93,14 +93,14 @@ def period_to_date(period):
93
  datetime_ref_date = datetime(2024, 12, 1)
94
 
95
  # Sequential period numbers scenario (1 up to 118 for December 2024)
96
- if period <= 118:
97
  # Calculate difference in months from December 2024
98
- months_diff = 118 - period
99
  date = datetime_ref_date - timedelta(days=months_diff * 30) # Rough approximation
100
  # Datetime-like integers scenario
101
  else:
102
  # Calculate difference in periods from the reference period and convert to date
103
- periods_diff = 118 - (period * (118/datetime_ref_period))
104
  date = datetime_ref_date - timedelta(days=periods_diff * 30)
105
 
106
  # Format and return the date
@@ -122,7 +122,7 @@ if not filtered_df.empty:
122
  lines = data_string.split('\n')
123
 
124
  # Iterate through the lines and extract the values
125
- for line in lines[:-2]: # Skip the last two lines which might not contain forecast data
126
  period, value = line.split()
127
  num_float = float(value)
128
  monetary_value = f'R$ {num_float:,.2f}' # Adding commas for thousands separator
 
93
  datetime_ref_date = datetime(2024, 12, 1)
94
 
95
  # Sequential period numbers scenario (1 up to 118 for December 2024)
96
+ if period <= 119:
97
  # Calculate difference in months from December 2024
98
+ months_diff = 119 - period
99
  date = datetime_ref_date - timedelta(days=months_diff * 30) # Rough approximation
100
  # Datetime-like integers scenario
101
  else:
102
  # Calculate difference in periods from the reference period and convert to date
103
+ periods_diff = 119 - (period * (119/datetime_ref_period))
104
  date = datetime_ref_date - timedelta(days=periods_diff * 30)
105
 
106
  # Format and return the date
 
122
  lines = data_string.split('\n')
123
 
124
  # Iterate through the lines and extract the values
125
+ for line in lines[:-1]: # Skip the last two lines which might not contain forecast data
126
  period, value = line.split()
127
  num_float = float(value)
128
  monetary_value = f'R$ {num_float:,.2f}' # Adding commas for thousands separator