pyspark.sql.DataFrame
显示凌乱的DataFrame.show()
- 换行而不是滚动。
我尝试了这些选项
import IPython
IPython.auto_scroll_threshold = 9999
from IPython.core.interactiveshell import InteractiveShell
InteractiveShell.ast_node_interactivity = "all"
from IPython.display import display
但没有运气。虽然在Atom编辑器中使用jupyter插件时滚动工作:
答案 0 :(得分:11)
这是一种解决方法
@NgModule({
declarations: [
//declaration
],
imports: [
//other modules
ComponentsModule,
],
bootstrap: [IonicApp],
entryComponents: [
//ionic pages
],
providers: [
StatusBar,
SplashScreen,
{provide: ErrorHandler, useClass: IonicErrorHandler},
//other providers
]
})
export class AppModule {}
尽管,我不知道此查询的计算负担。我认为spark_df.limit(5).toPandas().head()
并不昂贵。更正。
答案 1 :(得分:8)
只需编辑css文件,一切就好了。
打开jupyter笔记本../site-packages/notebook/static/style/style.min.css
文件。
搜索white-space: pre-wrap;
,然后将其删除。
保存文件并重新启动jupyter-notebook。
问题已解决。 :)
答案 2 :(得分:1)
除了上述@ karan-singla和@ vijay-jangir给出的答案之外,可以方便地用单线注释掉white-space: pre-wrap
样式的方式如下:
$ awk -i inplace '/pre-wrap/ {$0="/*"$0"*/"}1' $(dirname `python -c "import notebook as nb;print(nb.__file__)"`)/static/style/style.min.css
这翻译为;使用awk
更新包含pre-wrap
的 inplace 行,将其用*/ -- */
包围,即注释掉您在styles.css
中找到的文件工作的Python环境。
从理论上讲,如果人们使用多个环境(例如Anaconda),则可以将其用作别名。
参考:
答案 3 :(得分:0)
我不确定是否仍然有人在面对这个问题。但这可以通过使用开发人员工具调整某些网站设置来解决。
打开开发人员设置( F12 )。然后检查元素( ctrl + shift + c ) 然后单击输出。并取消选中空格属性(请参见下面的快照)
您只需要执行一次此操作即可。 (除非刷新页面)
这将直接向您显示确切的数据。无需转换为熊猫。
答案 4 :(得分:0)
尝试display(dataframe_name)
,它呈现可滚动的表格。
答案 5 :(得分:0)
准确来说是之前有人说过的话。
在文件 YES
有 2 anaconda3/lib/python3.7/site- packages/notebook/static/style/style.min.css
你必须以这种方式在这里评论一个 white-space: nowrap;
保存并重启jupyter
答案 6 :(得分:-1)
我在li' l函数下创建了它并且工作正常:
def printDf(sprkDF):
newdf = sprkDF.toPandas()
from IPython.display import display, HTML
return HTML(newdf.to_html())
如果您愿意,可以直接在火花查询中使用它,或者在任何火花数据框上使用它:
printDf(spark.sql('''
select * from employee
'''))