Documentation

pydtm.api

pydtm.api.countryLevelData(operation: str = '', countryName: str = '', admin0Pcode: str = '', fromDate: Optional[str] = None, toDate: Optional[str] = None, monthFrom_month: Optional[str] = None, monthFrom_year: Optional[int] = None, monthTo_month: Optional[str] = None, monthTo_year: Optional[str] = None, roundFrom: Optional[int] = None, roundTo: Optional[int] = None, to_pandas: bool = False)

Get country level data from IOM’s DTM API.

Parameters:
  • operation (str) – The operation to perform, default to “”

  • countryName (str) – The name of the country, default to “”, must not be specified if using admin0Pcode

  • admin0Pcode (str) – The admin0Pcode of the country (ISO 3166-1 alpha-3), default to “”, must not be specified if using countryName

  • fromDate (str) – The start date of the reporting period (format: “yyyy-mm-dd”), optional

  • toDate (str) – The end date of the reporting period (format: “yyyy-mm-dd”), optional

  • monthFrom_month (str) – The start month of the reporting period, default to None

  • monthFrom_year (int) – The start year of the reporting period, default to None

  • monthTo_month (str) – The end month of the reporting period, default to None

  • monthTo_year (int) – The end year of the reporting period, default to None

  • roundFrom (int) – The start round number, default to None, optional

  • roundTo (int) – The end round number, default to None, optional

  • to_pandas (bool) – Convert the response to a pandas DataFrame, default to False, optional

Returns:

The response from the API

Return type:

dict or pandas.DataFrame depending on the value of to_pandas

pydtm.api.admin1LevelData(operation: str = '', countryName: str = '', admin0Pcode: str = '', fromDate: Optional[str] = None, toDate: Optional[str] = None, monthFrom_month: Optional[str] = None, monthFrom_year: Optional[int] = None, monthTo_month: Optional[str] = None, monthTo_year: Optional[str] = None, roundFrom: Optional[int] = None, roundTo: Optional[int] = None, to_pandas: bool = False)

Get admin1 level data from IOM’s DTM API.

Parameters:
  • operation (str) – The operation to perform, default to “”

  • countryName (str) – The name of the country, default to “”, must not be specified if using admin0Pcode

  • admin0Pcode (str) – The admin0Pcode of the country (ISO 3166-1 alpha-3), default to “”, must not be specified if using countryName

  • fromDate (str) – The start date of the reporting period (format: “yyyy-mm-dd”), optional

  • toDate (str) – The end date of the reporting period (format: “yyyy-mm-dd”), optional

  • monthFrom_month (str) – The start month of the reporting period, default to None

  • monthFrom_year (int) – The start year of the reporting period, default to None

  • monthTo_month (str) – The end month of the reporting period, default to None

  • monthTo_year (int) – The end year of the reporting period, default to None

  • roundFrom (int) – The start round number, default to None, optional

  • roundTo (int) – The end round number, default to None, optional

  • to_pandas (bool) – Convert the response to a pandas DataFrame, default to False, optional

Returns:

The response from the API

Return type:

dict or pandas.DataFrame depending on the value of to_pandas

pydtm.api.admin2LevelData(operation: str = '', countryName: str = '', admin0Pcode: str = '', fromDate: Optional[str] = None, toDate: Optional[str] = None, monthFrom_month: Optional[str] = None, monthFrom_year: Optional[int] = None, monthTo_month: Optional[str] = None, monthTo_year: Optional[str] = None, roundFrom: Optional[int] = None, roundTo: Optional[int] = None, to_pandas: bool = False)

Get admin2 level data from IOM’s DTM API.

Parameters:
  • operation (str) – The operation to perform, default to “”

  • countryName (str) – The name of the country, default to “”, must not be specified if using admin0Pcode

  • admin0Pcode (str) – The admin0Pcode of the country (ISO 3166-1 alpha-3), default to “”, must not be specified if using countryName

  • fromDate (str) – The start date of the reporting period (format: “yyyy-mm-dd”), optional

  • toDate (str) – The end date of the reporting period (format: “yyyy-mm-dd”), optional

  • monthFrom_month (str) – The start month of the reporting period, default to None

  • monthFrom_year (int) – The start year of the reporting period, default to None

  • monthTo_month (str) – The end month of the reporting period, default to None

  • monthTo_year (int) – The end year of the reporting period, default to None

  • roundFrom (int) – The start round number, default to None, optional

  • roundTo (int) – The end round number, default to None, optional

  • to_pandas (bool) – Convert the response to a pandas DataFrame, default to False, optional

Returns:

The response from the API

Return type:

dict or pandas.DataFrame depending on the value of to_pandas

pydtm.utils

pydtm.utils.load_ISO3166_data()

Load the ISO 3166-1 country codes from the CSV file

pydtm.utils.countryToISO3166_A3(country)

Get the ISO 3166-1 alpha-3 code for a given country name.

Parameters:

country (str) – The name of the country.

Returns:

The ISO 3166-1 alpha-3 code for the country.

Return type:

str

pydtm.utils.ISO3166_A3ToCountry(ISO3166_A3_id)

Get the name of the country for a given ISO 3166-1 alpha-3 code.

Parameters:

ISO3166_A3_id (str) – The ISO 3166-1 alpha-3 code for the country.

Returns:

The name of the country.