Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

displayHTML() on Databricks returning Py4JException #12

Open
charraig opened this issue Mar 27, 2018 · 1 comment
Open

displayHTML() on Databricks returning Py4JException #12

charraig opened this issue Mar 27, 2018 · 1 comment

Comments

@charraig
Copy link

I'm trying to use this package on the Azure Databricks platform, but displayHTML() is returning the following exception: Py4JException: An exception was raised by the Python Proxy. Return Message: x

I am running Python 3 with Databricks Runtime Version 3.5 LTS (includes Apache Spark 2.2.1, Scala 2.11).

This is the code that produces the error, using the built-in 2013 IRS dataset:

import spark_df_profiling
csvFile = "dbfs:/databricks-datasets/data.gov/irs_zip_code_data/data-001/2013_soi_zipcode_agi.csv"
taxes2013 = (spark.read
             .option("delimiter",",")
             .option("header","true")
             .option("inferSchema","true")
             .csv(csvFile)
            )
taxes2013c = (taxes2013
              .select("STATEFIPS","STATE","zipcode","agi_stub","N1","MARS1","MARS2","MARS4","PREP")
              .cache())
profile = spark_df_profiling.ProfileReport(taxes2013c)
displayHTML(profile)
@pezon
Copy link

pezon commented May 2, 2018

displayHTML expects HTML text, but profile is a Python object. Use the object's html property:

displayHTML(profile.html)

That said, CSS styling and JS functionality is missing. There is a quick workaround (but not the most elegant solution):

bootstrap_html = """
<!doctype html>
  <html lang="en">
  <head>
    <meta charset="utf-8">
    <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script> 
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js"></script>
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.bundle.min.js"></script>
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" crossorigin="anonymous">
  </head>
</html>
"""

displayHTML(bootstrap_html + profile.html)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants