Forum Discussion

frithjof_v's avatar
frithjof_v
Community Champion
1 year ago
Solved

Pandas API on Spark

Hi all,

 

I want to test how to use Pandas API on Spark.

I'm reading a delta table and I want to save it to a single CSV file.

I already know how to do this in regular pandas, but I'd like to try it with the Pandas API on Spark.

I have a default lakehouse attached to my Notebook, and it works if I am using regular pandas.

 

 

import pyspark.pandas as ps

df = spark.read.load("abfss://[email protected]/TestLakehouse.Lakehouse/Tables/RandomNumbers")
df = df.limit(100)

df_pandasOnSpark = df.pandas_api()

df_pandasOnSpark.to_csv('/lakehouse/default/Files/RandomNumbers_PandasOnSpark.csv', header=True, index = False)

 

 

I'm getting the following error:

Py4JJavaError: An error occurred while calling o6290.save. : Operation failed: "Bad Request", 400, HEAD, http://onelake.dfs.fabric.microsoft.com/<workspaceGUID>/lakehouse/default/Files/RandomNumbers_PandasOnSpark.csv?upn=false&action=getStatus&timeout=90   

 

Anyone knows what I'm doing wrong & how I could get this to work?

 

Thanks in advance!

2 Replies