David Takacs
03/11/2024, 4:14 PMScout
03/11/2024, 4:14 PMpython from dagster import asset, MetadataValue import pandas as pd @asset def my_asset(): # Create a sample DataFrame data = pd.DataFrame({ "orders": [1, 2, 3, 4], "users": ["pam", "jim", "michael", "dwight"] }) # Convert the DataFrame to markdown format markdown_representation = data.head().to_markdown() # Attach the markdown representation as metadata to the asset yield MetadataValue.md(markdown_representation), data
In this example, data.head().to_markdown()
converts the top rows of the DataFrame into a markdown string. The MetadataValue.md()
function is then used to indicate that the string should be rendered as markdown in the UI. When you yield this metadata along with the DataFrame, the markdown representation will be displayed in the Dagster UI under the asset's details. Please note that the actual code and methods to use may vary depending on the version of Dagster you are using and the specific requirements of your project. Always refer to the latest documentation for the most up-to-date practices.