cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Plotting in pyspark.pandas Uncaught ReferenceError Plotly is not defined

Data_Cowboy
New Contributor III

Hi,

I am trying to plot using pyspark.pandas running this sample code:

speed = [0.1, 17.5, 40, 48, 52, 69, 88]
lifespan = [2, 8, 70, 1.5, 25, 12, 28]
index = ['snail', 'pig', 'elephant',
         'rabbit', 'giraffe', 'coyote', 'horse']
psdf = ps.DataFrame({'speed': speed,
                     'lifespan': lifespan}, index=index)
psdf.plot.bar()

When I run the code, it returns the following error:

Error Message 

This code can be found in this notebook from Microsoft (https://docs.microsoft.com/en-us/azure/databricks/_static/notebooks/pandas-to-pandas-api-on-spark-in-10-minutes.html).

Is there something that I need to define Plotly?

Please let me know if I may provide any additional information. Thank you for your assistance.

1 ACCEPTED SOLUTION

Accepted Solutions

Data_Cowboy
New Contributor III

Thank you @Werner Stinckens​ . I was able to find the plotly documentation listed below and setting the output_type and calling displayHTML() helped remedy the error.

View solution in original post

4 REPLIES 4

Data_Cowboy
New Contributor III

Just wanted to follow up on this, using matplotlib as the backend circumvents this error.

ps.set_option("plotting.backend", "matplotlib")

-werners-
Esteemed Contributor III

can you check the visualisation docs?

There is a page for plotly.

Data_Cowboy
New Contributor III

Thank you @Werner Stinckens​ . I was able to find the plotly documentation listed below and setting the output_type and calling displayHTML() helped remedy the error.

Kaniz
Community Manager
Community Manager

Hi @Jacob Herzog​, I hope you're doing well. I'm glad that you've found the resolution to your error. Would you mind selecting the best answer?