added example workflow
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
import pandas as pd
|
||||
from dagster import op
|
||||
|
||||
|
||||
@@ -11,3 +12,26 @@ def fetch_data() -> list:
|
||||
def process_data(data: list) -> dict:
|
||||
"""Processes raw data and returns a summary."""
|
||||
return {"count": len(data), "status": "success"}
|
||||
|
||||
|
||||
@op
|
||||
def generate_example_dataset() -> pd.DataFrame:
|
||||
"""Generates a small example dataset as a pandas DataFrame."""
|
||||
return pd.DataFrame(
|
||||
[
|
||||
{"order_id": 1001, "customer": "Alice", "quantity": 2, "unit_price": 9.50},
|
||||
{"order_id": 1002, "customer": "Bob", "quantity": 1, "unit_price": 15.00},
|
||||
{"order_id": 1003, "customer": "Charlie", "quantity": 4, "unit_price": 7.25},
|
||||
{"order_id": 1004, "customer": "Dora", "quantity": 3, "unit_price": 11.00},
|
||||
]
|
||||
)
|
||||
|
||||
|
||||
@op
|
||||
def transform_example_dataset(df: pd.DataFrame) -> pd.DataFrame:
|
||||
"""Applies a simple transformation to the example dataset."""
|
||||
|
||||
df["price_band"] = df["total_price"].apply(
|
||||
lambda value: "high" if value >= 25 else "standard"
|
||||
)
|
||||
return df
|
||||
|
||||
Reference in New Issue
Block a user