Josh Dunkley
03/07/2025, 10:04 PMMarvin
03/07/2025, 10:04 PMpython
from prefect import flow, task
import pandas as pd
@task
def create_dataframe():
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
return df
@flow
def save_dataframe_as_variable():
df = create_dataframe()
print(df)
if __name__ == "__main__":
save_dataframe_as_variable()
In this example, the create_dataframe
task returns a DataFrame, which is then handled by the save_dataframe_as_variable
flow. You can store the DataFrame in a variable within the flow scope, and use it as needed.
For more advanced storage options, such as persisting data between flow runs or using cloud storage, you might consider using Prefect's storage blocks or caching mechanisms. You can explore more about handling big data and optimizing Prefect workflows in their big data documentation.
This approach aligns with your preference for an imperative programming style. If you need further details or have specific requirements, feel free to ask!