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
- Give the transformation a name
- Choose its inputs (Input): the datasets it reads
- Name its outputs (Output): the datasets it produces
- 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
| Field | Value |
|---|---|
| Transformation | change_contract_currency |
| Input | Contrat |
| Output | Contrat_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.
