albhu commited on
Commit
59119de
·
verified ·
1 Parent(s): 635a76a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -144,10 +144,10 @@ def download_boe_rates():
144
  st.error(f"Failed to download rates: {e}")
145
  return None
146
 
147
- # Function to get Bank of England base rate for a given date
148
  def get_boe_base_rate(date, boe_rates_df):
149
- closest_date = boe_rates_df['Date Changed'].iloc[(boe_rates_df['Date Changed'] - date).abs().argsort()[0]]
150
- return boe_rates_df.loc[boe_rates_df['Date Changed'] == closest_date, 'Current Bank Rate'].values[0]
 
151
 
152
  if __name__ == "__main__":
153
  main()
 
144
  st.error(f"Failed to download rates: {e}")
145
  return None
146
 
 
147
  def get_boe_base_rate(date, boe_rates_df):
148
+ closest_date_index = (boe_rates_df['Date Changed'] - pd.Timestamp(date)).abs().argsort()[0]
149
+ closest_date = boe_rates_df['Date Changed'].iloc[closest_date_index]
150
+ return boe_rates_df.loc[closest_date_index, 'Current Bank Rate']
151
 
152
  if __name__ == "__main__":
153
  main()