Excel Na Utils

by Rukkha1024

data

Helper functions for NA/missing value handling in Excel data. Provides Python and VBA implementations following CLAUDE.md NA handling guidelines.

Skill Details

Repository Files

3 files in this skill directory


name: excel-na-utils description: Helper functions for NA/missing value handling in Excel data. Provides Python and VBA implementations following CLAUDE.md NA handling guidelines.

Excel NA Utils Skill

NA/missing value helper functions for Excel data processing

Overview

Consistent NA handling across Python and VBA based on CLAUDE.md guidelines:

  • Treat empty cells, #N/A, "NA", "N/A" as missing values
  • Exclude from numeric aggregates (mean, SD, min, max)
  • Track excluded value counts for auditing
  • Works with both Python and VBA

When to Use

  • Python: Analyzing Excel data with polars/pandas
  • VBA: Building summary macros with NA filtering
  • Statistics: Computing aggregates while excluding NA
  • Validation: Identifying and counting missing data
  • Auditing: Track excluded value counts

Python API

from na_helpers import is_na, filter_na, na_ratio, numeric_only

# Check if single value is NA
is_na(None)           # True
is_na("")             # True
is_na("NA")           # True
is_na("#N/A")         # True
is_na(1.5)            # False

# Filter NA from list
data = [1, 2, None, "NA", 3, "#N/A"]
clean = filter_na(data)  # [1, 2, 3]

# Calculate NA ratio
ratio = na_ratio(data)  # 0.5 (3 out of 6)

# Extract only numeric values (after NA filtering)
numbers = numeric_only(data)  # [1, 2, 3]

VBA Templates

' Check if value is NA
If Not IsNA(cellValue) And IsNumeric(cellValue) Then
    ' Use value for calculation
    AddNumeric arr, n, cellValue
End If

' IsNA function checks:
' - Empty cells
' - Error values (#N/A, #DIV/0!, etc.)
' - Text markers ("NA", "N/A", "na", "n/a")

' AddNumeric adds to array only if not NA
' Result: clean array of valid numbers only

NA Value Definitions

These are treated as missing values:

Type Examples Handling
Empty `` (blank cell) Excluded
Error #N/A, #DIV/0! Excluded
Text markers "NA", "N/A", "na" Excluded (case-insensitive, trimmed)

Output

Functions return:

  • is_na(): bool
  • filter_na(): list of non-NA values
  • na_ratio(): float (0.0-1.0)
  • numeric_only(): list of numeric values

With auditing:

  • Count of excluded NA values
  • Count of remaining valid values
  • NA ratio for reporting

Integration

Python + Excel

from na_helpers import filter_na, na_ratio

# Read from Excel, filter NA
data = [cell.value for cell in range]
clean = filter_na(data)
n_excluded = len(data) - len(clean)

# Report N and exclusions
print(f"N: {len(clean)} (excluded: {n_excluded})")

VBA (in vba.md)

' Module2 already implements IsNA + AddNumeric
' Example from BuildMetaSummary macro:

If Not IsNA(cellValue) And IsNumeric(cellValue) Then
    AddNumeric arr, n, cellValue
End If

' Result: proper N calculation with excluded count

Files

  • na_helpers.py: Python implementation
  • na_helpers.vba: VBA templates (reference)
  • SKILL.md: This file

Related Skills

  • excel-inspector: Analyze NA ratio per column
  • excel-vba-modifier: Use for VBA NA handling
  • Reference: vba.md (full VBA implementation)

Examples

Example 1: Calculate mean excluding NA

from na_helpers import filter_na
import statistics

data = [10, 20, None, 30, "NA", 40]
clean = filter_na(data)
mean = statistics.mean(clean)  # 25.0 (10+20+30+40)/4

Example 2: Report statistics

from na_helpers import filter_na, na_ratio

data = [...1000 values...]
clean = filter_na(data)

n_total = len(data)
n_valid = len(clean)
n_na = n_total - n_valid
ratio = na_ratio(data)

print(f"N: {n_valid} (excluded: {n_na}, NA%: {ratio*100:.1f}%)")

Example 3: VBA summary calculation

' In Module2
If Not IsNA(ageVal) And IsNumeric(ageVal) Then
    AddNumeric ageArr, nAge, ageVal
    If CDbl(ageVal) >= 60 Then
        AddNumeric ageOldArr, nAgeOld, ageVal
    Else
        AddNumeric ageYoungArr, nAgeYoung, ageVal
    End If
End If

Compliance

Follows CLAUDE.md NA Handling Guidelines: ✓ Empty, error, text NA treated consistently ✓ NA excluded from aggregates ✓ Count tracked for auditing ✓ Proper numeric conversion order ✓ Results report N correctly

Related Skills

Xlsx

Comprehensive spreadsheet creation, editing, and analysis with support for formulas, formatting, data analysis, and visualization. When Claude needs to work with spreadsheets (.xlsx, .xlsm, .csv, .tsv, etc) for: (1) Creating new spreadsheets with formulas and formatting, (2) Reading or analyzing data, (3) Modify existing spreadsheets while preserving formulas, (4) Data analysis and visualization in spreadsheets, or (5) Recalculating formulas

data

Clickhouse Io

ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

datacli

Clickhouse Io

ClickHouse database patterns, query optimization, analytics, and data engineering best practices for high-performance analytical workloads.

datacli

Analyzing Financial Statements

This skill calculates key financial ratios and metrics from financial statement data for investment analysis

data

Data Storytelling

Transform data into compelling narratives using visualization, context, and persuasive structure. Use when presenting analytics to stakeholders, creating data reports, or building executive presentations.

data

Kpi Dashboard Design

Design effective KPI dashboards with metrics selection, visualization best practices, and real-time monitoring patterns. Use when building business dashboards, selecting metrics, or designing data visualization layouts.

designdata

Dbt Transformation Patterns

Master dbt (data build tool) for analytics engineering with model organization, testing, documentation, and incremental strategies. Use when building data transformations, creating data models, or implementing analytics engineering best practices.

testingdocumenttool

Sql Optimization Patterns

Master SQL query optimization, indexing strategies, and EXPLAIN analysis to dramatically improve database performance and eliminate slow queries. Use when debugging slow queries, designing database schemas, or optimizing application performance.

designdata

Anndata

This skill should be used when working with annotated data matrices in Python, particularly for single-cell genomics analysis, managing experimental measurements with metadata, or handling large-scale biological datasets. Use when tasks involve AnnData objects, h5ad files, single-cell RNA-seq data, or integration with scanpy/scverse tools.

arttooldata

Xlsx

Spreadsheet toolkit (.xlsx/.csv). Create/edit with formulas/formatting, analyze data, visualization, recalculate formulas, for spreadsheet processing and analysis.

tooldata

Skill Information

Category:Data
Last Updated:1/23/2026