{"id":372088,"date":"2024-05-21T05:04:07","date_gmt":"2024-05-21T05:04:07","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=372088"},"modified":"-0001-11-30T00:00:00","modified_gmt":"2024-05-21T05:04:07","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=372088","title":{"rendered":"<span>\u041a\u0430\u043a\u00a0\u0431\u044b\u0441\u0442\u0440\u043e \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043a\u0443\u0431\u0438\u043a \u0434\u043b\u044f\u00a0\u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0437\u0430\u0434\u0430\u0447: \u0438\u0433\u0440\u0430\u0435\u043c\u0441\u044f \u0441\u00a0TinyOLAP<\/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<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/50b\/158\/472\/50b1584724a70e0f3f2869cd2fa268d8.jpg\" width=\"740\" height=\"417\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/50b\/158\/472\/50b1584724a70e0f3f2869cd2fa268d8.jpg\" data-blurred=\"true\"\/><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u0421\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u044f\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 OLAP\u2011\u043a\u0443\u0431 \u0434\u043b\u044f\u00a0\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u00a0\u043e\u043d \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e TinyOLAP, \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u00a0\u043d\u0435\u043c\u043d\u043e\u0433\u0438\u0445 OpenSource \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u043d\u0430\u00a0Python.<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0411\u043e\u0433\u0434\u0430\u043d\u043e\u0432, \u044f \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u044d\u043a\u0435\u043d\u0434\u2011\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a Polymatica \u0432\u00a0\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 SL Soft. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u0438\u0437\u0443\u0447\u0430\u043b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f OLAP\u2011\u043a\u0443\u0431\u043e\u0432, \u0432\u00a0\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0438 TinyOLAP.<\/p>\n<h2>\u0422\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044f <\/h2>\n<p><strong>OLAP<\/strong> (On\u2011Line Analytical Processing, \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445)\u00a0\u2014 \u043c\u0435\u0442\u043e\u0434 \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u00a0\u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437\u00a0\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0432\u00a0BI\u2011\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442\u00a0\u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>OLAP\u2011\u043a\u0443\u0431<\/strong> (OLAP cube)\u00a0\u2014 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0445 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0439 \u043a\u0443\u0431\u0438\u043a, \u043f\u0440\u0438\u00a0\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0435\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0437\u0443\u0447\u0430\u0435\u0442\u0435, \u0447\u0442\u043e\u00a0\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0438\u0437\u043d\u0435\u0441\u0430. \u0420\u0430\u0431\u043e\u0442\u0430\u044f \u0441\u00a0OLAP\u2011\u043a\u0443\u0431\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><strong>\u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f <\/strong>(dimension)\u00a0\u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u0430\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u0443\u0431\u0438\u043a\u0430. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437\u00a0\u0435\u0433\u043e \u0441\u0442\u043e\u0440\u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435\u043c = \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c: \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b, \u0434\u0430\u0442\u044b, \u0440\u0435\u0433\u0438\u043e\u043d\u044b \u0438 \u0438\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438. \u041a\u0430\u0436\u0434\u044b\u0439 \u0430\u0441\u043f\u0435\u043a\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d \u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d, \u044d\u0442\u043e \u043a\u0430\u043a\u00a0\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u044b \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p><strong>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 <\/strong>(measures)\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u00a0\u043d\u0438\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u0438\u043b\u0438\u00a0\u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e. \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a\u00a0\u043d\u0430\u0448\u0435\u043c\u0443 \u043e\u0431\u0440\u0430\u0437\u0443\u00a0\u2014 \u0432\u00a0\u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0434\u0430\u0436 \u0437\u0430\u00a0\u0434\u0430\u0442\u0443, \u0441\u0443\u043c\u043c\u0443 \u043f\u0440\u043e\u0434\u0430\u0436 \u043f\u043e\u00a0\u0442\u043e\u0432\u0430\u0440\u0430\u043c.<\/p>\n<h2>\u0421\u0442\u0440\u043e\u0438\u043c \u0441\u0432\u043e\u0439 \u043a\u0443\u0431 \u0432 TinyOLAP  <\/h2>\n<p>\u041e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e\u00a0\u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u044b \u043e\u0442\u00a0\u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u0443\u0431\u0430 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043d\u043e\u00a0\u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u043f\u043e\u0431\u043b\u0438\u0436\u0435 \u0441\u00a0TinyOLAP, \u0447\u0442\u043e\u00a0\u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u00a0\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 TinyOLAP \u0438 Pandas. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0438\u0445:<\/p>\n<pre><code class=\"python\">pip install tinyolap  pip install pandas <\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Database, \u0442\u043e \u0435\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0412\u00a0\u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 in_memory=True\u00a0\u2014 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u00a0\u043f\u0430\u043c\u044f\u0442\u0438. \u0415\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 False, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 SQLite3\u00a0\u0438 \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0411\u0414.<\/p>\n<pre><code class=\"python\">from tinyolap.database import Database  db = Database(\"forms\", in_memory=True)   db.caching = False<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f (dimension). \u041e\u043d\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432\u00a0\u0441\u0435\u0431\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439. <strong>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0443\u00a0\u043c\u0435\u043d\u044f \u043d\u0430 <\/strong><a href=\"https:\/\/github.com\/Pro100alf\/tinyolap_habr\"><strong>GitHub<\/strong><\/a><strong>.<\/strong><\/p>\n<pre><code class=\"python\"># \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u043c\u0438  dimension_names = [\"dim_company\", \"dim_assets\", \"dim_date\"]  cwd = os.getcwd()    dimensions = []    for name in dimension_names:  # \u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430  file_name = os.path.join(cwd, \"data\", f\"{name}.csv\")        # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0432 TinyOLAP \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435  dim = db.add_dimension(name).edit()  df = pd.read_csv(file_name)        # \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f  unique_dim = df[df.columns[0]].unique().astype(str)        # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435  dim.add_many(unique_dim)        # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435  if len(unique_dim) > 1:      dim.add_many(\"All\", tuple(unique_dim))   # \"\u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c\" \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f  dim.commit() <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. \u0412\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 TinyOLAP \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a\u00a0\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, \u043d\u043e\u00a0\u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438: \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u043e\u0433\u0443\u0442\u00a0\u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 (\u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0438 \u0441\u00a0\u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439). \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u0449\u0435\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432\u00a0\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"python\">data_file_name = os.path.join(cwd, \"data\", \"data.csv\")    df = pd.read_csv(data_file_name)    measures_target_names = [\"price\", \"quantity\", \"amount\"]    # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u0449\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \"measures\"  measures = db.add_dimension(\"measures\").edit()    # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445   measures.add_many(measures_target_names)    # \"\u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c\" \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f  measures.commit()   dimension_names.append('measures') <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u0443\u0431\u0430 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c OLAP \u043a\u0443\u0431. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438  cube = db.add_cube(name=\"data\", dimensions=dimension_names)        dim_count = 3    for i in range(dim_count):  df[df.columns[i]] = df[df.columns[i]].astype(str)   # \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u044b. \u041f\u0443\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0432\u0438\u0434  # (\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u04351,...,\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435n,\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c1)  # (\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u04351,...,\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435n,\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044cn)  for row in df.itertuples(index=False):  for cur_measure_index, cur_measure in enumerate(measures_target_names):      address = tuple(row[:dim_count]) + (cur_measure, )      value = row.__getattribute__(cur_measure)      cube.set(address, value) <\/code><\/pre>\n<p>\u0423\u00a0\u043d\u0430\u0441 \u0441\u043e\u0437\u0434\u0430\u043d \u043a\u0443\u0431, \u043d\u043e\u00a0\u043f\u043e\u043a\u0430 \u043e\u043d \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u043e\u0439 \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u00ab\u043c\u0430\u0433\u0438\u0435\u0439\u00bb OLAP \u043a\u0443\u0431\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0440\u0435\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u00a0\u043d\u0443\u0436\u043d\u043e\u043c \u043d\u0430\u043c \u0440\u0430\u043a\u0443\u0440\u0441\u0435:<\/p>\n<pre><code class=\"python\">view = View(cube, definition={      \"filters\": {\"dimensions\": [\"dim_assets\", \"dim_date\"]},      \"columns\": {\"dimensions\": [\"measures\"]},      \"rows\": {\"dimensions\": [\"dim_company\"]}  })    print(view.to_console_output()) <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/698\/a90\/6c4\/698a906c47aa8a743366effacccfe43f.png\" width=\"1389\" height=\"357\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/698\/a90\/6c4\/698a906c47aa8a743366effacccfe43f.png\"\/><\/figure>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 TinyOLAP<\/h3>\n<h4>\u042f\u0432\u043d\u044b\u0435 \u2013 \u043d\u0435\u044f\u0432\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b<\/h4>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0435\u0442. \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435\u00a0\u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432\u00a0\u0444\u0438\u043b\u044c\u0442\u0440\u0435 \u044f\u0432\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u00a0\u2014 TinyOLAP \u0432\u0437\u044f\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u043d\u044b\u0435. \u041f\u043e\u0444\u0438\u043a\u0441\u0438\u043c \u044d\u0442\u043e! \u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b All.<\/p>\n<pre><code class=\"python\">view = View(cube, definition={      \"filters\": {\"dimensions\": [{\"dimension\": \"dim_assets\", \"members\": \"All\"}, {\"dimension\": \"dim_date\", \"members\": \"All\"}]},      \"columns\": {\"dimensions\": [\"measures\"]},      \"rows\": {\"dimensions\": [\"dim_company\"]}  })    print(view.to_console_output()) <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/331\/a36\/989\/331a3698981b4ef0c7305cd8698fa130.png\" width=\"1460\" height=\"330\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/331\/a36\/989\/331a3698981b4ef0c7305cd8698fa130.png\"\/><\/figure>\n<p>\u0423\u0440\u0430, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u043d\u0430\u0448\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041d\u043e\u2026 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e TinyOLAP: \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438\u00a0\u2014 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u043e\u00a0\u0434\u043b\u044f\u00a0\u0446\u0435\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435\u00a0\u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442. \u0414\u043b\u044f\u00a0\u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (rules).<\/p>\n<h4>\u041f\u0440\u0430\u0432\u0438\u043b\u0430<\/h4>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 (rules)\u00a0\u2014 \u043f\u043e\u043d\u044f\u0442\u0438\u0435, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0435\u0441\u044f \u043a\u00a0TinyOLAP. \u041e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0438\u043b\u0438\u00a0\u0431\u0438\u0437\u043d\u0435\u0441\u2011\u043b\u043e\u0433\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430\u00a0\u0431\u044b\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043a\u0443\u0431\u0443. \u041f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043a\u0430\u043a\u00a0\u043c\u044b \u0443\u0436\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u0434\u043b\u044f\u00a0\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f\u00a0\u0446\u0435\u043d\u044b \u0438 \u0441\u0443\u043c\u043c\u044b. <\/p>\n<pre><code class=\"python\">@rule(\"data\", trigger=[\"measures:amount\"], scope=RuleScope.BASE_LEVEL)  def rule_cost(c: Cell):  quantity = c[\"quantity\"]  price = c[\"price\", c.BYPASS_RULES]  if quantity and price:      return float(price) * float(quantity)  return c.CONTINUE   @rule(\"data\", trigger=[\"measures:price\"], scope=RuleScope.AGGREGATION_LEVEL)  def rule_price(c: Cell):  quantity = c[\"quantity\"]  amount = c[\"amount\"]  if quantity != 0:      return float(amount \/ quantity)  return c.CONTINUE   cube.register_rule(rule_cost)  cube.register_rule(rule_price) <\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/2d2\/c1b\/073\/2d2c1b073887b304d54bcb2e5e5a0fa8.png\" width=\"1390\" height=\"311\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/2d2\/c1b\/073\/2d2c1b073887b304d54bcb2e5e5a0fa8.png\"\/><\/figure>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e\u00a0\u0441\u0443\u043c\u043c\u0430 \u0441\u0442\u0430\u043b\u0430 \u0432\u0435\u0440\u043d\u043e\u0439, \u043d\u043e\u00a0\u0446\u0435\u043d\u0430 \u043f\u043e\u2011\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430. \u0422\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u00a0\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432\u00a0\u043a\u043e\u043d\u0441\u043e\u043b\u044c. <\/p>\n<h4>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0420\u0430\u043d\u0435\u0435 \u0434\u043b\u044f\u00a0\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 to_console_log. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u00a0TinyOLAP \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u043e\u0432: to_dict, to_json, to_html.<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 to_dict \u043a\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0443 view.<\/p>\n<pre><code class=\"python\">print(view.to_dict())    {'contentType': 'TinyOlap.View', 'version': '0.8.16', 'uid': '0bab13b6-b8ef-49c8-9585-0e4aaadbc085', 'database': 'forms', 'cube': 'data', 'name': '7f4b46c5', 'title': '', 'description': '', 'zeroSuppressionOnRows': False, 'zeroSuppressionOnColumns': False, 'statistics': {'lastRefresh': '2024-03-06T00:55:19.211856', 'refreshDuration': 0.001097, 'cellsCount': 3, 'rowsCount': 1, 'columnsCount': 3, 'rowDimensionsCount': 1, 'columnDimensionsCount': 1, 'executedRules': 22, 'executedCellRequests': 49, 'executedCellAggregations': 88}, 'axes': {'filters': {'dimensions': [{'dimension': 'dim_assets', 'ordinal': 0, 'members': ['All']}, {'dimension': 'dim_date', 'ordinal': 1, 'members': ['All']}], 'positions': [{'row': 0, 'members': [{'name': 'All', 'level': 1, 'root': True}, {'name': 'All', 'level': 1, 'root': True}]}]}, 'rows': {'dimensions': [{'dimension': 'dim_company', 'ordinal': 0, 'members': ['2000']}], 'positions': [{'row': 0, 'members': [{'name': '2000', 'level': 0, 'root': True}]}]}, 'columns': {'dimensions': [{'dimension': 'measures', 'ordinal': 0, 'members': ['price', 'quantity', 'amount']}], 'positions': [{'row': 0, 'members': [{'name': 'price', 'level': 0, 'root': True}]}, {'row': 1, 'members': [{'name': 'quantity', 'level': 0, 'root': True}]}, {'row': 2, 'members': [{'name': 'amount', 'level': 0, 'root': True}]}]}}, 'cells': [{'row': 0, 'cells': [{'row': 0, 'col': 0, 'value': 160.24096385542168, 'caption': '160.24'}, {'row': 0, 'col': 1, 'value': 83.0, 'caption': '83.00'}, {'row': 0, 'col': 2, 'value': 13300.0, 'caption': '13,300.00'}]}]}  <\/code><\/pre>\n<p>\u041a\u0430\u043a\u00a0\u0432\u0438\u0434\u0438\u043c, \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u044b.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c OLAP \u043f\u043e \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e<\/h4>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 OLAP\u00a0\u2014 \u0432\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u00a0\u043f\u0440\u043e\u0441\u0442\u043e \u0432\u00a0\u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438, \u0430\u00a0\u0432\u00a0\u0440\u0430\u0437\u0440\u0435\u0437\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u043c \u0434\u043b\u044f\u00a0\u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0440\u0435\u0437, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0434\u0430\u0436 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0430 \u043f\u043e\u00a0\u0434\u0430\u0442\u0430\u043c.<\/p>\n<pre><code class=\"python\"> view = View(cube, definition={         \"filters\": {\"dimensions\": [{\"dimension\": \"dim_company\", \"members\": \"2000\"}]},         \"columns\": {\"dimensions\": [{\"dimension\": \"measures\", \"members\": \"quantity\"}, \"dim_date\"]},         \"rows\": {\"dimensions\": [\"dim_assets\"]}     })  print(view.to_console_output())<\/code><\/pre>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/3eb\/328\/719\/3eb3287193698869c6dca633fcd6d5ab.png\" width=\"2158\" height=\"153\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/3eb\/328\/719\/3eb3287193698869c6dca633fcd6d5ab.png\"\/><\/figure>\n<h3>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e TinyOLAP<\/h3>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 TinyOLAP \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0430\u043c \u043a\u0443\u0431\u0438\u043a, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u00a0\u043d\u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0440\u0435\u0437\u044b. \u041f\u043e\u00a0\u0442\u0438\u043f\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a\u00a0MOLAP (\u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430).<\/p>\n<p>\u0423\u00a0TinyOLAP \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u00a0\u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b, \u0442\u0430\u043a \u0438 \u043c\u0438\u043d\u0443\u0441\u044b.<\/p>\n<p>\u041f\u043b\u044e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u044f,<\/p>\n<\/li>\n<li>\n<p>OpenSourse.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438,<\/p>\n<\/li>\n<li>\n<p>\u0441\u043b\u0430\u0431\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f (\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b, \u043d\u043e\u00a0\u043d\u0435\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b),<\/p>\n<\/li>\n<li>\n<p>\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f\u00a0\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439,<\/p>\n<\/li>\n<li>\n<p>\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f\u00a0\u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441\u00a0\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c \u043d\u0430\u00a0OpenSourse\u2011\u0432\u0435\u0440\u0441\u0438\u0438, \u043e\u043f\u0438\u0441\u0430\u043d\u044b\u00a0\u043b\u0438\u0448\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0412\u00a0\u0442\u0435\u043a\u0443\u0449\u0435\u0439 \u0432\u0435\u0440\u0441\u0438\u0438 TinyOLAP \u0447\u0430\u0441\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0435\u0439 \u0437\u0430\u044f\u0432\u043b\u0435\u043d\u0430, \u043d\u043e\u00a0\u043d\u0435\u00a0\u0438\u043c\u043f\u043b\u0435\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u00a0\u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0438\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e\u0437\u043d\u0438\u043a\u0430\u044e\u0442 \u043e\u0448\u0438\u0431\u043a\u0438. \u041f\u0440\u0438\u00a0\u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0439 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u00ab\u043b\u0435\u0447\u0438\u0442\u0441\u044f\u00bb.<\/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\/803605\/\"> https:\/\/habr.com\/ru\/articles\/803605\/<\/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<figure class=\"full-width\"><\/figure>\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0425\u0430\u0431\u0440. \u0421\u0435\u0433\u043e\u0434\u043d\u044f\u0448\u043d\u044f\u044f \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0430 \u0442\u0435\u043c, \u043a\u0442\u043e \u0445\u043e\u0447\u0435\u0442 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 OLAP\u2011\u043a\u0443\u0431 \u0434\u043b\u044f\u00a0\u0430\u043d\u0430\u043b\u0438\u0437\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u043d\u044f\u0442\u044c, \u043a\u0430\u043a\u00a0\u043e\u043d \u0443\u0441\u0442\u0440\u043e\u0435\u043d \u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u042d\u043a\u0441\u043f\u0435\u0440\u0438\u043c\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0441\u00a0\u043f\u043e\u043c\u043e\u0449\u044c\u044e TinyOLAP, \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437\u00a0\u043d\u0435\u043c\u043d\u043e\u0433\u0438\u0445 OpenSource \u0434\u0432\u0438\u0436\u043a\u043e\u0432 \u043d\u0430\u00a0Python.<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0414\u043c\u0438\u0442\u0440\u0438\u0439 \u0411\u043e\u0433\u0434\u0430\u043d\u043e\u0432, \u044f \u0441\u0442\u0430\u0440\u0448\u0438\u0439 \u0431\u044d\u043a\u0435\u043d\u0434\u2011\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a Polymatica \u0432\u00a0\u043a\u043e\u043c\u043f\u0430\u043d\u0438\u0438 SL Soft. \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043d\u0430\u0437\u0430\u0434 \u044f \u0438\u0437\u0443\u0447\u0430\u043b \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u0432 \u0434\u043b\u044f\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f OLAP\u2011\u043a\u0443\u0431\u043e\u0432, \u0432\u00a0\u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435, \u0438 TinyOLAP.<\/p>\n<h2>\u0422\u0435\u0440\u043c\u0438\u043d\u043e\u043b\u043e\u0433\u0438\u044f <\/h2>\n<p><strong>OLAP<\/strong> (On\u2011Line Analytical Processing, \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0434\u0430\u043d\u043d\u044b\u0445)\u00a0\u2014 \u043c\u0435\u0442\u043e\u0434 \u0430\u043d\u0430\u043b\u0438\u0437\u0430, \u043e\u0441\u043d\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u00a0\u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437\u00a0\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u043e\u0432. \u0421\u0435\u0433\u043e\u0434\u043d\u044f \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437\u00a0\u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u043f\u043e\u0434\u0445\u043e\u0434\u043e\u0432 \u0432\u00a0BI\u2011\u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442\u00a0\u0431\u044b\u0441\u0442\u0440\u043e \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u044b \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438.<\/p>\n<p><strong>OLAP\u2011\u043a\u0443\u0431<\/strong> (OLAP cube)\u00a0\u2014 \u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442 \u0438\u0445 \u043b\u0443\u0447\u0448\u0435 \u043f\u043e\u043d\u0438\u043c\u0430\u0442\u044c \u0438 \u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c. \u041c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0438\u0433\u0440\u0443\u0448\u0435\u0447\u043d\u044b\u0439 \u043a\u0443\u0431\u0438\u043a, \u043f\u0440\u0438\u00a0\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0432\u044b \u0432\u0438\u0434\u0438\u0442\u0435 \u0435\u0433\u043e \u0440\u0430\u0437\u043d\u044b\u0435 \u0441\u0442\u043e\u0440\u043e\u043d\u044b \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0437\u0443\u0447\u0430\u0435\u0442\u0435, \u0447\u0442\u043e\u00a0\u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0443\u0442\u0440\u0438 \u0431\u0438\u0437\u043d\u0435\u0441\u0430. \u0420\u0430\u0431\u043e\u0442\u0430\u044f \u0441\u00a0OLAP\u2011\u043a\u0443\u0431\u0430\u043c\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u044b\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043d\u0430\u00a0\u043e\u0441\u043d\u043e\u0432\u0435 \u043d\u0430\u043a\u043e\u043f\u043b\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<p><strong>\u0418\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f <\/strong>(dimension)\u00a0\u2014 \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0438\u0445 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0430\u0441\u043f\u0435\u043a\u0442\u044b. \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0438\u043c \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u043d\u0430\u00a0\u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043a\u0443\u0431\u0438\u043a\u0430. \u041a\u0430\u0436\u0434\u0430\u044f \u0438\u0437\u00a0\u0435\u0433\u043e \u0441\u0442\u043e\u0440\u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435\u043c = \u0430\u0441\u043f\u0435\u043a\u0442\u043e\u043c: \u043f\u0440\u043e\u0434\u0443\u043a\u0442\u044b, \u0434\u0430\u0442\u044b, \u0440\u0435\u0433\u0438\u043e\u043d\u044b \u0438 \u0438\u043d\u044b\u0435 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438 \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u0438\u0441\u0442\u0438\u043a\u0438. \u041a\u0430\u0436\u0434\u044b\u0439 \u0430\u0441\u043f\u0435\u043a\u0442 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d \u0438 \u0438\u0437\u0432\u0435\u0441\u0442\u0435\u043d, \u044d\u0442\u043e \u043a\u0430\u043a\u00a0\u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0436\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u044b \u0437\u0430\u043f\u0438\u0441\u0438.<\/p>\n<p><strong>\u041f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 <\/strong>(measures)\u00a0\u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0438\u043b\u0438\u00a0\u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445. \u041f\u043e\u00a0\u043d\u0438\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0440\u043e\u0438\u0437\u0432\u0435\u0441\u0442\u0438 \u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u043a\u0443 \u0438\u043b\u0438\u00a0\u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044e. \u0412\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a\u00a0\u043d\u0430\u0448\u0435\u043c\u0443 \u043e\u0431\u0440\u0430\u0437\u0443\u00a0\u2014 \u0432\u00a0\u043a\u0430\u0436\u0434\u043e\u0435 \u043f\u0435\u0440\u0435\u0441\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0432\u043d\u0435\u0441\u0442\u0438 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e \u044d\u0442\u0438\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0434\u0430\u0436 \u0437\u0430\u00a0\u0434\u0430\u0442\u0443, \u0441\u0443\u043c\u043c\u0443 \u043f\u0440\u043e\u0434\u0430\u0436 \u043f\u043e\u00a0\u0442\u043e\u0432\u0430\u0440\u0430\u043c.<\/p>\n<h2>\u0421\u0442\u0440\u043e\u0438\u043c \u0441\u0432\u043e\u0439 \u043a\u0443\u0431 \u0432 TinyOLAP  <\/h2>\n<p>\u041e\u0433\u043e\u0432\u043e\u0440\u044e\u0441\u044c, \u0447\u0442\u043e\u00a0\u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u044b \u043e\u0442\u00a0\u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0433\u043e \u043a\u0443\u0431\u0430 \u0432\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e, \u043d\u043e\u00a0\u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u0442\u0435\u0441\u044c \u043f\u043e\u0431\u043b\u0438\u0436\u0435 \u0441\u00a0TinyOLAP, \u0447\u0442\u043e\u00a0\u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u0432\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0441\u00a0\u0441\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u0430\u043c\u0438.<\/p>\n<p>\u041d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u044e\u0442\u0441\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 TinyOLAP \u0438 Pandas. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0438\u0445:<\/p>\n<pre><code class=\"python\">pip install tinyolap  pip install pandas <\/code><\/pre>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043e\u0431\u044a\u0435\u043a\u0442\u0430 Database, \u0442\u043e \u0435\u0441\u0442\u044c \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0439 \u0431\u0430\u0437\u044b \u0434\u0430\u043d\u043d\u044b\u0445, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0412\u00a0\u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 in_memory=True\u00a0\u2014 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u044f\u0442\u0441\u044f \u0432\u00a0\u043f\u0430\u043c\u044f\u0442\u0438. \u0415\u0441\u043b\u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 False, \u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0430 SQLite3\u00a0\u0438 \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0411\u0414.<\/p>\n<pre><code class=\"python\">from tinyolap.database import Database  db = Database(\"forms\", in_memory=True)   db.caching = False<\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f (dimension). \u041e\u043d\u0438 \u0432\u043a\u043b\u044e\u0447\u0430\u044e\u0442 \u0432\u00a0\u0441\u0435\u0431\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439. <strong>\u0422\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u0443\u00a0\u043c\u0435\u043d\u044f \u043d\u0430 <\/strong><a href=\"https:\/\/github.com\/Pro100alf\/tinyolap_habr\"><strong>GitHub<\/strong><\/a><strong>.<\/strong><\/p>\n<pre><code class=\"python\"># \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0441 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f\u043c\u0438  dimension_names = [\"dim_company\", \"dim_assets\", \"dim_date\"]  cwd = os.getcwd()    dimensions = []    for name in dimension_names:  # \u0441\u0442\u0440\u043e\u0438\u043c \u043f\u0443\u0442\u044c \u0434\u043e \u0444\u0430\u0439\u043b\u0430  file_name = os.path.join(cwd, \"data\", f\"{name}.csv\")        # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043d\u043e\u0432\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0432 TinyOLAP \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u043d\u0430 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435  dim = db.add_dimension(name).edit()  df = pd.read_csv(file_name)        # \u0434\u0435\u043b\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f  unique_dim = df[df.columns[0]].unique().astype(str)        # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0430\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435  dim.add_many(unique_dim)        # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0439 \u044d\u043b\u0435\u043c\u0435\u043d\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u043a\u043b\u044e\u0447\u0430\u0435\u0442 \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435  if len(unique_dim) > 1:      dim.add_many(\"All\", tuple(unique_dim))   # \"\u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c\" \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f  dim.commit() <\/code><\/pre>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438. \u0412\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 TinyOLAP \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438 \u0441\u043e\u0437\u0434\u0430\u044e\u0442\u0441\u044f \u043a\u0430\u043a\u00a0\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f, \u043d\u043e\u00a0\u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044f\u043c\u0438: \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439 \u043c\u043e\u0433\u0443\u0442\u00a0\u0431\u044b\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u043c\u0438 (\u0446\u0435\u043b\u043e\u0447\u0438\u0441\u043b\u0435\u043d\u043d\u044b\u0435 \u0438 \u0441\u00a0\u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0435\u0439 \u0442\u043e\u0447\u043a\u043e\u0439). \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0431\u0449\u0435\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435 \u0438 \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0435\u0441\u0442\u044c \u0432\u00a0\u0434\u0430\u043d\u043d\u044b\u0445.<\/p>\n<pre><code class=\"python\">data_file_name = os.path.join(cwd, \"data\", \"data.csv\")    df = pd.read_csv(data_file_name)    measures_target_names = [\"price\", \"quantity\", \"amount\"]    # \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043e\u0431\u0449\u0438\u0439 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \"measures\"  measures = db.add_dimension(\"measures\").edit()    # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u043d\u0435\u0433\u043e \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445   measures.add_many(measures_target_names)    # \"\u0437\u0430\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u043c\" \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f  measures.commit()   dimension_names.append('measures') <\/code><\/pre>\n<p>\u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043a\u00a0\u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044e \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u0443\u0431\u0430 \u0438 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u043c\u0438.<\/p>\n<pre><code class=\"python\"># \u0441\u043e\u0437\u0434\u0430\u0435\u043c OLAP \u043a\u0443\u0431. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u043f\u0435\u0440\u0435\u0434\u0430\u0434\u0438\u043c \u0432\u0441\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0438  cube = db.add_cube(name=\"data\", dimensions=dimension_names)        dim_count = 3    for i in range(dim_count):  df[df.columns[i]] = df[df.columns[i]].astype(str)   # \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0444\u0430\u0439\u043b\u044b. \u041f\u0443\u0442\u044c \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0438\u043c\u0435\u0435\u0442 \u0432\u0438\u0434  # (\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u04351,...,\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435n,\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c1)  # (\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u04351,...,\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0435n,\u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044cn)  for row in df.itertuples(index=False):  for cur_measure_index, cur_measure in enumerate(measures_target_names):      address = tuple(row[:dim_count]) + (cur_measure, )      value = row.__getattribute__(cur_measure)      cube.set(address, value) <\/code><\/pre>\n<p>\u0423\u00a0\u043d\u0430\u0441 \u0441\u043e\u0437\u0434\u0430\u043d \u043a\u0443\u0431, \u043d\u043e\u00a0\u043f\u043e\u043a\u0430 \u043e\u043d \u0431\u0435\u0441\u043f\u043e\u043b\u0435\u0437\u0435\u043d \u0438 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u043e \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u043e\u0439 \u0441\u00a0\u0434\u0430\u043d\u043d\u044b\u043c\u0438. <\/p>\n<p>\u0414\u0430\u043b\u0435\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0430\u0437\u0431\u0438\u0440\u0430\u0442\u044c\u0441\u044f \u0441 \u00ab\u043c\u0430\u0433\u0438\u0435\u0439\u00bb OLAP \u043a\u0443\u0431\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0440\u0435\u0437 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u00a0\u043d\u0443\u0436\u043d\u043e\u043c \u043d\u0430\u043c \u0440\u0430\u043a\u0443\u0440\u0441\u0435:<\/p>\n<pre><code class=\"python\">view = View(cube, definition={      \"filters\": {\"dimensions\": [\"dim_assets\", \"dim_date\"]},      \"columns\": {\"dimensions\": [\"measures\"]},      \"rows\": {\"dimensions\": [\"dim_company\"]}  })    print(view.to_console_output()) <\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<h3>\u041f\u0440\u043e\u0431\u043b\u0435\u043c\u044b \u0438 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0438 TinyOLAP<\/h3>\n<h4>\u042f\u0432\u043d\u044b\u0435 \u2013 \u043d\u0435\u044f\u0432\u043d\u044b\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u044b<\/h4>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e\u00a0\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0435\u0442. \u0422\u0430\u043a \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043c\u044b \u043d\u0435\u00a0\u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u0432\u00a0\u0444\u0438\u043b\u044c\u0442\u0440\u0435 \u044f\u0432\u043d\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f\u00a0\u2014 TinyOLAP \u0432\u0437\u044f\u043b \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u0442\u043e \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0432\u044b\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u043d\u044b\u0435. \u041f\u043e\u0444\u0438\u043a\u0441\u0438\u043c \u044d\u0442\u043e! \u0414\u043b\u044f\u00a0\u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0440\u0430\u043d\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0435 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u0443\u044e\u0449\u0438\u0435 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b All.<\/p>\n<pre><code class=\"python\">view = View(cube, definition={      \"filters\": {\"dimensions\": [{\"dimension\": \"dim_assets\", \"members\": \"All\"}, {\"dimension\": \"dim_date\", \"members\": \"All\"}]},      \"columns\": {\"dimensions\": [\"measures\"]},      \"rows\": {\"dimensions\": [\"dim_company\"]}  })    print(view.to_console_output()) <\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0423\u0440\u0430, \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u043f\u0435\u0440\u0432\u044b\u0435 \u043d\u0430\u0448\u0438 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u044b. \u041d\u043e\u2026 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435\u00a0\u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041c\u044b \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0438\u0441\u044c \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e TinyOLAP: \u043f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u0438\u00a0\u2014 \u0441\u0443\u043c\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u043d\u043e\u00a0\u0434\u043b\u044f\u00a0\u0446\u0435\u043d\u044b \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 \u043d\u0435\u00a0\u043f\u043e\u0434\u0445\u043e\u0434\u0438\u0442. \u0414\u043b\u044f\u00a0\u0442\u0430\u043a\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u0435\u0432 \u0435\u0441\u0442\u044c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 (rules).<\/p>\n<h4>\u041f\u0440\u0430\u0432\u0438\u043b\u0430<\/h4>\n<p>\u041f\u0440\u0430\u0432\u0438\u043b\u0430 (rules)\u00a0\u2014 \u043f\u043e\u043d\u044f\u0442\u0438\u0435, \u043e\u0442\u043d\u043e\u0441\u044f\u0449\u0435\u0435\u0441\u044f \u043a\u00a0TinyOLAP. \u041e\u043d\u0438 \u043d\u0443\u0436\u043d\u044b \u0434\u043b\u044f\u00a0\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044f \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0445 \u0432\u044b\u0447\u0438\u0441\u043b\u0435\u043d\u0438\u0439 \u0438\u043b\u0438\u00a0\u0431\u0438\u0437\u043d\u0435\u0441\u2011\u043b\u043e\u0433\u0438\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0434\u043e\u043b\u0436\u043d\u0430\u00a0\u0431\u044b\u0442\u044c \u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0430 \u043a\u0443\u0431\u0443. \u041f\u043e\u00a0\u0443\u043c\u043e\u043b\u0447\u0430\u043d\u0438\u044e, \u043a\u0430\u043a\u00a0\u043c\u044b \u0443\u0436\u0435 \u0432\u044b\u044f\u0441\u043d\u0438\u043b\u0438 \u0440\u0430\u043d\u0435\u0435, \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u0435\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u0433\u0440\u0435\u0433\u0430\u0446\u0438\u044f \u0434\u043b\u044f\u00a0\u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0445 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0432\u043e\u0438 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0434\u043b\u044f\u00a0\u0446\u0435\u043d\u044b \u0438 \u0441\u0443\u043c\u043c\u044b. <\/p>\n<pre><code class=\"python\">@rule(\"data\", trigger=[\"measures:amount\"], scope=RuleScope.BASE_LEVEL)  def rule_cost(c: Cell):  quantity = c[\"quantity\"]  price = c[\"price\", c.BYPASS_RULES]  if quantity and price:      return float(price) * float(quantity)  return c.CONTINUE   @rule(\"data\", trigger=[\"measures:price\"], scope=RuleScope.AGGREGATION_LEVEL)  def rule_price(c: Cell):  quantity = c[\"quantity\"]  amount = c[\"amount\"]  if quantity != 0:      return float(amount \/ quantity)  return c.CONTINUE   cube.register_rule(rule_cost)  cube.register_rule(rule_price) <\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u0438\u0434\u0438\u043c, \u0447\u0442\u043e\u00a0\u0441\u0443\u043c\u043c\u0430 \u0441\u0442\u0430\u043b\u0430 \u0432\u0435\u0440\u043d\u043e\u0439, \u043d\u043e\u00a0\u0446\u0435\u043d\u0430 \u043f\u043e\u2011\u043f\u0440\u0435\u0436\u043d\u0435\u043c\u0443 \u043d\u0435\u043a\u043e\u0440\u0440\u0435\u043a\u0442\u043d\u0430. \u0422\u0443\u0442 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432\u00a0\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0432\u044b\u0432\u043e\u0434\u0430 \u0432\u00a0\u043a\u043e\u043d\u0441\u043e\u043b\u044c. <\/p>\n<h4>\u0412\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u0432\u044b\u0432\u043e\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0445<\/h4>\n<p>\u0420\u0430\u043d\u0435\u0435 \u0434\u043b\u044f\u00a0\u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434 to_console_log. \u041e\u0434\u043d\u0430\u043a\u043e \u0432\u00a0TinyOLAP \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043e\u0442\u0447\u0435\u0442\u043e\u0432: to_dict, to_json, to_html.<\/p>\n<p>\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 to_dict \u043a\u00a0\u043e\u0431\u044a\u0435\u043a\u0442\u0443 view.<\/p>\n<pre><code class=\"python\">print(view.to_dict())    {'contentType': 'TinyOlap.View', 'version': '0.8.16', 'uid': '0bab13b6-b8ef-49c8-9585-0e4aaadbc085', 'database': 'forms', 'cube': 'data', 'name': '7f4b46c5', 'title': '', 'description': '', 'zeroSuppressionOnRows': False, 'zeroSuppressionOnColumns': False, 'statistics': {'lastRefresh': '2024-03-06T00:55:19.211856', 'refreshDuration': 0.001097, 'cellsCount': 3, 'rowsCount': 1, 'columnsCount': 3, 'rowDimensionsCount': 1, 'columnDimensionsCount': 1, 'executedRules': 22, 'executedCellRequests': 49, 'executedCellAggregations': 88}, 'axes': {'filters': {'dimensions': [{'dimension': 'dim_assets', 'ordinal': 0, 'members': ['All']}, {'dimension': 'dim_date', 'ordinal': 1, 'members': ['All']}], 'positions': [{'row': 0, 'members': [{'name': 'All', 'level': 1, 'root': True}, {'name': 'All', 'level': 1, 'root': True}]}]}, 'rows': {'dimensions': [{'dimension': 'dim_company', 'ordinal': 0, 'members': ['2000']}], 'positions': [{'row': 0, 'members': [{'name': '2000', 'level': 0, 'root': True}]}]}, 'columns': {'dimensions': [{'dimension': 'measures', 'ordinal': 0, 'members': ['price', 'quantity', 'amount']}], 'positions': [{'row': 0, 'members': [{'name': 'price', 'level': 0, 'root': True}]}, {'row': 1, 'members': [{'name': 'quantity', 'level': 0, 'root': True}]}, {'row': 2, 'members': [{'name': 'amount', 'level': 0, 'root': True}]}]}}, 'cells': [{'row': 0, 'cells': [{'row': 0, 'col': 0, 'value': 160.24096385542168, 'caption': '160.24'}, {'row': 0, 'col': 1, 'value': 83.0, 'caption': '83.00'}, {'row': 0, 'col': 2, 'value': 13300.0, 'caption': '13,300.00'}]}]}  <\/code><\/pre>\n<p>\u041a\u0430\u043a\u00a0\u0432\u0438\u0434\u0438\u043c, \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432\u0435\u0440\u043d\u044b.<\/p>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c OLAP \u043f\u043e \u0438\u0441\u0442\u0438\u043d\u043d\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044e<\/h4>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 OLAP\u00a0\u2014 \u0432\u044b\u0432\u043e\u0434 \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0435\u00a0\u043f\u0440\u043e\u0441\u0442\u043e \u0432\u00a0\u0432\u0438\u0434\u0435 \u0442\u0430\u0431\u043b\u0438\u0447\u043a\u0438, \u0430\u00a0\u0432\u00a0\u0440\u0430\u0437\u0440\u0435\u0437\u0435, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u043c \u0434\u043b\u044f\u00a0\u0430\u043d\u0430\u043b\u0438\u0437\u0430. \u041f\u043e\u0441\u0442\u0440\u043e\u0438\u043c \u0441\u0440\u0435\u0437, \u0432\u00a0\u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0440\u043e\u0434\u0430\u0436 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u043e\u0432\u0430\u0440\u0430 \u043f\u043e\u00a0\u0434\u0430\u0442\u0430\u043c.<\/p>\n<pre><code class=\"python\"> view = View(cube, definition={         \"filters\": {\"dimensions\": [{\"dimension\": \"dim_company\", \"members\": \"2000\"}]},         \"columns\": {\"dimensions\": [{\"dimension\": \"measures\", \"members\": \"quantity\"}, \"dim_date\"]},         \"rows\": {\"dimensions\": [\"dim_assets\"]}     })  print(view.to_console_output())<\/code><\/pre>\n<figure class=\"full-width\"><\/figure>\n<h3>\u041d\u0435\u043c\u043d\u043e\u0433\u043e \u043e TinyOLAP<\/h3>\n<p>\u0411\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 TinyOLAP \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u0438 \u0441\u0430\u043c \u043a\u0443\u0431\u0438\u043a, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0432\u00a0\u043d\u0435\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u043e\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0440\u0435\u0437\u044b. \u041f\u043e\u00a0\u0442\u0438\u043f\u0443 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u0441\u044f \u043a\u00a0MOLAP (\u043c\u043d\u043e\u0433\u043e\u043c\u0435\u0440\u043d\u0430\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u0430\u044f \u0430\u043d\u0430\u043b\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430).<\/p>\n<p>\u0423\u00a0TinyOLAP \u0435\u0441\u0442\u044c \u043a\u0430\u043a\u00a0\u0441\u0432\u043e\u0438 \u043f\u043b\u044e\u0441\u044b, \u0442\u0430\u043a \u0438 \u043c\u0438\u043d\u0443\u0441\u044b.<\/p>\n<p>\u041f\u043b\u044e\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u043e\u0441\u0432\u043e\u0435\u043d\u0438\u044f,<\/p>\n<\/li>\n<li>\n<p>OpenSourse.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u0438\u043d\u0443\u0441\u044b:<\/p>\n<ul>\n<li>\n<p>\u043d\u0435\u0442 \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0438,<\/p>\n<\/li>\n<li>\n<p>\u0441\u043b\u0430\u0431\u0430\u044f \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f (\u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b \u043e\u043f\u0438\u0441\u0430\u043d\u044b, \u043d\u043e\u00a0\u043d\u0435\u00a0\u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u044b),<\/p>\n<\/li>\n<li>\n<p>\u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0434\u043b\u044f\u00a0\u0438\u0437\u043c\u0435\u0440\u0435\u043d\u0438\u0439 \u0438 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u0435\u0439,<\/p>\n<\/li>\n<li>\n<p>\u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u044b \u0438 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0434\u043b\u044f\u00a0\u0442\u044f\u0436\u0435\u043b\u044b\u0445 \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u0432.<\/p>\n<\/li>\n<\/ul>\n<p>\u041c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0441\u00a0\u043d\u0435\u0431\u043e\u043b\u044c\u0448\u0438\u043c \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u043c \u0434\u0430\u0442\u0430\u0441\u0435\u0442\u043e\u043c <\/p>\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-372088","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372088","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=372088"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/372088\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=372088"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=372088"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=372088"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}