You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+11-65Lines changed: 11 additions & 65 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,12 +20,20 @@ xml = MortXML(3282)
20
20
21
21
This `MortXML` class is a wrapper around the [underlying XML](https://mort.soa.org/About.aspx). The autocompletions you get on attributes improve the developer experience over using the underlying XML directly.
22
22
23
-

23
+

24
24
25
-
### Examples
25
+
Also, mortality rate tables are Pandas DataFrames.
26
+
27
+

28
+
29
+
30
+
## Accessing mortality rates
31
+
32
+
For a select and ultimate table we can retrieve rates as follows.
26
33
27
34
```py
28
35
from pymort import MortXML
36
+
# Table 3265 is 2015 VBT Smoker Distinct Male Non-Smoker ANB, see https://mort.soa.org/
29
37
xml = MortXML(3265)
30
38
# This is the select table as a MultiIndex (age/duration) DataFrame.
31
39
xml.Tables[0].Values
@@ -37,7 +45,7 @@ xml.Tables[1].Values
37
45
38
46
## Usage with tensor libraries
39
47
40
-
Once we get the data from Pandas to NumPy it should be easy to get into JAX or any other tensor library.
@@ -49,65 +57,3 @@ ultimate.shape # (103,) is age 18 to 120
49
57
# Be careful when indexing into these, ultimate[0] is the rate at age 18!
50
58
```
51
59
52
-
## Relational tables
53
-
54
-
Pymort provides **3 normalized tables** related by [primary/foreign keys](https://www.ibm.com/docs/en/ida/9.1.1?topic=entities-primary-foreign-keys), a design taken from relational databases.
55
-
56
-
Currently tables from 2015 VBT and 2017 CSO are supported. If you want support for tables from other studies, open an issue on GitHub.
57
-
58
-
XML files with multiple "select" (2-dimensional) or multiple "ultimate" (1-dimensional) tables like table [2636](https://mort.soa.org/ViewTable.aspx?&TableIdentity=2636) are not supported so that we can avoid adding another column.
59
-
60
-
### Metadata
61
-
62
-
Each table has a unique identifier called an `id`. There is information associated with this table like
63
-
64
-
- What is the name of the mortality study producing the table? (i.e. 2017 CSO vs. 2015 VBT)
65
-
- Is there a grouping that the table belongs to within the study? (i.e. unloaded preferred_structure gender_distinct ANB vs. loaded smoker_distinct gender_blended ALB)
66
-
- Gender (male vs. female)
67
-
- Risk (smoker vs. nonsmoker)
68
-
69
-
We call this information about a table the `metadata` and store it as an attribute of our `Relational` object.
70
-
71
-
```py
72
-
from pymort import Relational
73
-
74
-
db = Relational()
75
-
76
-
print(db.metadata)
77
-
```
78
-
79
-

80
-
81
-
### Select
82
-
83
-
Select tables depend on the issue age, and the years since issuing the contract.
84
-
85
-
```py
86
-
print(db.select)
87
-
```
88
-
89
-

90
-
91
-
### Ultimate
92
-
93
-
Ultimate tables depend on the attained age only.
94
-
95
-
```py
96
-
print(db.ultimate)
97
-
```
98
-
99
-

100
-
101
-
### Groupings
102
-
103
-
If you want to get the IDs for all tables having the same study and group there is a function for this, although you could do it yourself in Pandas.
104
-
105
-
```py
106
-
from pymort import getIdGroup
107
-
108
-
getIdGroup(3265)
109
-
```
110
-
111
-
This returns a dataclass representing the grouping.
0 commit comments