<?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: How does Vectorized Pandas UDF work? in Data Engineering</title>
    <link>https://community.databricks.com/t5/data-engineering/how-does-vectorized-pandas-udf-work/m-p/25288#M17569</link>
    <description>&lt;P&gt;&lt;I&gt;&amp;gt;How does Vectorized Pandas UDF work?&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Here is a video explaining the internals of Pandas UDFs (a.k.a. Vectorized UDFs) -  &lt;A href="https://youtu.be/UZl0pHG-2HA?t=123" target="test_blank"&gt;https://youtu.be/UZl0pHG-2HA?t=123&lt;/A&gt; . They use &lt;A href="http://arrow.apache.org/" alt="http://arrow.apache.org/" target="_blank"&gt;Apache Arrow&lt;/A&gt;, to exchange data directly between JVM and Python driver/executors with near-zero (de)serialization cost.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;gt;Do Vectorized Pandas UDFs apply to batches of data sequentially or in parallel?&lt;/I&gt;&lt;/P&gt;&lt;P&gt;If let's say  subtract_mean is a grouped map - when you run &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.groupby("id").apply(subtract_mean).show()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;partitions in spark are converted into arrow record batches and depending on the cardinality of id, multiple batches would be processed in parallel. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;gt;And is there a way to set the batch size?&lt;/I&gt;&lt;/P&gt;&lt;P&gt;You could configure spark.sql.execution.arrow.maxRecordsPerBatch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 18 Jun 2021 00:23:35 GMT</pubDate>
    <dc:creator>sajith_appukutt</dc:creator>
    <dc:date>2021-06-18T00:23:35Z</dc:date>
    <item>
      <title>How does Vectorized Pandas UDF work?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-vectorized-pandas-udf-work/m-p/25287#M17568</link>
      <description>&lt;P&gt;Do Vectorized Pandas UDFs apply to batches of data sequentially or in parallel? And is there a way to set the batch size?&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jun 2021 17:57:58 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-vectorized-pandas-udf-work/m-p/25287#M17568</guid>
      <dc:creator>User16752246553</dc:creator>
      <dc:date>2021-06-10T17:57:58Z</dc:date>
    </item>
    <item>
      <title>Re: How does Vectorized Pandas UDF work?</title>
      <link>https://community.databricks.com/t5/data-engineering/how-does-vectorized-pandas-udf-work/m-p/25288#M17569</link>
      <description>&lt;P&gt;&lt;I&gt;&amp;gt;How does Vectorized Pandas UDF work?&lt;/I&gt;&lt;/P&gt;&lt;P&gt;Here is a video explaining the internals of Pandas UDFs (a.k.a. Vectorized UDFs) -  &lt;A href="https://youtu.be/UZl0pHG-2HA?t=123" target="test_blank"&gt;https://youtu.be/UZl0pHG-2HA?t=123&lt;/A&gt; . They use &lt;A href="http://arrow.apache.org/" alt="http://arrow.apache.org/" target="_blank"&gt;Apache Arrow&lt;/A&gt;, to exchange data directly between JVM and Python driver/executors with near-zero (de)serialization cost.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;gt;Do Vectorized Pandas UDFs apply to batches of data sequentially or in parallel?&lt;/I&gt;&lt;/P&gt;&lt;P&gt;If let's say  subtract_mean is a grouped map - when you run &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;df.groupby("id").apply(subtract_mean).show()&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;partitions in spark are converted into arrow record batches and depending on the cardinality of id, multiple batches would be processed in parallel. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;I&gt;&amp;gt;And is there a way to set the batch size?&lt;/I&gt;&lt;/P&gt;&lt;P&gt;You could configure spark.sql.execution.arrow.maxRecordsPerBatch&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Jun 2021 00:23:35 GMT</pubDate>
      <guid>https://community.databricks.com/t5/data-engineering/how-does-vectorized-pandas-udf-work/m-p/25288#M17569</guid>
      <dc:creator>sajith_appukutt</dc:creator>
      <dc:date>2021-06-18T00:23:35Z</dc:date>
    </item>
  </channel>
</rss>

