验证加载到 Postgres 数据库的数据
在本练习中,您将最终构建一个端到端的数据管道。该管道会从一个 JSON 文件中抽取学校测试分数,并在转换阶段删除缺失分数的行。此外,还会根据总分对各学校按其所在城市进行排名。最后,转换后的数据集将被保存到 Postgres 数据库中。
为帮助您快速上手,extract() 和 transform() 函数已经构建完毕并按如下方式使用。此外,pandas 已以 pd 的别名导入。祝您顺利!
# Extract and clean the testing scores.
raw_testing_scores = extract("testing_scores.json")
cleaned_testing_scores = transform(raw_testing_scores)
本练习是课程的一部分
使用 Python 的 ETL 和 ELT
交互式实操练习
通过完成这段示例代码来试试这个练习。
def load(clean_data, con_engine):
# Store the data in the schools database
clean_data.____(
name="scores_by_city",
con=con_engine,
____="____", # Make sure to replace existing data
index=True,
index_label="school_id"
)