code: def _inflate_currency(
      country: str = None,
      currency_year: int = None,
      to_year: int = None,
  ) -> float:
      """
      Currency inflation for Pandas DataFrame column.
      Helper function for `inflate_currency` method.
      The API used is the World Bank Indicator API:
      https://datahelpdesk.worldbank.org/knowledgebase/articles/889392-about-the-indicators-api-documentation
      """
  
      # Check all inputs are correct data type
      check("country", country, [str])
      check("currency_year", currency_year, [int])
      check("to_year", to_year, [int])
  
      # Get WB country abbreviation
      _check_wb_country(country)
      if country in wb_country_dict.keys():
          country = wb_country_dict[country]
      else:
          # `country` is already a correct abbreviation; do nothing
          pass
  
      _check_wb_years(currency_year)
      _check_wb_years(to_year)
  
      url = (
          "https://api.worldbank.org/v2/country/"
          + country
          + "/indicator/FP.CPI.TOTL?date="
          + str(min(currency_year, to_year))
          + ":"
          + str(max(currency_year, to_year))
          + "&format=json"
      )
  
      result = requests.get(url)
  
      if result.status_code != 200:
          raise ConnectionError(
              "WB Indicator API failed to receive a 200 "
              "response from the server. "
              "Please try again later."
          )
  
      # The API returns a list of two items;
      # the second item in the list is what we want
      inflation_dict = json.loads(result.text)[1]
  
      # Error checking
      if inflation_dict is None:
          raise ValueError(
              "The WB Indicator API returned nothing. "
              "This likely means the currency_year and "
              "to_year are outside of the year range for "
              "which the WB has inflation data for the "
              "specified country."
          )
  
      # Create new dict with only the year and inflation values
      inflation_dict_ready = {
          int(inflation_dict[i]["date"]): float(
              inflation_dict[i]["value"]
          )
          for i in range(len(inflation_dict))
          if inflation_dict[i]["value"] is not None
      }
  
      # Error catching
      if currency_year not in inflation_dict_ready.keys():
          raise ValueError(
              f"The WB Indicator API does not have inflation "
              f"data for {currency_year} for {country}."
          )
      if to_year not in inflation_dict_ready.keys():
          raise ValueError(
              f"The WB Indicator API does not have inflation "
              f"data for {to_year} for {country}."
          )
  
      inflator = (
          inflation_dict_ready[to_year]
          / inflation_dict_ready[currency_year]
      )
      return inflator
  
file_path: pyjanitor/janitor/finance.py
imports: import json
  from datetime import date
  from functools import lru_cache
  from typing import Optional
  import pandas
  import pandas_flavor
  import requests
  from janitor.errors import JanitorError
  from .utils import check, deprecated_alias, is_connected
label_desc: Use image node_id 5 for calling a global function with example usage: _inflate_currency(country, currency_year, to_year) and returns: inflator