<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Plot number of abandoned cart items by product in Get Started Discussions</title>
    <link>https://community.databricks.com/t5/get-started-discussions/plot-number-of-abandoned-cart-items-by-product/m-p/38445#M5530</link>
    <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/85173"&gt;@SSV_dataeng&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;What is the question here?&lt;/P&gt;</description>
    <pubDate>Wed, 26 Jul 2023 05:50:08 GMT</pubDate>
    <dc:creator>daniel_sahal</dc:creator>
    <dc:date>2023-07-26T05:50:08Z</dc:date>
    <item>
      <title>Plot number of abandoned cart items by product</title>
      <link>https://community.databricks.com/t5/get-started-discussions/plot-number-of-abandoned-cart-items-by-product/m-p/38271#M5529</link>
      <description>&lt;DIV&gt;&lt;SPAN&gt;abandoned_carts_df = (email_carts_df.&lt;/SPAN&gt;&lt;SPAN&gt;filter&lt;/SPAN&gt;&lt;SPAN&gt;(col(&lt;/SPAN&gt;&lt;SPAN&gt;'converted'&lt;/SPAN&gt;&lt;SPAN&gt;) == &lt;/SPAN&gt;&lt;SPAN&gt;False&lt;/SPAN&gt;&lt;SPAN&gt;).&lt;/SPAN&gt;&lt;SPAN&gt;filter&lt;/SPAN&gt;&lt;SPAN&gt;(col(&lt;/SPAN&gt;&lt;SPAN&gt;'cart'&lt;/SPAN&gt;&lt;SPAN&gt;).isNotNull())&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;display(abandoned_carts_df)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SSV_dataeng_0-1690194232666.png" style="width: 649px;"&gt;&lt;img src="https://community.databricks.com/t5/image/serverpage/image-id/2963i3C206ADD15B789D4/image-dimensions/649x389/is-moderation-mode/true?v=v2" width="649" height="389" role="button" title="SSV_dataeng_0-1690194232666.png" alt="SSV_dataeng_0-1690194232666.png" /&gt;&lt;/span&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;abandoned_items_df = (abandoned_carts_df.select(col(&lt;/SPAN&gt;&lt;SPAN&gt;"cart"&lt;/SPAN&gt;&lt;SPAN&gt;).alias(&lt;/SPAN&gt;&lt;SPAN&gt;"items"&lt;/SPAN&gt;&lt;SPAN&gt;)).groupBy(&lt;/SPAN&gt;&lt;SPAN&gt;"items"&lt;/SPAN&gt;&lt;SPAN&gt;).count()&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;display(abandoned_items_df)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;verfiication Failed&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;expected_columns = [&lt;/SPAN&gt;&lt;SPAN&gt;"items"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"count"&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;expected_count = &lt;/SPAN&gt;&lt;SPAN&gt;12&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;assert&lt;/SPAN&gt;&lt;SPAN&gt; abandoned_items_df.count() == expected_count, &lt;/SPAN&gt;&lt;SPAN&gt;"Counts do not match"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;assert&lt;/SPAN&gt;&lt;SPAN&gt; abandoned_items_df.columns == expected_columns, &lt;/SPAN&gt;&lt;SPAN&gt;"Columns do not match"&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;print&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;"All test pass"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;AssertionError&lt;/SPAN&gt;: Counts do not match&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;SPAN class=""&gt;---------------------------------------------------------------------------&lt;/SPAN&gt; &lt;SPAN class=""&gt;AssertionError&lt;/SPAN&gt; Traceback (most recent call last) &lt;A&gt;&amp;lt;command-1787238488083704&amp;gt;&lt;/A&gt; in &lt;SPAN class=""&gt;&amp;lt;cell line: 5&amp;gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;()&lt;/SPAN&gt; &lt;SPAN&gt;3&lt;/SPAN&gt; expected_count &lt;SPAN class=""&gt;=&lt;/SPAN&gt; &lt;SPAN class=""&gt;12&lt;/SPAN&gt; &lt;SPAN&gt;4&lt;/SPAN&gt; &lt;SPAN class=""&gt;----&amp;gt; 5&lt;/SPAN&gt; &lt;SPAN class=""&gt;assert&lt;/SPAN&gt; abandoned_items_df&lt;SPAN class=""&gt;.&lt;/SPAN&gt;count&lt;SPAN class=""&gt;(&lt;/SPAN&gt;&lt;SPAN class=""&gt;)&lt;/SPAN&gt; &lt;SPAN class=""&gt;==&lt;/SPAN&gt; expected_count&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;"Counts do not match"&lt;/SPAN&gt; &lt;SPAN&gt;6&lt;/SPAN&gt; &lt;SPAN&gt;7&lt;/SPAN&gt; &lt;SPAN class=""&gt;assert&lt;/SPAN&gt; abandoned_items_df&lt;SPAN class=""&gt;.&lt;/SPAN&gt;columns &lt;SPAN class=""&gt;==&lt;/SPAN&gt; expected_columns&lt;SPAN class=""&gt;,&lt;/SPAN&gt; &lt;SPAN class=""&gt;"Columns do not match"&lt;/SPAN&gt; &lt;SPAN class=""&gt;AssertionError&lt;/SPAN&gt;: Counts do not match&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 24 Jul 2023 10:25:13 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/plot-number-of-abandoned-cart-items-by-product/m-p/38271#M5529</guid>
      <dc:creator>SSV_dataeng</dc:creator>
      <dc:date>2023-07-24T10:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Plot number of abandoned cart items by product</title>
      <link>https://community.databricks.com/t5/get-started-discussions/plot-number-of-abandoned-cart-items-by-product/m-p/38445#M5530</link>
      <description>&lt;P&gt;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/85173"&gt;@SSV_dataeng&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;What is the question here?&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jul 2023 05:50:08 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/plot-number-of-abandoned-cart-items-by-product/m-p/38445#M5530</guid>
      <dc:creator>daniel_sahal</dc:creator>
      <dc:date>2023-07-26T05:50:08Z</dc:date>
    </item>
    <item>
      <title>Re: Plot number of abandoned cart items by product</title>
      <link>https://community.databricks.com/t5/get-started-discussions/plot-number-of-abandoned-cart-items-by-product/m-p/38573#M5531</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.databricks.com/t5/user/viewprofilepage/user-id/85173"&gt;@SSV_dataeng&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;Try&amp;nbsp;&lt;/P&gt;&lt;P&gt;abandoned_items_df = (abandoned_carts_df&lt;BR /&gt;.withColumn("items", explode("cart"))&lt;BR /&gt;.groupBy("items")&lt;BR /&gt;.count()&lt;BR /&gt;.sort("items")&lt;BR /&gt;)&lt;/P&gt;</description>
      <pubDate>Thu, 27 Jul 2023 12:16:42 GMT</pubDate>
      <guid>https://community.databricks.com/t5/get-started-discussions/plot-number-of-abandoned-cart-items-by-product/m-p/38573#M5531</guid>
      <dc:creator>NandiniN</dc:creator>
      <dc:date>2023-07-27T12:16:42Z</dc:date>
    </item>
  </channel>
</rss>

