{"id":417805,"date":"2024-06-30T01:46:39","date_gmt":"2024-06-30T01:46:39","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=417805"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-06-30T01:46:39","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=417805","title":{"rendered":"<span>\u0421\u0442\u0440\u043e\u0438\u043c \u0442\u0435\u043f\u043b\u043e\u0432\u044b\u0435 \u043a\u0430\u0440\u0442\u044b \u0432 Apache Zeppelin<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c\u0438, \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Apache Zeppelin \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441\u043e Spark \u043d\u0430 Scala, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b07\/e79\/f32\/b07e79f32739d0d669157c7ddd4b331e.png\" alt=\"\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 &quot;\u0441\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u0438\u044f\u043d\u0438\u0435&quot;? \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c? \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u0435\u0445\u0430\u043b\u0438!\" title=\"\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 &quot;\u0441\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u0438\u044f\u043d\u0438\u0435&quot;? \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c? \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u0435\u0445\u0430\u043b\u0438!\" width=\"1589\" height=\"909\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b07\/e79\/f32\/b07e79f32739d0d669157c7ddd4b331e.png\"\/><figcaption>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 &#171;\u0441\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u0438\u044f\u043d\u0438\u0435&#187;? \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c? \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u0435\u0445\u0430\u043b\u0438!<\/figcaption><\/figure>\n<p>\u041d\u0430 \u043d\u044b\u043d\u0435\u0448\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u0440\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0432\u0435\u0435\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u044d\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438: <\/p>\n<ol>\n<li>\n<p>\u043d\u0430\u0439\u0442\u0438 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043c\u0435\u0440\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0432\u0435\u0435\u0440\u0430 \u0434\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u043d\u0446\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c; <\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0438 \u0441 \u0447\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u044b. <\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043b\u043d\u043e\u0442\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u0442 \u043b\u0438 \u0432 \u043d\u0438\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432, \u043d\u0435 \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 Timescale, \u0430 \u0435\u0449\u0435 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Apache Spark (\u0432 \u043d\u0430\u0448\u0435\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0436\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 Scala), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438 \u0432 Hadoop. \u041f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0432 Apache Zeppelin, \u0432\u0435\u0434\u044c \u0432 \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0435 \u0436\u0435 \u043d\u0430\u0432\u044b\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0438 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0436\u043e\u0431 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f Scala-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0435 \u0441\u0442\u0440\u0430\u0448\u0438\u0442, \u0442\u043e \u0432\u043e\u0442 \u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Python \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Bokeh \u043d\u0438\u0447\u0435\u0433\u043e \u0432 Zeppelin \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0432\u0438\u0434 \u0432\u0443\u0437\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e \u0434\u043b\u044f Scala-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 spark-\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 Zeppelin \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0435\u043a\u0438\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 &#8212; \u0432\u044b\u0442\u0430\u0449\u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b \u0438\u043b\u0438 \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432 Parquet \u0432 Hadoop, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u043a\u0430\u043a \u0445\u043e\u0442\u0438\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0438\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0441\u0432\u043e\u0438 \u043d\u043e\u0432\u044b\u0435 \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043d\u0438\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430v \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438. \u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0443\u044e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>ourDataframe.show(100,\u00a0false)  \/\/\u0432 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0446\u0435\u043f\u0435\u043b\u043b\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u0435\u0440\u0432\u044b\u0435 100 \u0441\u0442\u0440\u043e\u0447\u0435\u043a println(ourDataframe.count())  \/\/\u0430 \u0435\u0449\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 ourDataframe.registerTempTable(\"tableexample\") \/\/\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0435<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438? \u042d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 <code>%sql<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 &#171;\u0446\u0435\u043f\u0435\u043b\u043b\u0438\u043d\u0430&#187; \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p><code>%sql select  hour,  max from tableexample<\/code><\/p>\n<p>\u041f\u0440\u0438 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/382\/d74\/425\/382d7442516641d11e5e8af49ba3acae.png\" alt=\"\" title=\"\" width=\"1708\" height=\"472\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/382\/d74\/425\/382d7442516641d11e5e8af49ba3acae.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041c\u0438\u043d\u0443\u0441 \u0435\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0435 \u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Bokeh.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0443 (\u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440) \u0441 Zeppelin. <\/p>\n<p><code>RUN pip install -q numpy==1.17.3 <\/code><\/p>\n<p><code>RUN pip install -q pandas==0.25.0 <\/code><\/p>\n<p><code>RUN pip3 install -q bokeh==2.4.2<\/code>  <\/p>\n<p><code>RUN pip3 install -q bkzep<\/code>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0443 \u043d\u0430\u0441 \u043f\u0440\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0437\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0451 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u043e\u0435 (\u043f\u043e\u043c\u0438\u043c\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 pyspark \u0438 \u0442.\u043f.), \u0447\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 &#171;\u0433\u043b\u0430\u0432\u0430\u0445&#187; Zeppelin \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u043c\u0438 \u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c\u0438. \u0421\u043e\u0437\u0434\u0430\u0435\u043c &#171;\u0433\u043b\u0430\u0432\u0443&#187; \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c <code>%spark.pyspark<\/code><\/p>\n<pre><code>%spark.pyspark import bkzep import numpy as np from bokeh.io import output_notebook, show from bokeh.plotting import figure from bokeh.models import ColumnDataSource from bokeh.layouts import gridplot from pyspark.sql.functions import col, coalesce, lit, monotonically_increasing_id from pyspark.sql import DataFrame from pyspark.sql.functions import * output_notebook(notebook_type='zeppelin')<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0435, \u0442\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u043e\u043a \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 BokehJS, \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0435 \u0438\u0434\u0435\u0442 \u043a\u0430\u043a \u043d\u0430\u0434\u043e:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e08\/f85\/ba0\/e08f85ba0b9fbc65b571d22db40a1592.png\" alt=\"\" title=\"\" width=\"1698\" height=\"408\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e08\/f85\/ba0\/e08f85ba0b9fbc65b571d22db40a1592.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e &#171;\u0433\u043b\u0430\u0432&#187;, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u0434 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435 \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0440\u0438\u0441\u043e\u0432\u043a\u043e\u0439 \u043d\u0443\u0436\u043d\u043e\u0439 \u043d\u0430\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 &#171;\u0446\u0435\u043f\u0435\u043b\u043b\u0438\u043d\u0430&#187; \u0442\u0430\u0431\u043b\u0438\u0446, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 &#171;pivoted&#187;.<\/p>\n<pre><code>%pyspark from\u00a0pyspark.sql.functions\u00a0import\u00a0* def\u00a0plot_summaries(sensor,\u00a0dfName): \u00a0\u00a0\u00a0\u00a0df\u00a0=\u00a0sqlContext.table(dfName) #\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 PySpark \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 Zeppeling \u00a0\u00a0\u00a0\u00a0pdf\u00a0=\u00a0df.toPandas() #\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 dataFrame Pandas \u00a0\u00a0\u00a0\u00a0source\u00a0=\u00a0ColumnDataSource(pdf) #\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u043b\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u00a0\u00a0\u00a0\u00a0fig\u00a0=\u00a0figure(title=\"Mean\u00a0and\u00a0Standard\u00a0deviation\u00a0of\u00a0'{}'\".format(sensor)) #\u0437\u0430\u0434\u0430\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0433\u0440\u0430\u0444\u0438\u043a\u0430, \u0442\u0443\u0442 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u00a0\u00a0\u00a0\u00a0fig.line(x='index',\u00a0y=sensor+'_mean',\u00a0source=source,\u00a0color=\"orange\") \u00a0\u00a0\u00a0\u00a0fig.line(x='index',\u00a0y=sensor+'_stddev',\u00a0source=source,\u00a0color=\"blue\") \u00a0\u00a0\u00a0\u00a0show(gridplot([fig],\u00a0ncols=1,\u00a0plot_width=1000,\u00a0plot_height=400)) #\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043b\u0438\u043d\u0438\u0439 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 sensors\u00a0=\u00a0[ \u00a0\u00a0\u00a0\u00a0\"Water_Level_Sensor\", \u00a0\u00a0\u00a0\u00a0\"Water_Temperature_Sensor\", \u00a0\u00a0] for\u00a0sensor\u00a0in\u00a0sensors: \u00a0\u00a0\u00a0\u00a0plot_summaries(sensor,\u00a0\"pivoted\")<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0432\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0441\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0440\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u044b\u043c \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u0435\u0449\u0435 \u0434\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 &#171;\u0441\u043f\u0430\u0440\u043a\u0435&#187; \u0438 \u0443\u043b\u043e\u0436\u0438\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#171;pivoted&#187;, \u043a\u0430\u043a \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0443 index:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/743\/1b2\/8fe\/7431b28fe98388e8b41e492b0ebdb510.png\" alt=\"\" title=\"\" width=\"1007\" height=\"852\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/743\/1b2\/8fe\/7431b28fe98388e8b41e492b0ebdb510.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438, \u0442\u043e, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u043b\u0438\u043d\u0438\u044f\u043c\u0438 &#8212; \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043e\u043a\u043d\u0435. \u041d\u043e \u043a\u0443\u0434\u0430 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u0440\u0430\u0444\u0438\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0430\u043c\u0438\u043c. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u043a\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043e\u0441\u0438 x (\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435), \u043d\u043e \u0438 \u043f\u043e \u043e\u0441\u0438 y (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f), \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043f\u0430\u043b\u043e \u0432 &#171;\u043e\u043a\u043d\u0430&#187; \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 3\u0445-\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0433\u0434\u0435 \u0442\u043e\u0447\u043a\u0430 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 x \u0438 y \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0446\u0432\u0435\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043f\u0430\u0432\u0448\u0435\u0433\u043e \u0432 &#171;\u0432\u0435\u0434\u0440\u043e&#187; (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c &#171;\u043e\u043a\u043d\u043e\u043c&#187; \u043f\u043e x \u0438 y). \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0442\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0442\u0430\u043a \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043b\u0435\u0433\u043b\u043e \u0432\u0434\u043e\u043b\u044c &#171;\u0446\u0435\u043d\u0442\u0440\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439&#187;, \u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0448\u043b\u043e \u0432 &#171;\u0432\u044b\u0431\u0440\u043e\u0441\u044b&#187;, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u0442\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0435\u0441\u043b\u0438 &#171;\u0432\u044b\u0431\u0440\u043e\u0441\u044b&#187; \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e, \u0430 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0437\u0430\u043a\u043e\u043d\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u044b\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0442\u0430\u043a\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u044d\u0442\u043e\u0439 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0432\u0435\u0435\u0440\u0435 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u043e \u0432 \u0446\u0435\u043b\u044b\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u044f\u0441\u044c \u0438\u043b\u0438 \u043e\u043a\u043e\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u043b\u044b\u0445 \u0438\u043b\u0438 \u043e\u043a\u043e\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0442\u0435\u043c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u0442 150 \u0434\u043e 400 \u043f\u043e \u043e\u0441\u0438 y). \u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430, \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430, \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0434\u043e\u043d\u0435\u0441\u0442\u0438 \u0434\u043e \u043d\u0430\u0441 \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041f\u043b\u044e\u0441 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0440\u0435\u0437\u043a\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u0440\u0435\u043c\u0435\u043d \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/508\/cad\/300\/508cad3000231a84caf54221d3eb690a.png\" alt=\"\" title=\"\" width=\"985\" height=\"405\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/508\/cad\/300\/508cad3000231a84caf54221d3eb690a.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u0430\u0441\u0441\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u0438\u043c\u0438\u0442\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435, \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u0431\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u044f\u0432\u043d\u043e \u043f\u0430\u0434\u0430\u0435\u0442, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u0435\u0433\u0440\u0430\u0434\u0438\u0440\u0443\u0435\u0442, \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0435\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u044b-\u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430, \u0447\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043a\u0430\u043a &#171;\u0437\u0430\u0431\u043e\u0440 \u0438\u0437 \u0436\u0435\u0440\u0434\u0435\u0439&#187;, \u0442\u043e\u0440\u0447\u0430\u0449\u0438\u0445 \u0432\u044b\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0447\u0442\u043e \u0431\u044b\u043b\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0431\u044b\u043b\u0438 \u043d\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u044b, \u0430 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/119\/c73\/442\/119c734422881c4314325b121bdb7e00.png\" alt=\"\" title=\"\" width=\"1280\" height=\"724\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/119\/c73\/442\/119c734422881c4314325b121bdb7e00.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u0436\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0443?<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0432 Spark \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c 2 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0440\u0435\u043c\u044f \u0441\u0443\u0442\u043e\u043a, \u0442\u0430\u0439\u043c\u0441\u0442\u0435\u043c\u043f, \u0438 \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043a\u043b\u0438\u043a\u0430\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u0438\u043b\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 &#171;\u043e\u043a\u043d\u0430&#187;), \u0430 \u0442\u0440\u0435\u0442\u044c\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c\u0441\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0445 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u043f\u043e \u043e\u0431\u043e\u0438\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c. \u0412 API Spark \u0437\u0430 \u0442\u0430\u043a\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u043c\u0435\u0442\u043e\u0434\u044b.. <code>groupBy()<\/code> \u0438 <code>window()<\/code>. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 Scala \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code>import org.apache.spark.sql.expressions.Window import org.apache.spark.sql.types.TimestampType def getDFFromJdbcSource(spark: SparkSession, query: String): DataFrame = { val timescaledbLogin = \"postgres\" val timescaledbPassword = \"password\" val timescaledbJdbc = s\"jdbc:postgresql:\/\/timescaledb:5432\/db\" \/\/\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414 spark   .read   .format(\"jdbc\")   .option(\"url\", timescaledbJdbc)   .option(\"driver\", \"org.postgresql.Driver\")   .option(\"user\", timescaledbLogin)   .option(\"password\", timescaledbPassword)   .option(\"query\", query)   .option(\"fetchsize\", \"2000000\")   .load()  } import spark.sqlContext.implicits._ import org.apache.spark.sql.functions._ import org.apache.spark.sql.types._ val ourDataframe = getDFFromJdbcSource(SparkSession.builder().appName(\"test\").master(\"local\").getOrCreate(), s\"\"\"SELECT *  FROM sensor_data WHERE (timestamp > '2022-02-09 00:00:00.000' and timestamp &lt; '2022-02-11 00:00:00.000')\"\"\") \/\/\u0442\u0443\u0442 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u043b\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 .withColumn(\"DelayColumn\", (col(\"acceptTimestamp\")).cast(LongType).divide(1000) - to_timestamp(date_format(col(\"timestamp\"), \"HH:mm:ss.SSS\")).cast(LongType).divide(1000)) \/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0441\u0442\u0435\u043c\u043f\u0430 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \/\/ \u043f\u043b\u044e\u0441 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438 \u0434\u043b\u044f \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \"\u043e\u043a\u043d\u0430\" \u043f\u043e \u043e\u0441\u0438 y \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c \/\/ \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043e\u043a\u0440\u0443\u0433\u043b\u044f\u0442\u044c, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0432\u0435\u0437\u043b\u043e .groupBy( window(\"window_time\".desc) \/\/\u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0435\u0449\u0435 \u0438 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 ourDataframe. show(100, false) println(dailySummariesDf.count()) ourDataframe.registerTempTable(\"heatmap\") <\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code>+-------------------+--------------------+-----+ |window_time        |DelayColumn         |count| +-------------------+--------------------+-----+ |2022-02-10 18:50:00|1.6428744912879999E9|1    | |2022-02-10 18:50:00|1.642874507993E9    |2    |<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 count-\u0442\u043e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u0446\u0432\u0435\u0442. \u0418\u0442\u0430\u043a, \u0432\u043d\u0438\u0437\u0443 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043d\u0430\u0434 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u0432 <code>%pyspark<\/code> \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<pre><code>%pyspark from pyspark.sql.functions import * def plot_summaries(sensor, dfName): dft = sqlContext.table(dfName) pdf = dft.toPandas() import pandas as pd import numpy as np from bokeh.transform import log_cmap     #\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0432 \u0446\u0432\u0435\u0442 \u043f\u043e \u043b\u043e\u0433\u0430\u0440\u0438\u0444\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0448\u043a\u0430\u043b\u0435  A = pdf.pivot_table('count', sensor, 'window_time', fill_value=0) #\u0432\u043e\u0442 \u0432\u0430\u0436\u043d\u0435\u0439\u0448\u0435\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435!  #\u0431\u0435\u0437 \u044f\u0432\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0431\u0440\u043e\u0441\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 count \u043f\u043e \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c window_time \u0438 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c\u043e\u043c\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f #\u0447\u0435\u0440\u0435\u0437 \u0444\u0443\u043d\u043a\u0446\u0438\u044e pivot_table() \u043d\u0443\u0436\u043d\u044b\u0439 \u0442\u0440\u0435\u0445\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432 \u043d\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f  source = ColumnDataSource(data={'x':[pdf['window_time'].min()] #\u0441\u0430\u043c\u043e\u0435 \u043b\u0435\u0432\u043e                            ,'y':[0] #\u0441\u0430\u043c\u044b\u0439 \u043d\u0438\u0437                            ,'dw':[pdf['window_time'].max()-pdf['window_time'].min()]                             #\u0448\u0438\u0440\u0438\u043d\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f                            ,'dh':[pdf[sensor].max()] #\u0432\u044b\u0441\u043e\u0442\u0430 \u0438\u0437\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f,                             #\u0441\u0447\u0438\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0449\u0435, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 0                            ,'im':[A.to_numpy()]                             #\u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c 2D \u043c\u0430\u0441\u0441\u0438\u0432 numpy \u0447\u0435\u0440\u0435\u0437 to_numpy()                            })  color_mapper = LogColorMapper(palette=\"Viridis256\", low=0, high=pdf['count'].max()) #\u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0443\u0442 \u0437\u0430\u0434\u0430\u0435\u0442\u0441\u044f \u0446\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u0448\u043a\u0430\u043b\u0430 \u0430-\u043b\u044f \"\u0441\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u0438\u044f\u043d\u0438\u0435\"  plot = figure(toolbar_location=None,x_axis_type='datetime') #\u0437\u0430\u0434\u0430\u0434\u0438\u043c \u0442\u0438\u043f \u043e\u0441\u0438 \u0445 \u043a\u0430\u043a \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 plot.image(x='x', y='y', source=source, image='im',dw='dw',dh='dh',  color_mapper=color_mapper) #\u0441\u0430\u043c\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u0435  color_bar = ColorBar(color_mapper=color_mapper, label_standoff=12) #\u043b\u0435\u0433\u0435\u043d\u0434\u0430 \u0434\u043b\u044f \u0446\u0432\u0435\u0442\u043e\u0432\u043e\u0439 \u0448\u043a\u0430\u043b\u044b \u0438 \u0435\u0435 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d\u0438\u0435 plot.add_layout(color_bar, 'right')  show(gridplot([plot], ncols=1, plot_width=1600, plot_height=900)) #\u0441\u0442\u0440\u043e\u0438\u043c \u0432\u0441\u0435 \u0432\u043c\u0435\u0441\u0442\u0435, \u0437\u0430\u0434\u0430\u0432 \u0440\u0430\u0437\u043c\u0435\u0440\u044b  sensors = [ \"DelayColumn\"] for sensor in sensors: plot_summaries_heatmap(sensor, \"heatmap\") #\u0432\u044b\u0437\u043e\u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/1ed\/166\/6f3\/1ed1666f301fcdbe2d7895ab9ccb7d50.png\" alt=\"\u0412 \u0434\u043e\u0431\u0440\u044b\u0439 \u043f\u0443\u0442\u044c!\" title=\"\u0412 \u0434\u043e\u0431\u0440\u044b\u0439 \u043f\u0443\u0442\u044c!\" width=\"1581\" height=\"971\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/1ed\/166\/6f3\/1ed1666f301fcdbe2d7895ab9ccb7d50.png\"\/><figcaption>\u0412 \u0434\u043e\u0431\u0440\u044b\u0439 \u043f\u0443\u0442\u044c!<\/figcaption><\/figure>\n<p>\u041d\u0443 \u0430 \u0434\u0430\u043b\u044c\u0448\u0435, \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043c\u0430\u0441\u0442\u0435\u0440\u0441\u0442\u0432\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438. \u0422\u0430\u043a\u043e\u0439 \u0432\u043e\u0442 &#171;\u043b\u0438\u043d\u0435\u0439\u0447\u0430\u0442\u044b\u0439 \u0441\u043f\u0435\u043a\u0442\u0440&#187;, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0445\u0430\u0440\u0430\u0442\u0435\u0440\u0435\u043d \u0434\u043b\u044f \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0441\u043d\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0442\u043e\u043a\u043e\u0432 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043a\u0430\u0437\u044b\u0432\u044e\u0442\u0441\u044f \u0432 \u0440\u0430\u0432\u043d\u043e\u0432\u0435\u0441\u043d\u043e\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u043c\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0438\u0442\u0435\u043b\u044f \u0434\u0430\u043d\u043d\u044b\u0445, \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442 \u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, &#171;\u0434\u0440\u0435\u0439\u0444\u043e\u0432\u0430\u0442\u044c&#187; \u043a\u043e\u0433\u0434\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0434\u0435\u0433\u0440\u0430\u0434\u0438\u0440\u0443\u0435\u0442. \u041a \u0443\u043c\u0435\u043d\u0438\u044e \u043f\u043e\u043d\u044f\u0442\u044c \u0438 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0440\u0430\u0437\u0432\u0438\u0442\u044c \u0438 \u0443\u043c\u0435\u043d\u0438\u0435 \u043e\u0431\u044a\u044f\u0441\u043d\u0438\u0442\u044c \u0443\u0432\u0438\u0434\u0435\u043d\u043d\u043e\u0435 \u043d\u0435\u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0438 \u043d\u0435\u043c\u0430\u0442\u0435\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044f\u043c, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e, \u043f\u043e\u0447\u0435\u043c\u0443, \u0433\u043b\u044f\u0434\u044f \u043d\u0430 \u044d\u0442\u0438 \u043a\u0430\u0440\u0442\u0438\u043d\u043a\u0438, \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0443. \u041f\u043e \u043c\u043e\u0435\u043c\u0443 \u043e\u043f\u044b\u0442\u0443, \u044d\u0442\u043e \u0431\u044b\u043b\u043e \u0434\u0430\u0436\u0435 \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0438 \u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \ud83d\ude42<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/668468\/\"> https:\/\/habr.com\/ru\/articles\/668468\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442! <\/p>\n<p>\u0412 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u044f \u0431\u044b \u0445\u043e\u0442\u0435\u043b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u0441 \u0442\u0435\u043c\u0438, \u043a\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 Apache Zeppelin \u0432 \u0441\u043e\u0447\u0435\u0442\u0430\u043d\u0438\u0438 \u0441\u043e Spark \u043d\u0430 Scala, \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044f\u043c\u0438 \u043f\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<figure class=\"full-width\"><figcaption>\u0412\u043e\u0442 \u0442\u0430\u043a\u043e\u0435 &#171;\u0441\u0435\u0432\u0435\u0440\u043d\u043e\u0435 \u0441\u0438\u044f\u043d\u0438\u0435&#187;? \u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e, \u043a\u0430\u043a \u044d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u043a\u0430\u043a \u0442\u0430\u043a\u043e\u0435 \u043d\u0430\u0440\u0438\u0441\u043e\u0432\u0430\u0442\u044c? \u0422\u043e\u0433\u0434\u0430 \u043f\u043e\u0435\u0445\u0430\u043b\u0438!<\/figcaption><\/figure>\n<p>\u041d\u0430 \u043d\u044b\u043d\u0435\u0448\u043d\u0435\u0439 \u0440\u0430\u0431\u043e\u0442\u0435 \u044f \u0437\u0430\u043d\u0438\u043c\u0430\u044e\u0441\u044c \u0432\u043e\u043f\u0440\u043e\u0441\u0430\u043c\u0438 \u0437\u0430\u043c\u0435\u0440\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u043d\u0432\u0435\u0435\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0430 \u044d\u0442\u0430 \u0440\u0430\u0431\u043e\u0442\u0430 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432 \u0441\u0435\u0431\u044f, \u043a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e, \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435 \u0448\u0430\u0433\u0438: <\/p>\n<ol>\n<li>\n<p>\u043d\u0430\u0439\u0442\u0438 \u043a\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043f\u043e\u043c\u0435\u0440\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u043e\u0434\u043d\u043e\u043c \u043a\u043e\u043d\u0446\u0435 \u043a\u043e\u043d\u0432\u0435\u0435\u0440\u0430 \u0434\u043e \u0434\u0440\u0443\u0433\u043e\u0433\u043e \u043a\u043e\u043d\u0446\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c; <\/p>\n<\/li>\n<li>\n<p>\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u043a\u043e\u0433\u0434\u0430 \u043f\u043e\u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0438 \u0441 \u0447\u0435\u043c \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0441\u0432\u044f\u0437\u0430\u043d\u044b. <\/p>\n<\/li>\n<\/ol>\n<p>\u041a\u0440\u043e\u043c\u0435 \u0442\u043e\u0433\u043e, \u0438\u043d\u043e\u0433\u0434\u0430 \u0431\u044b\u0432\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u043f\u043e\u043b\u043d\u043e\u0442\u043e\u0439 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0435\u0442 \u043b\u0438 \u0432 \u043d\u0438\u0445 \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432, \u043d\u0435 \u0441\u043d\u0438\u0436\u0430\u0435\u0442\u0441\u044f \u043b\u0438 \u043d\u0430 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0443\u0447\u0430\u0441\u0442\u043a\u0430\u0445 \u043f\u043b\u043e\u0442\u043d\u043e\u0441\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0435\u0434\u0438\u043d\u0438\u0446\u0443 \u0432\u0440\u0435\u043c\u0435\u043d\u0438.<\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0435 \u0443 \u043d\u0430\u0441 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432 \u0431\u0430\u0437\u0435 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0445 \u0440\u044f\u0434\u043e\u0432 Timescale, \u0430 \u0435\u0449\u0435 \u0438\u0445 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 Apache Spark (\u0432 \u043d\u0430\u0448\u0435\u0439 \u043e\u0440\u0433\u0430\u043d\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0436\u043e\u0431\u044b \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b \u043d\u0430 Scala), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0438 \u0432 Hadoop. \u041f\u043e\u0432\u0435\u0440\u0445 \u0432\u0441\u0435\u0439 \u044d\u0442\u043e\u0439 \u0438\u043d\u0444\u0440\u0430\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0430\u043d\u0430\u043b\u0438\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u044c \u0432 Apache Zeppelin, \u0432\u0435\u0434\u044c \u0432 \u043d\u0435\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u0442\u0435 \u0436\u0435 \u043d\u0430\u0432\u044b\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0438 \u0434\u043b\u044f \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0434\u0436\u043e\u0431 \u043f\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0434\u0430\u043d\u043d\u044b\u0445. <\/p>\n<p>\u041e\u0434\u043d\u0430\u043a\u043e, \u0435\u0441\u043b\u0438 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440\u043a\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043f\u043e\u0434\u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0435 \u0438 \u043e\u043a\u043e\u043d\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0434\u043b\u044f Scala-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 \u043d\u0435 \u0441\u0442\u0440\u0430\u0448\u0438\u0442, \u0442\u043e \u0432\u043e\u0442 \u0441 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0435\u0439, \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Python \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Bokeh \u043d\u0438\u0447\u0435\u0433\u043e \u0432 Zeppelin \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0432 \u044d\u0442\u043e\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435, \u0430 \u0437\u0430\u043e\u0434\u043d\u043e \u043e\u0441\u0432\u043e\u0438\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0441\u0435\u0431\u044f \u0432\u0438\u0434 \u0432\u0443\u0437\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u044c\u0442\u0435, \u0447\u0442\u043e \u043c\u044b \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u0433\u043e \u0434\u043b\u044f Scala-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u043e\u0432 spark-\u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430 Zeppelin \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043d\u0435\u043a\u0438\u0439 \u0434\u0430\u0442\u0430\u0441\u0435\u0442 &#8212; \u0432\u044b\u0442\u0430\u0449\u0438\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0431\u0430\u0437\u044b \u0438\u043b\u0438 \u0438\u0437 \u0444\u0430\u0439\u043b\u043e\u0432 Parquet \u0432 Hadoop, \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0435\u0433\u043e \u043a\u0430\u043a \u0445\u043e\u0442\u0438\u043c, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437\u0431\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u043e\u0442 \u043d\u0435\u043d\u0443\u0436\u043d\u044b\u0445 \u043a\u043e\u043b\u043e\u043d\u043e\u043a, \u0438\u043b\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0441\u0432\u043e\u0438 \u043d\u043e\u0432\u044b\u0435 \u0438 \u043f\u0435\u0440\u0435\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u043d\u0438\u0445. \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430v \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0442\u043e\u0440\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438, \u043e\u0442 \u043f\u0435\u0440\u0432\u043e\u0439 \u043a\u043e\u043b\u043e\u043d\u043a\u0438. \u0427\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c?<\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0443\u0436\u043d\u043e \u0434\u0430\u0442\u0430\u0441\u0435\u0442 \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0443\u044e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0437\u0430\u0432\u0435\u0440\u0448\u0438\u043c \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code>ourDataframe.show(100,\u00a0false)  \/\/\u0432 \u0432\u0435\u0431-\u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0446\u0435\u043f\u0435\u043b\u043b\u0438\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0432\u0435\u0434\u0435\u043d\u043e \u043f\u0435\u0440\u0432\u044b\u0435 100 \u0441\u0442\u0440\u043e\u0447\u0435\u043a println(ourDataframe.count())  \/\/\u0430 \u0435\u0449\u0435 \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0435 ourDataframe.registerTempTable(\"tableexample\") \/\/\u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u043e\u043c \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0435<\/code><\/pre>\n<p>\u0418\u0442\u0430\u043a, \u043a\u0430\u043a\u043e\u0439 \u043f\u0440\u043e\u0441\u0442\u0435\u0439\u0448\u0438\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438? \u042d\u0442\u043e \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440 <code>%sql<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0435 &#171;\u0446\u0435\u043f\u0435\u043b\u043b\u0438\u043d\u0430&#187; \u0442\u0430\u0431\u043b\u0438\u0446\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440:<\/p>\n<p><code>%sql select  hour,  max from tableexample<\/code><\/p>\n<p>\u041f\u0440\u0438 \u043e\u0442\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041c\u0438\u043d\u0443\u0441 \u0435\u0435 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u0447\u0435\u043a \u043d\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0435\u0435 \u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0432\u044b\u0431\u043e\u0440\u043a\u0430\u0445. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0432\u0443\u043c\u0435\u0440\u043d\u044b\u0439 \u0433\u0440\u0430\u0444\u0438\u043a \u043f\u0440\u0438 \u043f\u043e\u043c\u043e\u0449\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Bokeh.<\/p>\n<p>\u041f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e, \u043e\u043d\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0443 (\u0438\u043b\u0438 \u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440) \u0441 Zeppelin. <\/p>\n<p><code>RUN pip install -q numpy==1.17.3 <\/code><\/p>\n<p><code>RUN pip install -q pandas==0.25.0 <\/code><\/p>\n<p><code>RUN pip3 install -q bokeh==2.4.2<\/code>  <\/p>\n<p><code>RUN pip3 install -q bkzep<\/code>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u0430\u043a \u0443 \u043d\u0430\u0441 \u043f\u0440\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043e\u0431\u0440\u0430\u0437\u0430 \u0441\u0442\u0430\u0432\u0438\u0442\u0441\u044f \u0432\u0441\u0451 \u043f\u0438\u0442\u043e\u043d\u043e\u0432\u0441\u043a\u043e\u0435 (\u043f\u043e\u043c\u0438\u043c\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u043e\u0433\u043e, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0433\u043e \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0441\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 pyspark \u0438 \u0442.\u043f.), \u0447\u0442\u043e \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u043d\u0430\u043c \u0438\u043c\u0435\u043d\u043d\u043e \u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438. <\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0445 &#171;\u0433\u043b\u0430\u0432\u0430\u0445&#187; Zeppelin \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0440\u0430\u0437\u043d\u044b\u043c\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u043c\u0438 \u0438 \u0433\u0440\u0430\u0444\u0438\u043a\u0430\u043c\u0438. \u0421\u043e\u0437\u0434\u0430\u0435\u043c &#171;\u0433\u043b\u0430\u0432\u0443&#187; \u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u043e\u043c <code>%spark.pyspark<\/code><\/p>\n<pre><code>%spark.pyspark import bkzep import numpy as np from bokeh.io import output_notebook, show from bokeh.plotting import figure from bokeh.models import ColumnDataSource from bokeh.layouts import gridplot from pyspark.sql.functions import col, coalesce, lit, monotonically_increasing_id from pyspark.sql import DataFrame from pyspark.sql.functions import * output_notebook(notebook_type='zeppelin')<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442\u044c \u0435\u0435, \u0442\u043e \u043f\u043e\u044f\u0432\u0438\u0442\u0441\u044f \u0437\u043d\u0430\u0447\u043e\u043a \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 BokehJS, \u0437\u043d\u0430\u0447\u0438\u0442 \u0432\u0441\u0435 \u0438\u0434\u0435\u0442 \u043a\u0430\u043a \u043d\u0430\u0434\u043e:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0442\u044c \u043a \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e &#171;\u0433\u043b\u0430\u0432&#187;, \u0432 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043a\u043e\u0434 \u043d\u0430 \u043f\u0438\u0442\u043e\u043d\u0435 \u0437\u0430\u0439\u043c\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0440\u0438\u0441\u043e\u0432\u043a\u043e\u0439 \u043d\u0443\u0436\u043d\u043e\u0439 \u043d\u0430\u043c \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0438\u0437 \u0441\u043e\u0445\u0440\u0430\u043d\u0435\u043d\u043d\u044b\u0445 \u0432 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 &#171;\u0446\u0435\u043f\u0435\u043b\u043b\u0438\u043d\u0430&#187; \u0442\u0430\u0431\u043b\u0438\u0446, \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043d\u0438\u0436\u0435 &#8212; \u0442\u0430\u0431\u043b\u0438\u0446\u0430 &#171;pivoted&#187;.<\/p>\n<pre><code>%pyspark from\u00a0pyspark.sql.functions\u00a0import\u00a0* def\u00a0plot_summaries(sensor,\u00a0dfName): \u00a0\u00a0\u00a0\u00a0df\u00a0=\u00a0sqlContext.table(dfName) #\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u043b\u0438 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 PySpark \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 Zeppeling \u00a0\u00a0\u00a0\u00a0pdf\u00a0=\u00a0df.toPandas() #\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 dataFrame Pandas \u00a0\u00a0\u00a0\u00a0source\u00a0=\u00a0ColumnDataSource(pdf) #\u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043b\u0438 \u0432 \u043e\u0431\u044a\u0435\u043a\u0442-\u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u0434\u043b\u044f \u043a\u043e\u043b\u043e\u043d\u043e\u043a \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u00a0\u00a0\u00a0\u00a0fig\u00a0=\u00a0figure(title=\"Mean\u00a0and\u00a0Standard\u00a0deviation\u00a0of\u00a0'{}'\".format(sensor)) #\u0437\u0430\u0434\u0430\u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442 \u0433\u0440\u0430\u0444\u0438\u043a\u0430, \u0442\u0443\u0442 \u0436\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u00a0\u00a0\u00a0\u00a0fig.line(x='index',\u00a0y=sensor+'_mean',\u00a0source=source,\u00a0color=\"orange\") \u00a0\u00a0\u00a0\u00a0fig.line(x='index',\u00a0y=sensor+'_stddev',\u00a0source=source,\u00a0color=\"blue\") \u00a0\u00a0\u00a0\u00a0show(gridplot([fig],\u00a0ncols=1,\u00a0plot_width=1000,\u00a0plot_height=400)) #\u0434\u043e\u0431\u0430\u0432\u0438\u043b\u0438 \u043b\u0438\u043d\u0438\u0439 \u0438 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043b\u0438 \u043d\u0430 \u043e\u0442\u0440\u0438\u0441\u043e\u0432\u043a\u0443 sensors\u00a0=\u00a0[ \u00a0\u00a0\u00a0\u00a0\"Water_Level_Sensor\", \u00a0\u00a0\u00a0\u00a0\"Water_Temperature_Sensor\", \u00a0\u00a0] for\u00a0sensor\u00a0in\u00a0sensors: \u00a0\u00a0\u00a0\u00a0plot_summaries(sensor,\u00a0\"pivoted\")<\/code><\/pre>\n<p>\u0418 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u0430\u043a\u0438\u0435 \u0432\u043e\u0442 \u043f\u0440\u043e\u0441\u0442\u0435\u043d\u044c\u043a\u0438\u0435 \u0433\u0440\u0430\u0444\u0438\u043a\u0438 \u0441\u043e \u0441\u0440\u0435\u0434\u043d\u0438\u043c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435\u043c \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0440\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u044b\u043c \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u0435\u043c, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u044b \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u0435\u0449\u0435 \u0434\u043e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0432 &#171;\u0441\u043f\u0430\u0440\u043a\u0435&#187; \u0438 \u0443\u043b\u043e\u0436\u0438\u043b\u0438 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0443 &#171;pivoted&#187;, \u043a\u0430\u043a \u0438 \u043a\u043e\u043b\u043e\u043d\u043a\u0443 index:<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041a\u043e\u0433\u0434\u0430 \u0440\u0435\u0447\u044c \u0438\u0434\u0435\u0442 \u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u0445 \u0442\u0435\u043b\u0435\u043c\u0435\u0442\u0440\u0438\u0438, \u0442\u043e, \u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b, \u043c\u043e\u0436\u043d\u043e \u0438 \u043f\u0440\u0430\u0432\u0434\u0430 \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0447\u0435\u0442\u044b\u0440\u044c\u043c\u044f \u043b\u0438\u043d\u0438\u044f\u043c\u0438 &#8212; \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0432 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e, \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e, \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043d\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c \u043e\u043a\u043d\u0435. \u041d\u043e \u043a\u0443\u0434\u0430 \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0433\u0440\u0430\u0444\u0438\u043a, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u044d\u0442\u043e \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043c\u043e\u0436\u043d\u043e \u044f\u0432\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441\u0430\u043c\u0438\u043c. \u0421\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u043a\u043d\u0430 \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u043e\u0441\u0438 x (\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435), \u043d\u043e \u0438 \u043f\u043e \u043e\u0441\u0438 y (\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f), \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043e\u0442 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043f\u0430\u043b\u043e \u0432 &#171;\u043e\u043a\u043d\u0430&#187; \u043f\u043e \u0432\u0435\u0440\u0442\u0438\u043a\u0430\u043b\u0438, \u0430 \u043f\u043e\u0442\u043e\u043c \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u043f\u043b\u043e\u0441\u043a\u043e\u0441\u0442\u0438 3\u0445-\u043c\u0435\u0440\u043d\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432, \u0433\u0434\u0435 \u0442\u043e\u0447\u043a\u0430 \u0441 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u0430\u043c\u0438 x \u0438 y \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u0435\u0442\u044c \u0446\u0432\u0435\u0442 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u043f\u043e\u043f\u0430\u0432\u0448\u0435\u0433\u043e \u0432 &#171;\u0432\u0435\u0434\u0440\u043e&#187; (\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u044b\u043c &#171;\u043e\u043a\u043d\u043e\u043c&#187; \u043f\u043e x \u0438 y). \u0422\u0430\u043a \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0442\u0435\u043f\u043b\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u0432\u0438\u0434\u0435\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0442\u0430\u043a \u0438 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437\u043c\u0435\u043d\u044f\u044e\u0449\u0435\u0433\u043e\u0441\u044f \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043b\u0435\u0433\u043b\u043e \u0432\u0434\u043e\u043b\u044c &#171;\u0446\u0435\u043d\u0442\u0440\u0430 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0439&#187;, \u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0443\u0448\u043b\u043e \u0432 &#171;\u0432\u044b\u0431\u0440\u043e\u0441\u044b&#187;, \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u0447\u0435\u0442\u043a\u043e \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0435\u0441\u043b\u0438 &#171;\u0432\u044b\u0431\u0440\u043e\u0441\u044b&#187; \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u043d\u0435 \u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e, \u0430 \u043f\u043e \u043a\u0430\u043a\u043e\u043c\u0443-\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0437\u0430\u043a\u043e\u043d\u0443, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u0441 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u044b\u043c \u043f\u043e\u0432\u0442\u043e\u0440\u0435\u043d\u0438\u0435\u043c \u0432\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u042d\u0442\u043e \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0440\u0438\u0447\u0438\u043d\u0443 \u0442\u0430\u043a\u0438\u0445 \u0441\u043e\u0431\u044b\u0442\u0438\u0439.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u044d\u0442\u043e\u0439 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u0432 \u043a\u043e\u043d\u0432\u0435\u0435\u0440\u0435 \u043f\u043e \u043a\u0430\u043a\u0438\u043c-\u0442\u043e \u043f\u0440\u0438\u0447\u0438\u043d\u0430\u043c \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u043b\u043e \u0432 \u0446\u0435\u043b\u044b\u0439 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043a\u043e\u043d\u0446\u0435\u043d\u0442\u0440\u0438\u0440\u0443\u044f\u0441\u044c \u0438\u043b\u0438 \u043e\u043a\u043e\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u043c\u0430\u043b\u044b\u0445 \u0438\u043b\u0438 \u043e\u043a\u043e\u043b\u043e \u0431\u043e\u043b\u0435\u0435 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u044d\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u0442\u0435\u043c\u043d\u043e\u0439 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043e\u0442 150 \u0434\u043e 400 \u043f\u043e \u043e\u0441\u0438 y). \u0413\u0440\u0430\u0444\u0438\u043a\u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c\u0430, \u043c\u0438\u043d\u0438\u043c\u0443\u043c\u0430, \u0441\u0440\u0435\u0434\u043d\u0435\u0433\u043e \u0438 \u0441\u0440\u0435\u0434\u043d\u0435\u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0438\u0447\u043d\u043e\u0433\u043e \u043e\u0442\u043a\u043b\u043e\u043d\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u043c\u043e\u0433\u043b\u0438 \u0431\u044b \u0434\u043e\u043d\u0435\u0441\u0442\u0438 \u0434\u043e \u043d\u0430\u0441 \u044d\u0442\u0443 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e. \u041f\u043b\u044e\u0441 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439, \u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0437\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f, \u0440\u0435\u0437\u043a\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u0440\u0435\u043c\u0435\u043d \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0410 \u043d\u0430 \u044d\u0442\u043e\u0439 \u0442\u0435\u043f\u043b\u043e\u0432\u043e\u0439 \u043a\u0430\u0440\u0442\u0435 \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043c\u0430\u0441\u0441\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u0435\u0434\u0435\u043b\u0430\u0445 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0432\u0435\u0440\u0445\u043d\u0435\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u043d\u043e:<\/p>\n<ol>\n<li>\n<p>\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0432\u043d\u0443\u0442\u0440\u0438 \u043b\u0438\u043c\u0438\u0442\u0430 \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0431\u043e\u043b\u0435\u0435 \u043d\u0435\u0440\u0430\u0432\u043d\u043e\u043c\u0435\u0440\u043d\u043e\u0435, \u0441\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0435\u0440\u0435\u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0438 \u043e\u0431\u0449\u0435\u0435 \u0447\u0438\u0441\u043b\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0430\u043d\u043d\u044b\u0445 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0439 \u044f\u0432\u043d\u043e \u043f\u0430\u0434\u0430\u0435\u0442, \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u0435\u0433\u0440\u0430\u0434\u0438\u0440\u0443\u0435\u0442, \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u0435\u0435 \u0440\u0435\u0441\u0442\u0430\u0440\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0435\u0441\u0442\u044c \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u044b-\u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430, \u0447\u0442\u043e \u0432\u0438\u0434\u043d\u043e \u043a\u0430\u043a &#171;\u0437\u0430\u0431\u043e\u0440 \u0438\u0437 \u0436\u0435\u0440\u0434\u0435\u0439&#187;, \u0442\u043e\u0440\u0447\u0430\u0449\u0438\u0445 \u0432\u044b\u0448\u0435 \u044d\u0442\u043e\u0433\u043e \u043b\u0438\u043c\u0438\u0442\u0430;<\/p>\n<\/li>\n<li>\n<p>\u0438 \u0447\u0442\u043e \u0431\u044b\u043b\u0430 \u043a\u0430\u043a\u0430\u044f-\u0442\u043e \u0430\u043d\u043e\u043c\u0430\u043b\u0438\u044f, \u043a\u043e\u0433\u0434\u0430 \u044d\u0442\u043e \u0431\u044b\u043b\u0438 \u043d\u0435 \u0440\u0435\u0433\u0443\u043b\u044f\u0440\u043d\u044b\u0435 \u0435\u0434\u0438\u043d\u0438\u0447\u043d\u044b\u0435 \u0432\u044b\u0431\u0440\u043e\u0441\u044b, \u0430 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432\u0434\u0440\u0443\u0433 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0443 \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435.<\/p>\n<\/li>\n<\/ol>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u0418\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e, \u043a\u0430\u043a \u0436\u0435 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043a\u0430\u0440\u0442\u0443?<\/p>\n<p>\u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430 \u0432 Spark \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c 2 \u043a\u043e\u043b\u043e\u043d\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432\u0440\u0435\u043c\u044f \u0441\u0443\u0442\u043e\u043a, \u0442\u0430\u0439\u043c\u0441\u0442\u0435\u043c\u043f, \u0438 \u0432\u0440\u0435\u043c\u044f \u043e\u0442\u043a\u043b\u0438\u043a\u0430\/\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 \u043c\u0438\u043b\u043b\u0438\u0441\u0435\u043a\u0443\u043d\u0434\u0430\u0445), \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f (\u0438\u043b\u0438 \u043a\u043e\u0440\u0442\u0435\u0436\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0438 \u043a\u043e\u043d\u0446\u0430 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 &#171;\u043e\u043a\u043d\u0430&#187;), \u0430 \u0442\u0440\u0435\u0442\u044c\u044f, \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u0435\u043b\u0430\u0442\u044c\u0441\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f, \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0430 \u043a\u0430\u043a \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u043e\u0431\u044b\u0442\u0438\u0439, \u043f\u043e\u043f\u0430\u0432\u0448\u0438\u0445 \u0432 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u043e\u043a\u043d\u043e \u043f\u043e \u043e\u0431\u043e\u0438\u043c \u043a\u043e\u043b\u043e\u043d\u043a\u0430\u043c. \u0412 API Spark \u0437\u0430 \u0442\u0430\u043a\u0443\u044e \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u043e\u0442\u0432\u0435\u0447\u0430\u044e\u0442 \u043c\u0435\u0442\u043e\u0434\u044b.. <code>groupBy()<\/code> \u0438 <code>window()<\/code>. \u041f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 Scala \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0440\u0430:<\/p>\n<pre><code>import org.apache.spark.sql.expressions.Window import org.apache.spark.sql.types.TimestampType def getDFFromJdbcSource(spark: SparkSession, query: String): DataFrame = { val timescaledbLogin = \"postgres\" val timescaledbPassword = \"password\" val timescaledbJdbc = s\"jdbc:postgresql:\/\/timescaledb:5432\/db\" \/\/\u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043a \u0411\u0414 spark   .read   .format(\"jdbc\")   .option(\"url\", timescaledbJdbc)   .option(\"driver\", \"org.postgresql.Driver\")   .option(\"user\", timescaledbLogin)   .option(\"password\", timescaledbPassword)   .option(\"query\", query)   .option(\"fetchsize\", \"2000000\")   .load()  } import spark.sqlContext.implicits._ import org.apache.spark.sql.functions._ import org.apache.spark.sql.types._ val ourDataframe = getDFFromJdbcSource(SparkSession.builder().appName(\"test\").master(\"local\").getOrCreate(), s\"\"\"SELECT *  FROM sensor_data WHERE (timestamp > '2022-02-09 00:00:00.000' and timestamp &lt; '2022-02-11 00:00:00.000')\"\"\") \/\/\u0442\u0443\u0442 \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0437\u0430\u0434\u0430\u043b\u0438 \u0434\u0438\u0430\u043f\u0430\u0437\u043e\u043d \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 .withColumn(\"DelayColumn\", (col(\"acceptTimestamp\")).cast(LongType).divide(1000) - to_timestamp(date_format(col(\"timestamp\"), \"HH:mm:ss.SSS\")).cast(LongType).divide(1000)) \/\/ \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u0437\u0430\u0434\u0435\u0440\u0436\u043a\u0438 \u0432\u044b\u0447\u0438\u0442\u0430\u043d\u0438\u0435\u043c \u043e\u0434\u043d\u043e\u0433\u043e \u0442\u0430\u0439\u043c\u0441\u0442\u0435\u043c\u043f\u0430 \u0438\u0437 \u0434\u0440\u0443\u0433\u043e\u0433\u043e \/\/ \u043f\u043b\u044e\u0441 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u043a \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438 \u0434\u043b\u044f \u043f\u043e\u043f\u0430\u0434\u0430\u043d\u0438\u044f \u0432 \"\u043e\u043a\u043d\u0430\" \u043f\u043e \u043e\u0441\u0438 y \u0435\u0434\u0438\u043d\u0438\u0446\u0430\u043c \/\/ \u0438\u043d\u043e\u0433\u0434\u0430 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043d\u0430\u0434\u043e \u043e\u043a\u0440\u0443\u0433\u043b\u044f\u0442\u044c, \u043d\u043e \u0437\u0434\u0435\u0441\u044c \u043f\u043e\u0432\u0435\u0437\u043b\u043e .groupBy( window(\"window_time\".desc) \/\/\u0434\u043b\u044f \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u0435\u0449\u0435 \u0438 \u043e\u0442\u0441\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u043b\u0438 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 ourDataframe. show(100, false) println(dailySummariesDf.count()) ourDataframe.registerTempTable(\"heatmap\") <\/code><\/pre>\n<p>\u0412\u044b\u0432\u043e\u0434 \u0442\u0435\u043a\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0442\u0430\u043a\u043e\u0439:<\/p>\n<pre><code>+-------------------+--------------------+-----+ |window_time        |DelayColumn         |count| +-------------------+--------------------+-----+ |2022-02-10 18:50:00|1.6428744912879999E9|1    | |2022-02-10 18:50:00|1.642874507993E9    |2    |<\/code><\/pre>\n<p>\u0412\u043e\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0435 count-\u0442\u043e \u043c\u044b \u0438 \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u0446\u0432\u0435\u0442. \u0418\u0442\u0430\u043a, \u0432\u043d\u0438\u0437\u0443 \u043c\u0430\u043d\u0438\u043f\u0443\u043b\u044f\u0446\u0438\u0438 \u043d\u0430\u0434 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u0432 <code>%pyspark<\/code> \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0442\u043e\u0440\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<pre><code>%pyspark from pyspark.sql.functions import * def plot_summaries(sensor, dfName): dft =<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-417805","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/417805","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=417805"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/417805\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=417805"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=417805"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=417805"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}