F. Nikita Thomas
09/05/2022, 4:54 PMprefect[viz]
was installed, but with the current version ,<2.3.1> , I'm having difficulties get some basic code to work - Could someone please assist? Thanks!
import requests
from pprint import pprint as pp
from prefect import flow, task, Flow
import pandas as pd
import json
## extract
@task(name="extract")
def get_data():
r = requests.get("<https://rickandmortyapi.com/api/character/>")
return r.json()
@task
def transform(r: dict):
df = pd.json_normalize(r["results"])
print(df)
@task(name="load")
def write_frame(df: pd.DataFrame):
pass
"""
## This is the way to visualize flow before current version
with Flow("ETL") as flow:
e = get_data()
t = transform(e)
l = write_frame(t)
flow.visualize()
"""
@flow
def flow_test():
e = get_data()
t = transform(e)
l = write_frame(t)
flow_test().visualize() # This doesn't work...
Anna Geller
09/05/2022, 9:00 PM