{"id":310912,"date":"2020-10-03T15:00:26","date_gmt":"2020-10-03T15:00:26","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=310912"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=310912","title":{"rendered":"\u0424\u043e\u0440\u043c\u0430\u0442 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 pandas"},"content":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/521894\/\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043a\u0430 \u0435\u0449\u0451 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0443 \u0432 \u043f\u043e\u0434\u0441\u043e\u0437\u043d\u0430\u043d\u0438\u0435 \u0438\u043b\u0438, \u043d\u0430 \u0445\u0443\u0434\u043e\u0439 \u043a\u043e\u043d\u0435\u0446, \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 slack, \u0432\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0438 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 excel \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/use-conditional-formatting-to-highlight-information-fed60dfa-1d3f-4e13-9ecb-f1951ff89d7f\">\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> \u0438 <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/analyze-trends-in-data-using-sparklines-be6579cf-a8e3-471a-a459-873614413ce1\">\u0441\u043f\u0430\u0440\u043a\u043b\u0430\u0439\u043d\u044b<\/a>. \u0410 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>pandas<\/code>: \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/style.html\"><code>DataFrame.style<\/code><\/a> \u0438 <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/options.html\"><code>Options and settings<\/code><\/a>.<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u0431\u0430\u0437\u043e\u0432\u0443\u044e \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/h3>\n<p>  <\/p>\n<p>\u0418\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <code>pandas<\/code> \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 <code>seaborn<\/code> \u0434\u043b\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043d\u0430\u0431\u043e\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 <code>penguins<\/code>:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">import pandas as pd import seaborn as sns<\/code><\/pre>\n<p>  <\/p>\n<p>\u0421 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>pd.set_option<\/code> \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u043c \u0432\u044b\u0432\u043e\u0434 \u0442\u0430\u043a \u0447\u0442\u043e\u0431\u044b:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0442\u0440\u043e\u043a \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0431\u044b\u043b\u043e \u043d\u0435 \u0431\u043e\u043b\u044c\u0448\u0435 5;<\/li>\n<li>\u0442\u0435\u043a\u0441\u0442 \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u043e\u0442\u0440\u0430\u0436\u0430\u043b\u0441\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u0432\u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0434\u043b\u0438\u043d\u044b (\u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u043e, \u0435\u0441\u043b\u0438 \u0432 \u044f\u0447\u0435\u0439\u043a\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043e\u043a \u0438\u043b\u0438 URL, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c);<\/li>\n<li>\u0432\u0441\u0435 \u0447\u0438\u0441\u043b\u0430 \u043e\u0442\u0440\u0430\u0436\u0430\u043b\u0438\u0441\u044c \u0441 \u0434\u0432\u0443\u043c\u044f \u0437\u043d\u0430\u043a\u0430\u043c\u0438 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u044f\u0442\u043e\u0439; <\/li>\n<\/ul>\n<p>  <\/p>\n<pre><code class=\"python\">pd.set_option('max_rows', 5) pd.set_option('display.max_colwidth', None) pd.set_option('display.float_format', '{:.2f}'.format)<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0435\u043c \u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">penguins = sns.load_dataset(\u2018penguins\u2019) penguins<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/gh\/ym\/17\/ghym17ts3l9dmyf3nijw2mn2cds.png\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0432\u0435\u0440\u043d\u0443\u0442\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043a \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u043c, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c <code>pd.reset_option<\/code>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0442\u0430\u043a, \u0435\u0441\u043b\u0438 \u0445\u043e\u0442\u0438\u043c \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">pd.reset_option('all')<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0432\u043e\u0439\u0441\u0442\u0432 <code>set_option<\/code>.<\/p>\n<p>  <\/p>\n<h3>\u041d\u0430\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0430\u0445<\/h3>\n<p>  <\/p>\n<p><strong> \u0424\u043e\u0440\u043c\u0430\u0442 \u0447\u0438\u0441\u0435\u043b, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0438 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440<\/strong><\/p>\n<p>  <\/p>\n<p>\u0423 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u043e\u0432 \u0432 <code>pandas<\/code> \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u043e <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/style.html\"><code>DataFrame.style<\/code><\/a>, \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u043c\u0435\u043d\u044f\u0435\u0442 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u044f\u0447\u0435\u0435\u043a \u043f\u043e \u0443\u0441\u043b\u043e\u0432\u0438\u044e \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a \u0438\u043b\u0438 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0434\u0430\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u043d\u0430\u043a\u043e\u0432 \u043f\u043e\u0441\u043b\u0435 \u0437\u0430\u043f\u044f\u0442\u043e\u0439, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u044b\u0445 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">(penguins  .head(5)  .style  .format('{:.1f}', na_rep='-')  .format({'species': lambda x:x.lower(),           'island': lambda x:x.lower(),           'sex': lambda x: '-' if pd.isna(x) else x.lower()          }) )<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/vj\/z-\/a2\/vjz-a2faffvbcztzb9hew9ra0zu.png\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p>\u0423 \u043d\u0430\u0441 \u0442\u0443\u0442 \u0432\u0441\u0451 \u043f\u0440\u043e \u043f\u0438\u043d\u0433\u0432\u0438\u043d\u043e\u0432, \u043d\u043e \u0432 \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u0446\u0435\u043d\u0430\u0445, \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0437\u043d\u0430\u043a \u20bd \u043f\u0435\u0440\u0435\u0434 \u0447\u0438\u0441\u043b\u043e\u043c \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">(df .style .format({'price': '\u20bd{:.2f}'}) )<\/code><\/pre>\n<p>  <\/p>\n<p>\u0414\u0430\u043b\u044c\u0448\u0435 \u2014 \u0431\u043e\u043b\u044c\u0448\u0435!<\/p>\n<p>  <\/p>\n<p><strong>\u0412\u044b\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0446\u0432\u0435\u0442\u043e\u043c (\u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u0438)<\/strong><\/p>\n<p>  <\/p>\n<p>\u0424\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 \u043c\u0438\u043d\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0438 \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e\u0433\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u044b\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u0441\u0442\u043e\u043b\u0431\u0446\u044b, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0442\u044c\u0441\u044f, \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a. \u042d\u0442\u043e\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0431\u0443\u0434\u0435\u043c \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0442\u044c \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 <code>subset<\/code>.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">numeric_columns = ['bill_length_mm',                    'bill_depth_mm',                    'flipper_length_mm',                    'body_mass_g']<\/code><\/pre>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u043c \u043c\u0438\u043d\u0438\u043c\u0443\u043c, \u043c\u0430\u043a\u0441\u0438\u043c\u0443\u043c \u0438 \u043f\u0443\u0441\u0442\u044b\u0435 \u044f\u0447\u0435\u0439\u043a\u0438 \u0438 \u0432\u044b\u0432\u0435\u0434\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0435 5 \u0441\u0442\u0440\u043e\u043a \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">(penguins  .head(5)  .style  .format('{:.1f}', na_rep='-')  .format({'species': lambda x:x.lower(),           'island': lambda x:x.lower(),           'sex': lambda x: '-' if pd.isna(x) else x.lower()          })  .highlight_null(null_color='lightgrey')  .highlight_max(color='yellowgreen', subset=numeric_columns)  .highlight_min(color='coral', subset=numeric_columns) )<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/fi\/gx\/cy\/figxcyielvwnzxo0lxfvjjdvhgu.png\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0433\u043b\u044f\u0434\u043d\u043e \u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e \u0432 \u044d\u0442\u0438\u0445 5\u0442\u0438 \u0441\u0442\u0440\u043e\u043a\u0430\u0445 \u0441\u0430\u043c\u044b\u0439 \u0434\u043b\u0438\u043d\u043d\u044b\u0439 \u043a\u043b\u044e\u0432 \u0443 \u043f\u0438\u043d\u0433\u0432\u0438\u043d\u0430 \u0432 \u0441\u0442\u0440\u043e\u043a\u0435 \u0441 \u0438\u043d\u0434\u0435\u043a\u0441\u043e\u043c 2 \u0438 \u0443 \u043d\u0435\u0433\u043e (\u043d\u0435\u0451!) \u0436\u0435 \u0441\u0430\u043c\u044b\u0435 \u0434\u043b\u0438\u043d\u043d\u044b\u0435 \u043f\u043b\u0430\u0432\u043d\u0438\u043a\u0438 \u0438 \u0441\u0430\u043c\u044b\u0439 \u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0438\u0439 \u0432\u0435\u0441.<\/p>\n<p>  <\/p>\n<p>\u0423\u0441\u043b\u043e\u0436\u043d\u0438\u043c \u0435\u0449\u0451 \u043d\u0435\u043c\u043d\u043e\u0433\u043e: \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043d\u0430 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0434\u043b\u0438\u043d\u044b \u043f\u043b\u0430\u0432\u043d\u0438\u043a\u043e\u0432 \u043f\u0438\u043d\u0433\u0432\u0438\u043d\u043e\u0432-\u0434\u0435\u0432\u043e\u0447\u0435\u043a \u0432\u0438\u0434\u0430 Adelie.<\/p>\n<p>  <\/p>\n<p><strong>Bar chart \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/strong><\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430, \u0432\u044b\u0434\u0435\u043b\u044f\u0435\u043c \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0434\u0430\u0442\u0430\u0444\u0440\u0435\u0439\u043c \u043f\u0438\u043d\u0433\u0432\u0438\u043d\u043e\u0432 \u0436\u0435\u043d\u0441\u043a\u043e\u0433\u043e \u043f\u043e\u043b\u0430 \u0438 \u0432\u0438\u0434\u0430 Adelie \u0438 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0434\u043b\u044f \u043d\u0438\u0445 \u0440\u0430\u0437\u0431\u0440\u043e\u0441 \u0434\u043b\u0438\u043d \u043f\u043b\u0430\u0432\u043d\u0438\u043a\u043e\u0432.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">adelie_female = (penguins[(penguins['species'] == 'Adelie') &amp;                            (penguins['sex'] == 'FEMALE')]                  .copy()                 )  adelie_female['flipper_l_var'] = ((adelie_female['flipper_length_mm']-                                                   adelie_female['flipper_length_mm'].mean()).round())<\/code><\/pre>\n<p>  <\/p>\n<p>\u041a \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u0447\u0438\u0441\u043b\u043e\u0432\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u043e\u0440\u043c\u0430\u0442 \u0434\u043b\u044f \u0441\u0442\u043e\u043b\u0431\u0446\u0430 <code>'flipper_l_var'<\/code>. \u0417\u0430\u0434\u0430\u0451\u043c:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0433\u0440\u0443\u043f\u043f\u0443 \u0441\u0442\u043e\u043b\u0431\u0446\u043e\u0432 (<code>subset<\/code>), \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u043c \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u0433\u0440\u0430\u0444\u0438\u043a;<\/li>\n<li>\u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u0435 (<code>align<\/code>): <code>mid<\/code> \u2014 \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u043e\u0436\u0438\u0434\u0430\u0435\u043c, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043a\u0430\u043a \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435, \u0442\u0430\u043a \u0438 \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0435. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0434\u0440\u0443\u0433\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u0432\u044b\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442;<\/li>\n<li>\u0446\u0432\u0435\u0442 (<code>color<\/code>). \u0412 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 2 \u0446\u0432\u0435\u0442\u0430: \u0434\u043b\u044f \u043e\u0442\u0440\u0438\u0446\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0438 \u043f\u043e\u043b\u043e\u0436\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439;<\/li>\n<li>\u0433\u0440\u0430\u043d\u0438\u0446\u044b (<code>vmin<\/code>, <code>vmax<\/code>).<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u041e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>set_properties<\/code> \u043f\u0440\u043e\u043f\u0438\u0448\u0435\u043c, \u0447\u0442\u043e \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0441\u0442\u043e\u043b\u0431\u0446\u0435 <code>'flipper_l_var'<\/code> \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u0442\u043e\u044f\u0442\u044c \u0432 \u0446\u0435\u043d\u0442\u0440\u0435 \u044f\u0447\u0435\u0439\u043a\u0438.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">(adelie_female  .head(5)  .style  .format('{:.1f}', na_rep='-')  .format({'species': lambda x:x.lower(),           'island': lambda x:x.lower(),           'sex': lambda x: '-' if pd.isna(x) else x.lower()          })  .bar(subset=['flipper_l_var'],       align='mid',       color=['coral', 'yellowgreen'],       vmin=adelie_female['flipper_l_var'].min(),       vmax=adelie_female['flipper_l_var'].max()      )  .set_properties(**{'text-align': 'center'}, subset='flipper_l_var') )<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/cy\/jx\/fc\/cyjxfc7z1wykgtay1bi2bhb_crm.png\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p><strong>Heatmap \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435<\/strong><\/p>\n<p>  <\/p>\n<p>\u0418\u043d\u043e\u0433\u0434\u0430 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e \u043f\u043e\u0434\u0441\u0432\u0435\u0442\u0438\u0442\u044c \u0432\u0441\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u0432 \u0442\u0430\u0431\u043b\u0438\u0446\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0440\u0430\u0434\u0438\u0435\u043d\u0442\u0430. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043a\u043e\u0433\u0434\u0430 \u043d\u0443\u0436\u043d\u043e \u0441\u0440\u0430\u0432\u043d\u0438\u0442\u044c \u0441\u0433\u0440\u0443\u043f\u043f\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043f\u0438\u043d\u0433\u0432\u0438\u043d\u043e\u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u0432\u0438\u0434\u043e\u0432 \u0438 \u0441\u0440\u0435\u0434\u043d\u0438\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f \u043c\u0430\u0441\u0441\u044b, \u0434\u043b\u0438\u043d \u043f\u043b\u0430\u0432\u043d\u0438\u043a\u043e\u0432 \u0438 \u043a\u043b\u044e\u0432\u0430 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0432\u0438\u0434\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">species_stat=(penguins              .groupby('species')              .agg(penguins_count=('species','count'),                   mean_bill_length=('bill_length_mm', 'mean'),                   mean_bill_depth=('bill_depth_mm', 'mean'),                   mean_flipper_length=('flipper_length_mm', 'mean'),                   mean_body_mass=('body_mass_g', 'mean'),                  )              )<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/k4\/dj\/np\/k4djnpxtehcr2m0kdbvzp30zf5m.png\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p>\u041e \u0442\u0440\u0435\u0445 \u0432\u0438\u0434\u0430\u0445 \u043f\u0438\u043d\u0433\u0432\u0438\u043d\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0432\u044b\u0432\u043e\u0434\u044b \u0438 \u043f\u043e \u044d\u0442\u043e\u0439 \u0442\u0430\u0431\u043b\u0438\u0446\u0435, \u043d\u043e \u0435\u0441\u043b\u0438 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u0441\u044f \u0447\u0443\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0435, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u0441\u0440\u0430\u0437\u0443 \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0447\u0435\u043c-\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u043c, \u0447\u0435\u043c \u0440\u0430\u0437\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u0442\u044c \u0440\u044f\u0434\u044b \u0447\u0438\u0441\u0435\u043b.<\/p>\n<p>  <\/p>\n<p>\u0418\u0441\u043f\u0440\u0430\u0432\u0438\u043c \u044d\u0442\u043e. \u041f\u043e\u0442\u043e\u043c\u0443 \u0447\u0442\u043e, \u043d\u0443 \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u0435\u0435 \u0438 \u0432\u0435\u0441\u0435\u043b\u0435\u0435 \u0440\u0430\u0437\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u043d\u0438\u044f \u0447\u0438\u0441\u0435\u043b?! \u0418 \u0435\u0441\u043b\u0438 \u0432\u044b \u0434\u0443\u043c\u0430\u0435\u0442\u0435 \u043f\u043e-\u0434\u0440\u0443\u0433\u043e\u043c\u0443, \u044f \u043d\u0435 \u0437\u043d\u0430\u044e, \u0437\u0430\u0447\u0435\u043c \u0432\u044b \u0434\u043e\u0447\u0438\u0442\u0430\u043b\u0438 \u0434\u043e \u044d\u0442\u043e\u0433\u043e \u043c\u043e\u043c\u0435\u043d\u0442\u0430.<\/p>\n<p>  <\/p>\n<pre><code class=\"python\">(species_stat  .T  .style  .format(&quot;{:.1f}&quot;)  .background_gradient(cmap='Blues', axis=1) )<\/code><\/pre>\n<p>  <\/p>\n<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/webt\/ae\/bp\/ge\/aebpgea1p3odnwzfw2uxxx2onxc.png\" alt=\"image\"\/><\/p>\n<p>  <\/p>\n<p>\u0422\u0440\u0430\u043d\u0441\u043f\u043e\u043d\u0438\u0440\u0443\u0435\u043c \u0442\u0430\u0431\u043b\u0438\u0446\u0443 \u2014 \u0442\u0430\u043a \u043d\u0430\u0433\u043b\u044f\u0434\u043d\u0435\u0435 \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043c\u0435\u0436\u0434\u0443 \u0432\u0438\u0434\u0430\u043c\u0438 \u0438 \u043f\u0440\u0438\u043c\u0435\u043d\u044f\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>background_gradient<\/code> \u0441\u043e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c\u0438 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0446\u0432\u0435\u0442\u043e\u0432\u0430\u044f \u043a\u0430\u0440\u0442\u0430(<code>cmap<\/code>): <code>Blues<\/code>. \u042d\u0442\u043e \u043e\u0434\u043d\u0430 \u0438\u0437 \u0434\u0435\u0444\u043e\u043b\u0442\u043d\u044b\u0445 \u043a\u0430\u0440\u0442;<\/li>\n<li>\u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u0435 \u043f\u043e \u0441\u0442\u0440\u043e\u043a\u0430\u043c (<code>axis=1<\/code>).<\/li>\n<\/ul>\n<p>  <\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434<\/h3>\n<p>  <\/p>\n<p>\u0424\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u0431\u043b\u0438\u0446 \u0432 <code>pandas<\/code> \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <code>DataFrame.style<\/code> \u0438 <code>Options and settings<\/code> \u0443\u043f\u0440\u043e\u0449\u0430\u0435\u0442 \u0436\u0438\u0437\u043d\u044c, \u043d\u0443 \u0438\u043b\u0438 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c \u0443\u043b\u0443\u0447\u0448\u0430\u0435\u0442 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0434\u0430 \u0438 \u043e\u0442\u0447\u0435\u0442\u043e\u0432. \u041d\u043e \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0442\u0438\u043f\u043e\u0432 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0440\u043e\u043f\u0443\u0441\u043a\u043e\u0432 \u0438 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430 \u043b\u0443\u0447\u0448\u0435, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u043e\u0441\u043e\u0437\u043d\u0430\u043d\u043d\u043e \u0435\u0449\u0451 \u0434\u043e \u044d\u0442\u0430\u043f\u0430 \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438.<\/p>\n<p>  <\/p>\n<h3>\u0414\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f \u0441:<\/h3>\n<p>  <\/p>\n<ul>\n<li><a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/style.html#Export-to-Excel\">\u042d\u043a\u0441\u043f\u043e\u0440\u0442\u043e\u043c \u0432 excel<\/a>;<\/li>\n<li><a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/reference\/api\/pandas.io.formats.style.Styler.apply.html\">\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438<\/a> \u0434\u043b\u044f \u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043b\u0438 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>highlight_max<\/code>, <code>highlight_min<\/code> \u0438 <code>highlight_null<\/code>, \u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u0435\u0435 \u0438\u0437\u043e\u0449\u0440\u0451\u043d\u043d\u044b\u0445 \u0443\u0441\u043b\u043e\u0432\u0438\u0439 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u044e;<\/li>\n<li>\u0422\u0430\u043a\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438 \u043a\u0430\u043a <a href=\"https:\/\/pypi.org\/project\/sparklines\/\"><code>sparklines<\/code><\/a> \u0438 <a href=\"https:\/\/prettypandas.readthedocs.io\/en\/latest\/\"><code>PrettyPandas<\/code><\/a>.<\/li>\n<\/ul>\n<\/div>\n<p> \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\/post\/521894\/\"> https:\/\/habr.com\/ru\/post\/521894\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html post__text_v1\" id=\"post-content-body\" data-io-article-url=\"https:\/\/habr.com\/ru\/post\/521894\/\">\n<p>\u0415\u0441\u043b\u0438 \u0432\u044b \u043f\u043e\u043a\u0430 \u0435\u0449\u0451 \u043d\u0435 \u0437\u043d\u0430\u0435\u0442\u0435 \u043a\u0430\u043a \u0442\u0440\u0430\u043d\u0441\u043b\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u043a\u0430\u0437\u0447\u0438\u043a\u0443 \u0432 \u043f\u043e\u0434\u0441\u043e\u0437\u043d\u0430\u043d\u0438\u0435 \u0438\u043b\u0438, \u043d\u0430 \u0445\u0443\u0434\u043e\u0439 \u043a\u043e\u043d\u0435\u0446, \u0442\u0435\u043a\u0441\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f \u0432 slack, \u0432\u0430\u043c \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0442\u043e\u043c, \u043a\u0430\u043a \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0442\u0435\u0440\u043f\u0440\u0435\u0442\u0430\u0446\u0438\u0438 \u0442\u0430\u0431\u043b\u0438\u0446 \u0431\u043e\u043b\u0435\u0435 \u0431\u044b\u0441\u0442\u0440\u044b\u043c \u0438 \u043a\u043e\u043c\u0444\u043e\u0440\u0442\u043d\u044b\u043c.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0432 excel \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/use-conditional-formatting-to-highlight-information-fed60dfa-1d3f-4e13-9ecb-f1951ff89d7f\">\u0443\u0441\u043b\u043e\u0432\u043d\u043e\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/a> \u0438 <a href=\"https:\/\/support.microsoft.com\/en-us\/office\/analyze-trends-in-data-using-sparklines-be6579cf-a8e3-471a-a459-873614413ce1\">\u0441\u043f\u0430\u0440\u043a\u043b\u0430\u0439\u043d\u044b<\/a>. \u0410 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043c\u044b \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u043a\u0430\u043a \u0432\u0438\u0437\u0443\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e Python \u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 <code>pandas<\/code>: \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/style.html\"><code>DataFrame.style<\/code><\/a> \u0438 <a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/options.html\"><code>Options and settings<\/code><\/a>.<\/p>\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-310912","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310912","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=310912"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/310912\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=310912"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=310912"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=310912"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}