Dates module

Miscellaneous data utilities

parse_row_dates(data)

Replace date strings in raw response with datetime objects, in-place.

Does not replace "MRV" or "-". If we don't recognize the format, do nothing.

Parameters:
  • data (Sequence[Dict[str, Any]]) –

    sequence of dictionaries with date keys to parse

format_dates(dates, freq)

Given one or two date arguments, turn them into WB-accepted date parameters

Parameters:
  • dates (Dates) –

    a date or a tuple of two dates, where a date is either a string or a datetime.datetime object. The date can be either a World-Bank format string or anything that dateparser can handle.

  • freq (str) –

    One of "Y", "M", or "Q" for year, month, or quarter respectively.

Returns:
  • str

    A string representing a date or date range according to the specified

  • str

    frequency in the form the World Bank API expects.