Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
How can I convert a sempy.fabric.fabricdataframe to spark df?
The following does not work
dataset = (fabric
.evaluate_dax(workspace= server,
dataset=db,
dax_string=query_string)
).to_pandas()
AttributeError: 'FabricDataFrame' object has no attribute 'to_pandas()'
Solved! Go to Solution.
dataset = (fabric
.evaluate_dax(workspace= server,
dataset=db,
dax_string=query_string)
)
spark_df = spark.createDataFrame(dataset)
This works for me.
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.
"
The FabricDataFrame class:
"
dataset = (fabric
.evaluate_dax(workspace= server,
dataset=db,
dax_string=query_string)
)
spark_df = spark.createDataFrame(dataset)
This works for me.
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.
"
The FabricDataFrame class:
"
Liked the 1-liner; took a longer route which I can happily discard
# 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]]))]
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
5 | |
4 | |
2 | |
2 | |
2 |