Skip to main content

Malawi Information Library (Districts, Currency, Agriculture, Health, Demographics)

Project description

mw_info

A lightweight Python library to access structured information about Malawi’s districts, agriculture, currency exchange rates, health facilities, and demographics.


Features

✅ District-level insights:
Region, coordinates, population, climate, timezone, elevation, and more

✅ Currency conversion:
Convert between MWK and major currencies (USD, EUR, ZAR, etc.)

✅ Agricultural info:
Query crops and fish species using Chichewa, English, or scientific name

✅ Health data:
Get health facility counts (hospitals, clinics, health posts) by district

✅ Demographics:
Population totals, gender ratios, age distribution, and urban/rural splits


Installation

pip install mw-info

or for development:

git clone https://github.com/Tuntufye4/mw_info.git
cd mw_info
pip install -e .

Usage

DistrictInfo Class, Methods & Examples

get_all_districts()

districts = DistrictInfo()
all_districts = districts.get_all_districts()
print(all_districts)
# Output: ['Lilongwe', 'Blantyre', 'Machinga', ...]

get_district_info(district_name, fields=None)

districts = DistrictInfo()

#### Full info for Lilongwe
info = districts.get_district_info("Lilongwe")
print(info)

#### Selected fields only
selected = districts.get_district_info("Mangochi", fields=["population_2023", "languages", "climate"])
print(selected)

filter_by_region(region_name)

Returns list of district dictionaries for districts in a given region.

districts = DistrictInfo()
southern_districts = districts.filter_by_region("Southern")
for d in southern_districts:
    print(d["district"])
### Outputs districts in Southern region

get_all_district_data()

Returns the full raw list of all district dictionaries.

districts = DistrictInfo()
all_data = districts.get_all_district_data()
print(all_data[0])  # Print first district data

CurrencyConverter Class, Methods & Examples

available_currencies()

Returns list of supported currency codes.

print(currency.available_currencies())
 Example output: ['USD', 'EUR', 'ZAR', 'GBP', 'KES', ...]

convert_from_base(amount, to_currency)

Convert amount from MWK (base currency) to another currency.

mwk_amount = 10000
usd_amount = currency.convert_from_base(mwk_amount, "USD")
print(f"{mwk_amount} MWK is approximately {usd_amount} USD")

convert_to_base(amount, from_currency)

Convert amount from another currency to MWK.

usd_amount = 100
mwk_amount = currency.convert_to_base(usd_amount, "USD")
print(f"{usd_amount} USD is approximately {mwk_amount} MWK")

AgriInfoMw Class Methods

from agriculture_info import AgricultureInfoMW

agri = AgricultureInfoMW()

Query crop or fish info by any name (Chichewa, English, or Scientific)

crop = agri.query_info("Chimanga")
print(crop)

fish = agri.query_info("Oreochromis shiranus")
print(fish)

Query by English name

crop2 = agri.query_info("Maize")
print(crop2)

List all crops

all_crops = agri.list_all_crops()
print(all_crops)

List all fish species

all_fish = agri.list_all_fish()
print(all_fish)

Class HealthInfo

from mw_info.health import HealthInfoMW

health = HealthInfoMW()
### List all districts

print(health.get_all_districts())

### Get district 

print(health.get_district_health("Zomba"))

### Filter by facility count
print(health.filter_by_facility_count("hospitals", threshold=3))

## Class DemographicsInfoMW

from mw_info.demographics import DemographicsInfoMW

demo = DemographicsInfoMW()


### Get all districts

print(demo.get_all_districts())

### Get Total Population

print(demo.get_population_total("Lilongwe"))
print(demo.get_urban_rural_split("Blantyre"))

### Get district data
print(demo.get_district_data("Zomba", fields=["population", "urban_percent"]))

Data Source

All the yml files datastores are chatgpt generated.

License

This project is licensed under the MIT License

Maintainer

Tuntufye Mwanyongo

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mw_info-0.1.2.tar.gz (10.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mw_info-0.1.2-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file mw_info-0.1.2.tar.gz.

File metadata

  • Download URL: mw_info-0.1.2.tar.gz
  • Upload date:
  • Size: 10.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.0

File hashes

Hashes for mw_info-0.1.2.tar.gz
Algorithm Hash digest
SHA256 3dea16d325edb90fe77dc57288391886d017ead808c5b1c148e6fcb5d8deca12
MD5 17ed68d63109a9254c23325500151d77
BLAKE2b-256 b8c586114fa8a0f9a0aaab777462891423a71212688a2a5d1693d9f1b1025c1b

See more details on using hashes here.

File details

Details for the file mw_info-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: mw_info-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 11.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.8.0

File hashes

Hashes for mw_info-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1ecfa282ecd4fd0e2d7e211e10b57eadb374fedaf7f2f11db4802ddd0ecdf807
MD5 ee85c4b6bbaf531e66dcd5c16b6a6a34
BLAKE2b-256 eebbda1c476cbab3bc078de188334bd652041f5b2deca60ee740de826bb8ce31

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page