📅  最后修改于: 2023-12-03 15:05:35.251000             🧑  作者: Mango
Thanatologue is a Python package that provides a class for working with mortality data. The name comes from "thanatos," the Greek term for death, and "logos," which means study or discourse.
To install Thanatologue, you can use pip:
pip install thanatologue
Here's an example of how to use Thanatologue to load and preprocess mortality data:
from thanatologue import MortalityData
data = MortalityData.from_csv('mort_data.csv')
data.clean_data()
And here's an example of how to calculate age-specific death rates and life expectancy:
death_rates = data.get_death_rates()
life_expectancy = data.get_life_expectancy()
You can also estimate mortality models and forecast future mortality rates:
from thanatologue import MortalityModel
model = MortalityModel.fit(data, method='lee-carter')
forecast = model.forecast(n=10)
Finally, you can build life tables and calculate associated measures:
from thanatologue import LifeTable
table = LifeTable(data)
table.build()
prob_die = table.get_probability_of_dying()
num_survivors = table.get_number_of_survivors(75)
The full documentation for Thanatologue is available at https://thanatologue.readthedocs.io/en/latest/.
Thanatologue is released under the MIT License.