abandoned_carts_df = (email_carts_df。
過濾器
(坳(
“轉換”
)= =
假
)。
過濾器
(坳(
“車”
).isNotNull ())
)
顯示器(abandoned_carts_df)
abandoned_items_df = (abandoned_carts_df.select(坳(
“購物車”
).alias (
“項目”
).groupBy (
“項目”
).count ()
)
顯示器(abandoned_items_df)
expected_columns = [
“項目”
,
“數”
]
expected_count =
12
斷言
= = expected_count abandoned_items_df.count (),
“數不匹配”
斷言
abandoned_items_df。列= =expected_columns,
“列不匹配”
打印
(
“所有測試通過”
)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
AssertionError回溯(最近調用最後)
<命令- 1787238488083704 >在
<細胞係:5 >
()
3expected_count
=
12
4
- - - - - > 5
斷言abandoned_items_df
。數
(
)
= =expected_count
,
“數不匹配”
6
7
斷言abandoned_items_df
。列
= =expected_columns
,
“列不匹配”
AssertionError:數量不匹配