-
-
Notifications
You must be signed in to change notification settings - Fork 0
Python API
benzsevern edited this page Mar 29, 2026
·
1 revision
The main entry point. Auto-detects providers based on input type.
import infermap
# Files
result = infermap.map("source.csv", "target.csv")
# DataFrames (Polars or Pandas)
result = infermap.map(source_df, target_df)
# Database
result = infermap.map("data.csv", "postgresql://host/db", table="users")
# With schema file overlay
result = infermap.map("data.csv", "target.csv", schema_file="schema.yaml")
# With required fields
result = infermap.map("data.csv", "target.csv", required=["email", "phone"])Load a saved mapping config. Skips inference entirely.
result = infermap.from_config("mapping.yaml")
remapped = result.apply(new_df)Advanced usage with custom configuration.
engine = infermap.MapEngine(
min_confidence=0.4, # minimum score to keep a mapping (default: 0.3)
sample_size=1000, # rows to sample for profiling (default: 500)
scorers=infermap.default_scorers() + [my_custom_scorer],
config_path="infermap.yaml", # scorer weight overrides
)
result = engine.map(source, target)| Method | Returns | Description |
|---|---|---|
report() |
dict |
Structured mapping with per-scorer breakdown |
apply(df) |
DataFrame | Remap columns (preserves Polars/Pandas type) |
to_config(path) |
None | Save as reusable YAML |
to_json() |
str |
JSON string of report |
| Attribute | Type | Description |
|---|---|---|
mappings |
list[FieldMapping] |
Source-to-target mappings |
unmapped_source |
list[str] |
Source fields with no match |
unmapped_target |
list[str] |
Target fields with no match |
warnings |
list[str] |
Required field warnings |
metadata |
dict |
Timing, scorer config |
| Attribute | Type | Description |
|---|---|---|
source |
str |
Source field name |
target |
str |
Target field name |
confidence |
float |
Combined score (0.0-1.0) |
breakdown |
dict[str, ScorerResult] |
Per-scorer scores |
reasoning |
str |
Human-readable summary |
@infermap.scorer(name="fhir_type", weight=0.8)
def fhir_scorer(source, target):
# source and target are FieldInfo objects
# Return ScorerResult(score, reasoning) or None to abstain
return infermap.ScorerResult(score=0.9, reasoning="FHIR match")