<?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 Converting Fabric dataframe to spark dataframe in Data Engineering</title>
    <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Converting-Fabric-dataframe-to-spark-dataframe/m-p/4151035#M4083</link>
    <description>&lt;P&gt;How can I convert a &lt;A href="https://learn.microsoft.com/en-us/python/api/semantic-link-sempy/sempy.fabric.fabricdataframe?view=semantic-link-python" target="_self"&gt;sempy.fabric.fabricdataframe&lt;/A&gt; to spark df?&lt;/P&gt;
&lt;P&gt;The following does not work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dataset = (fabric
            .evaluate_dax(workspace= server,
            dataset=db,
            dax_string=query_string)
    ).to_pandas()


AttributeError: 'FabricDataFrame' object has no attribute 'to_pandas()'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sun, 15 Sep 2024 01:22:29 GMT</pubDate>
    <dc:creator>smpa01</dc:creator>
    <dc:date>2024-09-15T01:22:29Z</dc:date>
    <item>
      <title>Converting Fabric dataframe to spark dataframe</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Converting-Fabric-dataframe-to-spark-dataframe/m-p/4151035#M4083</link>
      <description>&lt;P&gt;How can I convert a &lt;A href="https://learn.microsoft.com/en-us/python/api/semantic-link-sempy/sempy.fabric.fabricdataframe?view=semantic-link-python" target="_self"&gt;sempy.fabric.fabricdataframe&lt;/A&gt; to spark df?&lt;/P&gt;
&lt;P&gt;The following does not work&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;dataset = (fabric
            .evaluate_dax(workspace= server,
            dataset=db,
            dax_string=query_string)
    ).to_pandas()


AttributeError: 'FabricDataFrame' object has no attribute 'to_pandas()'&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2024 01:22:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Converting-Fabric-dataframe-to-spark-dataframe/m-p/4151035#M4083</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2024-09-15T01:22:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Fabric dataframe to spark dataframe</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Converting-Fabric-dataframe-to-spark-dataframe/m-p/4151376#M4089</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;dataset = (fabric
            .evaluate_dax(workspace= server,
            dataset=db,
            dax_string=query_string)
    )

spark_df = spark.createDataFrame(dataset)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works for me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think you can treat the Fabric dataframe as a Pandas dataframe, and convert it to a Spark dataframe the same way you would convert a Pandas dataframe to a Spark dataframe.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/fabric/data-science/semantic-link-overview#fabricdataframe-data-structure" target="_blank" rel="noopener"&gt;https://learn.microsoft.com/en-us/fabric/data-science/semantic-link-overview#fabricdataframe-data-structure&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;"&lt;BR /&gt;The&amp;nbsp;FabricDataFrame&amp;nbsp;class:&lt;/EM&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;EM&gt;Supports all pandas operations.&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;Subclasses the&amp;nbsp;pandas DataFrame&amp;nbsp;and adds metadata, such as semantic information and lineage.&lt;/EM&gt;&lt;/LI&gt;&lt;LI&gt;&lt;EM&gt;(...)&lt;BR /&gt;&lt;/EM&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;EM&gt;"&lt;/EM&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2024 19:03:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Converting-Fabric-dataframe-to-spark-dataframe/m-p/4151376#M4089</guid>
      <dc:creator>frithjof_v</dc:creator>
      <dc:date>2024-09-15T19:03:29Z</dc:date>
    </item>
    <item>
      <title>Re: Converting Fabric dataframe to spark dataframe</title>
      <link>https://community.fabric.microsoft.com/t5/Data-Engineering/Converting-Fabric-dataframe-to-spark-dataframe/m-p/4151379#M4090</link>
      <description>&lt;P&gt;Liked the 1-liner; took a longer route which I can happily discard&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;# data_as_dict = dataset.to_dict()
# columns = dataset.columns

# flattened_rows = [Row(**{col: data_as_dict[col][i] for col in columns}) for i in range(len(data_as_dict[columns[0]]))]&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 15 Sep 2024 18:59:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Data-Engineering/Converting-Fabric-dataframe-to-spark-dataframe/m-p/4151379#M4090</guid>
      <dc:creator>smpa01</dc:creator>
      <dc:date>2024-09-15T18:59:42Z</dc:date>
    </item>
  </channel>
</rss>

