<?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: AI functions with PySpark error in Data Science</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4899193#M985</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Glad to hear, you found the solution. Yeah, You can mark your own post as Solution.&lt;/P&gt;</description>
    <pubDate>Thu, 11 Dec 2025 03:42:25 GMT</pubDate>
    <dc:creator>v-karpurapud</dc:creator>
    <dc:date>2025-12-11T03:42:25Z</dc:date>
    <item>
      <title>AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4888264#M944</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have tried the AI functions capabilities in notebooks. The example with pandas dataframe worked for me. But the example as of the MS documentation with PySpark does not work.&lt;/P&gt;&lt;P&gt;Example from docs:&lt;/P&gt;&lt;P&gt;# This code uses AI. Always review output for mistakes.&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;df = spark.createDataFrame([&lt;BR /&gt;("Scarves",),&lt;BR /&gt;("Snow pants",),&lt;BR /&gt;("Ski goggles",)&lt;BR /&gt;], ["product"])&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;responses = df.ai.generate_response(prompt="Write a short, punchy email subject line for a winter sale.", output_col="response")&lt;BR /&gt;display(responses)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error message is:&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;AttributeError&lt;/SPAN&gt;&lt;SPAN&gt;: 'DataFrame' object has no attribute 'ai'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Anyone a idea about it?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;PS: yes, openai lib is installed and admin setting is enabled, thats why it works with pandas df's &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2025 09:31:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4888264#M944</guid>
      <dc:creator>Mauro89</dc:creator>
      <dc:date>2025-11-28T09:31:58Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4888411#M947</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The error happens because your notebook isn’t running with the Spark AI features that Microsoft Fabric requires for the .ai accessor to work on PySpark DataFrames. Even though pandas AI functions run fine, the Spark version only works when your notebook uses Fabric Runtime 1.2 or later and when your workspace has AI in Notebooks and AI Spark Extensions enabled. If either of these is missing, Spark won’t load the AI extension, which is why you see the AttributeError. To fix it, switch your notebook to Fabric Runtime 1.2+, enable the AI features in the Admin Portal, and restart the kernel. After that, the PySpark example from the Fabric docs will work as expected. If Spark AI still isn’t available in your environment, you can temporarily call it using the AISpark helper class until the extension is enabled.&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2025 12:41:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4888411#M947</guid>
      <dc:creator>ABD128</dc:creator>
      <dc:date>2025-11-28T12:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4888430#M948</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="930974" data-lia-user-login="ABD128" class="lia-mention lia-mention-user"&gt;ABD128&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;runtime is 1.3.&lt;/P&gt;&lt;P&gt;Do you mean this setting in the admin portal? If yes, it is enabled:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any other advise?&lt;/P&gt;</description>
      <pubDate>Fri, 28 Nov 2025 13:00:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4888430#M948</guid>
      <dc:creator>Mauro89</dc:creator>
      <dc:date>2025-11-28T13:00:58Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890320#M956</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Thank you for contacting the Microsoft Fabric community forum.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The setting shown in your screenshot enables Copilot/OpenAI features for the whole tenant, but it doesn't ensure that the Spark AI extension is active in your notebook session. The .ai accessor comes from the Spark AI integration, which relies on the AI Spark Extensions being enabled on the specific &lt;SPAN&gt;capacity&lt;/SPAN&gt; where your workspace is running.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even with Runtime 1.3, the extension might not load if the environment kernel starts without the AI Spark package or if the capacity-level AI features for “AI in notebooks / Spark AI Extensions” are not enabled.To check this, you can run the following in your notebook:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;hasattr(spark.createDataFrame([("x",)], ["col"]), "ai")&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If this returns False, the Spark AI extension did not load. If your capacity settings are correct but it still doesn’t load, it could be a deployment issue in that case, you should contact Fabric support, since .ai should be available on Runtime 1.3.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;As a workaround, you can use the helper class:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;from fabricext.ai import AISpark&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope this information is helpful. If you have any further questions, please let us know.&amp;nbsp;we can assist you further.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Microsoft Fabric Community Support Team.&lt;BR /&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2025 06:53:47 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890320#M956</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-12-02T06:53:47Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890443#M957</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="883005" data-lia-user-login="v-karpurapud" class="lia-mention lia-mention-user"&gt;v-karpurapud&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Iam still not sure to which extension you relate (&lt;SPAN&gt;AI Spark Extensions being enabled on the specific&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;capacity)?&lt;BR /&gt;Is it in the admin portal or where can I find it? As Iam Admin in the Fabric environment as well as capacity I assume I can enable it once found.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And the workaround throughs the follwoing error:&lt;BR /&gt;No module named 'fabricext'&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks and best regards!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2025 07:53:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890443#M957</guid>
      <dc:creator>Mauro89</dc:creator>
      <dc:date>2025-12-02T07:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890570#M958</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To clarify, when I mentioned “AI Spark Extensions being enabled on the capacity,” I did not mean there is a manual setting in the Admin Portal, as such an option does not exist. The Spark AI layer is included, but Microsoft activates it automatically during the Fabric Runtime rollout, and its availability may differ based on capacity or region.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;In this context, “enabled” signifies that the Spark AI components are present in the capacity’s runtime and accessible to notebooks. In your case, the absence of both df.ai and the fabricext module suggests that the Spark AI package is not yet available on your capacity, despite being on Runtime 1.3 with tenant-level Copilot/OpenAI enabled.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Since this extension is generally expected to be available, we recommend submitting a support ticket so the Fabric team can review your capacity and assist further.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;You can submit a ticket via the Microsoft Power BI Support Portal:&lt;/P&gt;
&lt;P&gt;&lt;A title="https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket" href="https://learn.microsoft.com/en-us/power-bi/support/create-support-ticket" target="_blank" rel="noreferrer noopener"&gt;How to create a Fabric and Power BI Support ticket - Power BI | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Microsoft Fabric Community Support Team.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2025 10:28:58 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890570#M958</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-12-02T10:28:58Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890669#M959</link>
      <description>&lt;P&gt;Thanks&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="883005" data-lia-user-login="v-karpurapud" class="lia-mention lia-mention-user"&gt;v-karpurapud&lt;/a&gt;&amp;nbsp;for clarification.&lt;/P&gt;&lt;P&gt;I have created a ticket and will keep this thread posted about the solution.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Dec 2025 12:10:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4890669#M959</guid>
      <dc:creator>Mauro89</dc:creator>
      <dc:date>2025-12-02T12:10:40Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4891275#M961</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN data-teams="true"&gt;Thanks for the update. Hope your issue gets resolved soon. when it does, please share the insights with the community as it can be helpful to others. &lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 03 Dec 2025 04:29:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4891275#M961</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-12-03T04:29:07Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4896574#M976</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&lt;BR /&gt;&lt;BR /&gt;Could you let us know if the issue was resolved after creating the support case?&lt;SPAN&gt;If you have any further questions, please let us know.&amp;nbsp;we can assist you further.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Microsoft Fabric Community Support Team&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2025 05:06:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4896574#M976</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-12-09T05:06:05Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4896748#M977</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="883005" data-lia-user-login="v-karpurapud" class="lia-mention lia-mention-user"&gt;v-karpurapud&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;we are still on it, trying to figure out whats the issue.&lt;/P&gt;&lt;P&gt;I will keep the thread posted &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards!&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2025 08:27:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4896748#M977</guid>
      <dc:creator>Mauro89</dc:creator>
      <dc:date>2025-12-09T08:27:25Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4897005#M978</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thank You for the response.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Dec 2025 11:30:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4897005#M978</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-12-09T11:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4898454#M984</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="883005" data-lia-user-login="v-karpurapud" class="lia-mention lia-mention-user"&gt;v-karpurapud&lt;/a&gt;&amp;nbsp;sooooo. I turned out to be the issue was sitting infront of the screen not in the screen&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":grinning_face_with_sweat:"&gt;😅&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I was only importing the libary for pandas and was not award that the pyspark library is a different one. So for all ready this post, the solution is to import the correct relevant library.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; synapse.ml.aifunc &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;aifunc --&amp;gt; for Pandas&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; synapse.ml.spark.aifunc &lt;/SPAN&gt;&lt;SPAN&gt;as&lt;/SPAN&gt; &lt;SPAN&gt;aifunc --&amp;gt; for PySpark&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Nevertheless, thanks for the support here in this thread!&lt;/DIV&gt;&lt;DIV&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="883005" data-lia-user-login="v-karpurapud" class="lia-mention lia-mention-user"&gt;v-karpurapud&lt;/a&gt;&amp;nbsp;may I can take my own answer as solution?&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Dec 2025 12:05:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4898454#M984</guid>
      <dc:creator>Mauro89</dc:creator>
      <dc:date>2025-12-10T12:05:05Z</dc:date>
    </item>
    <item>
      <title>Re: AI functions with PySpark error</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4899193#M985</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="937100" data-lia-user-login="Mauro89" class="lia-mention lia-mention-user"&gt;Mauro89&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Glad to hear, you found the solution. Yeah, You can mark your own post as Solution.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Dec 2025 03:42:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Science/AI-functions-with-PySpark-error/m-p/4899193#M985</guid>
      <dc:creator>v-karpurapud</dc:creator>
      <dc:date>2025-12-11T03:42:25Z</dc:date>
    </item>
  </channel>
</rss>

