Skip to content

Search is only available in production builds. Try building and previewing the site to test it out locally.

Transformations

A transformation creates a dataset that exists in no source: it takes data as input and produces new data as output. Transformations are written in Python.

They are used to clean or reshape data before it feeds the graph.

  • Stable result — with the same inputs, a transformation always gives the same result
  • Isolated — it only reads its inputs and writes its outputs (no access to files or the network)
  • Chained automatically — if a transformation uses the result of another one, GraphForge runs them in the right order

Create a transformation

  1. Give the transformation a name
  2. Choose its inputs (Input): the datasets it reads
  3. Name its outputs (Output): the datasets it produces
  4. Write the Python code

The code is a transform function:

  • it receives inputs, a dictionary that holds each input under its name
  • it returns a dictionary that holds each output under its name

The names used in the code must be exactly those declared in Input and Output.

Example: switch a contract’s currency to dollars

FieldValue
Transformationchange_contract_currency
InputContrat
OutputContrat_bis
def transform(inputs: dict) -> dict:
df = inputs["Contrat"].copy()
df.loc[df["contrat"] == "Contrat FR-LED-2201 - Valeo", "currency"] = "USD"
df["contrat"] = df["contrat"] + "_v2"
return {"Contrat_bis": df}

The transformation reads the Contrat dataset, switches the currency of contract FR-LED-2201 to USD, appends _v2 to the name of each contract, then returns the result under the name Contrat_bis.

Create a transformation