我将尝试在Jupyter Notebook中将PySpark数据框以HTML表格的形式显示,但是所有方法似乎都失败了。
使用以下方法可显示文本格式的表格:
使用这种方法将HTML表格显示为字符串:
使用以下方法可显示文本格式的表格:
import pandas
df.toPandas()
使用这种方法将HTML表格显示为字符串:
df.toPandas().to_html()
这将以更漂亮的方式输出未解析的 HTML,但它不会被解析成表格:
print(df.toPandas().to_html())
同时,所有这些
from IPython.display import display, HTML
HTML(df.toPandas().to_html())
print(HTML(df.toPandas().to_html()))
display(HTML(df.toPandas().to_html()))
只需打印此对象描述:
<IPython.core.display.HTML object>
还有其他我可以尝试的想法吗?
<IPython.core.display.HTML object>
。 - mkirzonimport ipywidgets as widgets import pandas out = widgets.HTML("") out.value = df.toPandas().to_html(index=False, col_space="40px", classes=('table', 'table-striped'))
我的代码可以正常运行,如有问题请告知。 - nonoDa