建立列数范围 Expectation
在此练习中,您将针对可再生能源发电数据集的列数编写一个 Expectation。假设列的数量可能会变化,但应始终保持在以 16 为中心的区间内。
可再生能源发电数据集已加载为一个 Batch,并赋值给变量 batch。Great Expectations 和 pandas 分别以 gx 和 pd 的名称可用。
本练习是课程的一部分
使用 Great Expectations 的数据质量入门
练习说明
- 编写一个 Expectation,要求数据集的列数应在 16 左右,允许正负 2 的浮动。
- 验证您的 Expectation。
- 打印该 Expectation 的成功状态,以及实际的列数。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Create the Expectation
col_count_expectation = gx.expectations.____(
min_value=____, ____=____
)
# Validate the Expectation
validation_results = batch.____(
expect=____
)
# Print out the success status
print(____.____)
# Print out the actual column count
print(____.____)