parse_csv_triangle
Converts a CSV file from disk into a cumulative loss triangle by handling missing values, stripping thousand separators, and auto-padding rows, making the data ready for chain ladder reserving calculations.
Instructions
Parse a CSV file from disk into a cumulative loss triangle.
Reads the file, treats empty cells and the tokens "NA", "N/A", "NaN", "-" as unobserved, strips embedded commas (thousand separators), and drops any leading row whose first cell is non-numeric but whose remaining cells are mostly numeric (e.g. a "Dev 1, Dev 2, …" header). Auto-pads jagged rows to a rectangle with nulls.
Use this when the user gives you a CSV file path and wants to run the chain ladder on it.
Args:
path: Absolute or ~-relative path to the CSV file. Must be
readable by the server process.
Returns:
- triangle: list[list[float | null]] — parsed cells, ready to
pass to compute_chain_ladder
- n_acc: int — number of accident-year rows
- n_dev: int — number of development periods (max row length)
- source: str — absolute path actually read
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| path | Yes |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||