abandoned_carts_df = (email_carts_df.filter(col('converted') == False).filter(col('cart').isNotNull()))
display(abandoned_carts_df)
abandoned_items_df = (abandoned_carts_df.select(col("cart").alias("items")).groupBy("items").count())
display(abandoned_items_df)
expected_columns = ["items", "count"]
expected_count = 12
assert abandoned_items_df.count() == expected_count, "Counts do not match"
assert abandoned_items_df.columns == expected_columns, "Columns do not match"
print("All test pass")
AssertionError: Counts do not match
--------------------------------------------------------------------------- AssertionError Traceback (most recent call last)
<command-1787238488083704> in
<cell line: 5>() 3 expected_count
= 12 4 ----> 5 assert abandoned_items_df
.count
() == expected_count
, "Counts do not match" 6 7 assert abandoned_items_df
.columns
== expected_columns
, "Columns do not match" AssertionError: Counts do not match