Skip to main content

What Fig Helpers Are

fig is a small, curated Python library built into every Go Fig Code node. It gives you five purpose-built functions for the data tasks that are painful to write from scratch in pandas: fuzzy matching, fiscal year conversion, statistical scoring, safe rate calculations, and near-duplicate detection. You don’t install or import fig. It’s always available inside the Code node’s Python mode, right alongside pd (pandas) and np (numpy).

When to Use Fig Helpers

Use fig.* when:
  • You need to match records across two sources where names or IDs aren’t exact (CRM ↔ accounting, messy leads, product SKUs)
  • Your organization uses a non-January fiscal year and you need to group dates correctly
  • You want a z-score, rolling z-score, or safe percentage change without writing the edge cases yourself
  • You’re cleaning a list with near-duplicate entries and DISTINCT won’t catch them
Don’t use them when:
  • A built-in node can do the same job. The XLOOKUP node handles exact joins without code
  • The task is simple enough for plain pandas (adding columns, basic filtering, .groupby)

Available Functions

The examples below reference B1 as a second parent table. In Go Fig, each parent connected to a code node is exposed as a DataFrame named after its step label (A1, B1, C1, …), the same label you see on the node in the canvas. The position-0 parent is also bound to data. See Joining Multiple Parents in the Code node docs.

fig.fuzzy_join

Match rows between two tables by approximate string similarity. For each row in the left table, finds the best match in the right table that scores above your similarity threshold. Signature:
Returns: a DataFrame combining columns from both tables, plus a _match_score column (0.0 to 1.0). Unmatched rows get NaN on the right-side columns and on _match_score. Example: reconcile HubSpot deals with QuickBooks customers:

fig.to_fiscal

Convert a date column into a fiscal-year integer, named by the calendar year the fiscal year starts in. Supports any fiscal-year start month. Signature:
Returns: a NumPy array of fiscal year integers. Example: July fiscal year start:

fig.zscore

Calculate z-scores, or how many standard deviations a value is from the mean. Useful for anomaly detection and identifying outliers. Signature:
Returns: a pandas Series of z-scores. Zero-variance inputs return all zeros (no NaN, no division error). Example: global z-score for outlier detection:
Example: 30-day rolling z-score:

fig.pct_change_safe

Percentage change between consecutive rows, with division-by-zero and missing-first-row handled safely. Signature:
Returns: a pandas Series. First row and any divide-by-zero rows get the fill value instead of NaN or inf. Example: month-over-month revenue change:

fig.dedupe

Drop duplicates by exact match on a column subset, or cluster near-duplicates by fuzzy string similarity. Signature:
Returns: a deduplicated DataFrame. Example: collapse messy company name variations:

Recipe Picker

Every fig function has a matching snippet in the Insert recipe dropdown at the top of the Python Code editor. Pick a recipe, edit the column names to match your data, and you’re done. No typing required.
Start with a recipe when you’re new to fig. The dropdown inserts a working example at the cursor so you just edit the column names and threshold values to match your data.

Usage Notes

fig is only available in Python mode of the Code node. SQL mode has no equivalent.
Fuzzy matching is computationally expensive. fig.fuzzy_join and fig.dedupe with fuzzy=True scale with the product of row counts so a 10,000 × 10,000 fuzzy join will be slow. For large tables, filter or sample down first.
Thresholds are 0.0 to 1.0, not 0 to 100. If you’re coming from fuzzywuzzy or rapidfuzz, remember that Fig helpers normalize scores to a 0-to-1 scale. 0.85 means 85% similarity.

Code Node

Write custom SQL or Python directly in your flow

XLOOKUP Node

Exact-match joins without code