Skip to content

How to use dataframes from asset to asset? #23006

Discussion options

You must be logged in to vote

In this example, we'll return multiple assets in the create_dataframe function and they'll be used as inputs for the process_dataframe asset:

import pandas as pd
from dagster import asset, multi_asset, Definitions, AssetIn, AssetKey, AssetOut

@multi_asset(
    outs={
        "df1": AssetOut(),
        "df2": AssetOut()
    }
)
def create_dataframe(context):
    data1 = {
        'A': [1, 2, 3, 4],
        'B': [5, 6, 7, 8]
    }
    data2 = {
        'X': [9, 10, 11, 12],
        'Y': [13, 14, 15, 16]
    }
    df1 = pd.DataFrame(data1)
    df2 = pd.DataFrame(data2)
    context.log.info(f"Raw dataframe 1: {df1}")
    context.log.info(f"Raw dataframe 2: {df2}")
    return df1, df2  # Must…

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@JamarWhitfield
Comment options

@garethbrickman
Comment options

Answer selected by JamarWhitfield
@JamarWhitfield
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
area: asset Related to Software-Defined Assets
2 participants