Skip to content

Utilities

Utility functions for the ClimAID package.

This module provides a collection of helper utilities for handling climate and epidemiological datasets used throughout ClimAID.

It includes functionality for: - Data ingestion and validation - Cleaning and preprocessing of datasets - Temporal train/test splitting for modeling workflows - Basic normalization and summary statistics

These utilities are designed to support reproducible and consistent data preparation across the ClimAID pipeline.

Notes
  • Functions in this module are independent of modeling and reporting layers.
  • Intended for internal use, but can be used externally for custom workflows.
Author

Avik Sam

Created

November 2025

build_district_tree(district_list)

Convert district keys like: IND_pune_maharashtra

into hierarchical structure: country → state → district

check_data_consistency(df, key_cols=['District', 'time'])

Verify that key identifiers (e.g., District, time) are unique and complete.

clean_numeric_column(series)

Clean messy numeric data like '7.71-09' or '295.2005/092' and convert to float.

ensure_directory(path)

Create directory if it does not exist.

load_csv_safe(filepath, parse_dates=['time'])

Safely load a CSV file and parse datetime columns if present.

normalize_features(df, cols)

Normalize selected numeric columns to [0, 1] range using MinMaxScaler.

pretty_country(code)

Convert ISO3 country code to human readable name.

Example

pretty_country("IND") 'India'

print_summary(df, label='Data')

Print summary statistics and missing value info.

split_train_test(df, date_col='time', cutoff_year=2020)

Split a dataset into training and testing subsets by year. - Training: all data before cutoff_year - Testing: all data after cutoff_year