[英]Why does Jupyter notebook NOT execute all the lines of code? (iPython)
[英]execute multiple lines in jupyter notebook
我是python和jupyter筆記本的新手。
搜索后,我發現如果要對sqlContext執行多行,則必須使用三元組“””,如下所示:
sqlContext.sql("""select year,month,count(distinct station) as count
from tempReadingsTable
where year>=1950 and year<=2014 and value>=10
group by year,month
order by count desc
""").show()
現在,我試圖為此找到相同的內容:
schMax = schMax.groupBy('year').
agg(fun.max('value').alias('value')).
join(sch['year','value']).
drop_duplicates(['year']).
select(['year','station','value']).
orderBy(['value'],ascending=[0])
除非我全部運行一行,否則它將失敗! 我該如何預防呢? 我希望能夠分別執行所有行...
您可以在一行的末尾使用\\
來讓python繼續讀取下一行作為上一行的一部分(如果需要,請刪除空格)。 盡管我認為如果將放進去,則可讀性更高.
在每個新行的開頭。 顯然,它是上一條語句的一部分,因為普通語句從不以開頭.
在python中。
schMax = schMax.groupBy('year')\
.agg(fun.max('value').alias('value'))\
.join(sch['year','value'])\
.drop_duplicates(['year'])\
.select(['year','station','value'])\
.orderBy(['value'],ascending=[0])
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.