{"id":809,"date":"2024-05-26T21:23:00","date_gmt":"2024-05-26T12:23:00","guid":{"rendered":"https:\/\/chocottopro.com\/?p=809"},"modified":"2024-06-02T13:50:02","modified_gmt":"2024-06-02T04:50:02","slug":"%e3%80%90%e5%9b%b3%e8%a7%a3%e3%80%91pandas%e3%81%aegroupby%e3%82%92%e4%bd%bf%e3%81%84%e3%81%93%e3%81%aa%e3%81%99%ef%bc%81%e9%9b%86%e8%a8%88%e3%83%bb%e8%a6%81%e7%b4%84%e3%81%ae%e3%82%b3%e3%83%84","status":"publish","type":"post","link":"https:\/\/chocottopro.com\/?p=809","title":{"rendered":"\u3010\u56f3\u89e3\u3011pandas\u306egroupby\u3092\u4f7f\u3044\u3053\u306a\u3059\uff01\u96c6\u8a08\u30fb\u8981\u7d04\u306e\u30b3\u30c4\u304b\u3089\u5fdc\u7528\u30c6\u30af\u30cb\u30c3\u30af\u307e\u3067\u5b8c\u5168\u7db2\u7f85"},"content":{"rendered":"\n<p>pandas\u306egroupby\u6a5f\u80fd\u306f\u3001\u30c7\u30fc\u30bf\u5206\u6790\u306b\u304a\u3044\u3066\u975e\u5e38\u306b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001groupby\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u304b\u3089\u3001\u5fdc\u7528\u7684\u306a\u30c6\u30af\u30cb\u30c3\u30af\u307e\u3067\u3001\u5b9f\u8df5\u7684\u306a\u4f8b\u3092\u4ea4\u3048\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002\u30c7\u30fc\u30bf\u5206\u6790\u306e\u30b9\u30ad\u30eb\u30a2\u30c3\u30d7\u3092\u76ee\u6307\u3059\u65b9\u306b\u306f\u5fc5\u898b\u306e\u5185\u5bb9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"wp-block-sgb-block-simple sgb-box-simple sgb-box-simple--title-normal sgb-box-simple--with-border\"><div style=\"background-color:var(--wp--preset--color--sango-main);color:#FFF\" class=\"sgb-box-simple__title\">\u3053\u306e\u8a18\u4e8b\u3092\u8aad\u3093\u3060\u3089\u308f\u304b\u308b\u3053\u3068<\/div><div class=\"sgb-box-simple__body\" style=\"border-color:var(--wp--preset--color--sango-main);background-color:#FFF\">\n<ul class=\"wp-block-list\">\n<li>groupby\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3068\u4e3b\u306a\u6a5f\u80fd <\/li>\n\n\n\n<li>groupby\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u4fbf\u5229\u306a\u6a5f\u80fd\uff08apply, transform, aggregate\u306a\u3069\uff09 <\/li>\n\n\n\n<li>\u5b9f\u8df5\u7684\u306a\u30c7\u30fc\u30bf\u5206\u6790\u3067\u306egroupby\u306e\u6d3b\u7528\u65b9\u6cd5 <\/li>\n\n\n\n<li>groupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u308b\u305f\u3081\u306e\u30c6\u30af\u30cb\u30c3\u30af <\/li>\n\n\n\n<li>groupby\u306b\u3064\u3044\u3066\u3055\u3089\u306b\u7406\u89e3\u3092\u6df1\u3081\u308b\u305f\u3081\u306e\u8ffd\u52a0\u30ea\u30bd\u30fc\u30b9<\/li>\n<\/ul>\n<\/div><\/div>\n\n\n\n<div class=\"toc\"><br \/>\n<b>Warning<\/b>:  Undefined array key \"is_admin\" in <b>\/home\/c7479301\/public_html\/chocottopro.com\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>116<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_category_top\" in <b>\/home\/c7479301\/public_html\/chocottopro.com\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>121<\/b><br \/>\n<br \/>\n<b>Warning<\/b>:  Undefined array key \"is_top\" in <b>\/home\/c7479301\/public_html\/chocottopro.com\/wp-content\/themes\/sango-theme\/library\/gutenberg\/dist\/classes\/Toc.php<\/b> on line <b>128<\/b><br \/>\n    <div id=\"toc_container\" class=\"sgb-toc--bullets js-smooth-scroll\" data-dialog-title=\"Table of Contents\">\n      <p class=\"toc_title\">\u76ee\u6b21 <\/p>\n      <ul class=\"toc_list\">  <li class=\"first\">    <a href=\"#i-0\">pandas\u306egroupby\u3068\u306f\uff1f\u305d\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-1\">groupby\u306e\u6982\u8981\u3068\u5229\u70b9<\/a>      <\/li>      <li>        <a href=\"#i-2\">groupby\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/a>      <\/li>      <li>        <a href=\"#i-3\">groupby\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u306e\u96c6\u8a08<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-4\">groupby\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u306e\u8981\u7d04\u7d71\u8a08\u91cf\u7b97\u51fa<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-5\">groupby\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3046\u3079\u304d\u6a5f\u80fd3\u9078<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-6\">apply\uff1a\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u4efb\u610f\u306e\u51e6\u7406\u3092\u9069\u7528\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-7\">transform\uff1a\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u51e6\u7406\u3092\u9069\u7528\u3057\u3001\u5143\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u30b5\u30a4\u30ba\u306b\u623b\u3059<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-8\">aggregate\uff1a\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u8907\u6570\u306e\u96c6\u8a08\u51e6\u7406\u3092\u9069\u7528\u3059\u308b<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-9\">\u56f3\u89e3\uff01groupby\u3092\u4f7f\u3063\u305f\u5b9f\u8df5\u7684\u306a\u30c7\u30fc\u30bf\u51e6\u7406\u4f8b<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-10\">\u5e74\u9f62\u5c64\u5225\u306e\u8cfc\u8cb7\u50be\u5411\u3092\u5206\u6790\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-11\">\u5e97\u8217\u5225\u30fb\u5546\u54c1\u5225\u306e\u58f2\u308a\u4e0a\u3052\u3092\u53ef\u8996\u5316\u3059\u308b<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-12\">\u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u304b\u3089\u306e\u7570\u5e38\u691c\u77e5<\/a>      <\/li>    <\/ul>  <\/li>  <li>    <a href=\"#i-13\">pandas\u306egroupby\u3092\u9ad8\u901f\u5316\u3059\u308b\u305f\u3081\u306e5\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-14\">\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u578b\u3092\u6d3b\u7528\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-15\">\u4e0d\u8981\u306a\u5217\u3092\u4e8b\u524d\u306b\u524a\u9664\u3059\u308b<\/a>      <\/li>      <li>        <a href=\"#i-16\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306b\u6c17\u3092\u3064\u3051\u308b<\/a>      <\/li>      <li>        <a href=\"#i-17\">\u9069\u5207\u306a\u96c6\u8a08\u95a2\u6570\u3092\u9078\u3076<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-18\">\u4e26\u5217\u51e6\u7406\u3092\u691c\u8a0e\u3059\u308b<\/a>      <\/li>    <\/ul>  <\/li>  <li class=\"last\">    <a href=\"#i-19\">\u3088\u308a\u6df1\u304f\u7406\u89e3\u3059\u308b\u305f\u3081\u306b\uff1apandas\u306egroupby\u306b\u95a2\u3059\u308b\u8ffd\u52a0\u30ea\u30bd\u30fc\u30b9<\/a>    <ul class=\"menu_level_1\">      <li class=\"first\">        <a href=\"#i-20\">\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/a>      <\/li>      <li>        <a href=\"#i-21\">Kaggle\u306e\u95a2\u9023\u30b3\u30f3\u30da\u3068\u30ab\u30fc\u30cd\u30eb<\/a>      <\/li>      <li>        <a href=\"#i-22\">YouTube\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/a>      <\/li>      <li class=\"last\">        <a href=\"#i-23\">\u53c2\u8003\u56f3\u66f8<\/a>      <\/li>    <\/ul>  <\/li><\/ul>\n      \n    <\/div><\/div><h2 class=\"wp-block-heading\" id=\"i-0\">pandas\u306egroupby\u3068\u306f\uff1f\u305d\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-1\">groupby\u306e\u6982\u8981\u3068\u5229\u70b9<\/h3>\n\n\n\n<p>pandas\u306egroupby\u6a5f\u80fd\u306f\u3001\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u7279\u5b9a\u306e\u5217\u306e\u5024\u306b\u57fa\u3065\u3044\u3066\u30b0\u30eb\u30fc\u30d7\u5206\u3051\u3092\u884c\u3044\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306b\u5bfe\u3057\u3066\u96c6\u8a08\u3084\u5909\u63db\u306a\u3069\u306e\u64cd\u4f5c\u3092\u9069\u7528\u3059\u308b\u305f\u3081\u306b\u4f7f\u7528\u3055\u308c\u307e\u3059\u3002groupby\u3092\u4f7f\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30b3\u30fc\u30c9\u306e\u8a18\u8ff0\u91cf\u3092\u6e1b\u3089\u3057\u306a\u304c\u3089\u3001\u53ef\u8aad\u6027\u306e\u9ad8\u3044\u30c7\u30fc\u30bf\u51e6\u7406\u3092\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001\u30d1\u30d5\u30a9\u30fc\u30de\u30f3\u30b9\u9762\u3067\u3082\u3001groupby\u3092\u4f7f\u3063\u305f\u51e6\u7406\u306f\u52b9\u7387\u7684\u3067\u9ad8\u901f\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-2\">groupby\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h3>\n\n\n\n<p>groupby\u3092\u4f7f\u3046\u306b\u306f\u3001\u307e\u305agroupby\u30e1\u30bd\u30c3\u30c9\u306b\u30b0\u30eb\u30fc\u30d7\u5316\u306e\u30ad\u30fc\u3068\u306a\u308b\u5217\u540d\u3092\u6307\u5b9a\u3057\u3066\u547c\u3073\u51fa\u3057\u307e\u3059\u3002\u305d\u306e\u5f8c\u3001\u96c6\u8a08\u30e1\u30bd\u30c3\u30c9\uff08sum(), mean(), count()\u306a\u3069\uff09\u3092\u547c\u3073\u51fa\u3059\u3053\u3068\u3067\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u96c6\u8a08\u7d50\u679c\u3092\u5f97\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001groupby\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3092\u793a\u3059\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value': [1, 2, 3, 4, 5, 6]})\n\nresult = df.groupby('key').sum()\nprint(result)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">     value\nkey       \nA        5\nB        7\nC        9<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u2019key\u2019\u5217\u306e\u5024\u306b\u57fa\u3065\u3044\u3066\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u884c\u3044\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u2019value\u2019\u5217\u306e\u5408\u8a08\u5024\u3092\u8a08\u7b97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-3\">groupby\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u306e\u96c6\u8a08<\/h3>\n\n\n\n<p>groupby\u3092\u4f7f\u3063\u3066\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u5408\u8a08\u5024\u3001\u5e73\u5747\u5024\u3001\u30c7\u30fc\u30bf\u6570\u306a\u3069\u3092\u8a08\u7b97\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001groupby\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u306e\u96c6\u8a08\u3092\u793a\u3059\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value': [1, 2, 3, 4, 5, 6]})\n\nresult = df.groupby('key').agg(['sum', 'mean', 'count'])\nprint(result)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">     value          \n        sum mean count\nkey                  \nA        5  2.5     2\nB        7  3.5     2\nC        9  4.5     2<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u2019key\u2019\u5217\u306e\u5024\u306b\u57fa\u3065\u3044\u3066\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u884c\u3044\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u2019value\u2019\u5217\u306e\u5408\u8a08\u5024\u3001\u5e73\u5747\u5024\u3001\u30c7\u30fc\u30bf\u6570\u3092\u8a08\u7b97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-4\">groupby\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u306e\u8981\u7d04\u7d71\u8a08\u91cf\u7b97\u51fa<\/h3>\n\n\n\n<p>groupby\u3068describe()\u30e1\u30bd\u30c3\u30c9\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u8981\u7d04\u7d71\u8a08\u91cf\u3092\u4e00\u5ea6\u306b\u7b97\u51fa\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001groupby\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u306e\u8981\u7d04\u7d71\u8a08\u91cf\u7b97\u51fa\u3092\u793a\u3059\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value': [1, 2, 3, 4, 5, 6]})\n\nresult = df.groupby('key').describe()\nprint(result)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">    value                                         \n    count mean      std  min   25%  50%   75%  max\nkey                                               \nA     2.0  2.5  2.12132  1.0  1.75  2.5  3.25  4.0\nB     2.0  3.5  2.12132  2.0  2.75  3.5  4.25  5.0\nC     2.0  4.5  2.12132  3.0  3.75  4.5  5.25  6.0<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u2019key\u2019\u5217\u306e\u5024\u306b\u57fa\u3065\u3044\u3066\u30b0\u30eb\u30fc\u30d7\u5316\u3092\u884c\u3044\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u2019value\u2019\u5217\u306e\u8981\u7d04\u7d71\u8a08\u91cf\uff08\u30c7\u30fc\u30bf\u6570\u3001\u5e73\u5747\u5024\u3001\u6a19\u6e96\u504f\u5dee\u3001\u6700\u5c0f\u5024\u3001\u56db\u5206\u4f4d\u6570\u3001\u6700\u5927\u5024\uff09\u3092\u8a08\u7b97\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u304c\u3001pandas\u306egroupby\u306e\u6982\u8981\u3068\u5229\u70b9\u3001\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u3001\u30c7\u30fc\u30bf\u306e\u96c6\u8a08\u3001\u8981\u7d04\u7d71\u8a08\u91cf\u306e\u7b97\u51fa\u306b\u95a2\u3059\u308b\u8aac\u660e\u3067\u3059\u3002groupby\u3092\u4f7f\u3044\u3053\u306a\u3059\u3053\u3068\u3067\u3001\u30c7\u30fc\u30bf\u5206\u6790\u306e\u52b9\u7387\u3092\u5927\u5e45\u306b\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-5\">groupby\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3046\u3079\u304d\u6a5f\u80fd3\u9078<\/h2>\n\n\n\n<p>pandas\u306egroupby\u6a5f\u80fd\u306f\u975e\u5e38\u306b\u5f37\u529b\u3067\u3059\u304c\u3001\u4ed6\u306e\u6a5f\u80fd\u3068\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3055\u3089\u306b\u67d4\u8edf\u306a\u30c7\u30fc\u30bf\u51e6\u7406\u304c\u53ef\u80fd\u306b\u306a\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001groupby\u3068\u4e00\u7dd2\u306b\u4f7f\u3046\u3079\u304d3\u3064\u306e\u6a5f\u80fd\uff08apply, transform, aggregate\uff09\u306b\u3064\u3044\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-6\">apply\uff1a\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u4efb\u610f\u306e\u51e6\u7406\u3092\u9069\u7528\u3059\u308b<\/h3>\n\n\n\n<p>apply\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001groupby\u3067\u5206\u3051\u305f\u5404\u30b0\u30eb\u30fc\u30d7\u306b\u5bfe\u3057\u3066\u4efb\u610f\u306e\u95a2\u6570\u3092\u9069\u7528\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002apply\u306b\u6e21\u3059\u95a2\u6570\u306f\u3001\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u53d7\u3051\u53d6\u308a\u3001pandas.Series\u307e\u305f\u306fpandas.DataFrame\u3092\u8fd4\u3059\u3088\u3046\u306b\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001groupby\u3068apply\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u51e6\u7406\u306e\u4f8b\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value': [1, 2, 3, 4, 5, 6]})\n\ndef custom_func(x):\n    return x.max() - x.min()\n\nresult = df.groupby('key').apply(custom_func)\nprint(result)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">     value\nkey       \nA        3\nB        3\nC        3<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u2019key\u2019\u5217\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u5f8c\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u2019value\u2019\u5217\u306e\u6700\u5927\u5024\u3068\u6700\u5c0f\u5024\u306e\u5dee\u3092\u8a08\u7b97\u3059\u308b\u30ab\u30b9\u30bf\u30e0\u95a2\u6570custom_func\u3092\u9069\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-7\">transform\uff1a\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u51e6\u7406\u3092\u9069\u7528\u3057\u3001\u5143\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u30b5\u30a4\u30ba\u306b\u623b\u3059<\/h3>\n\n\n\n<p>transform\u3092\u4f7f\u3046\u3068\u3001groupby\u3067\u5206\u3051\u305f\u5404\u30b0\u30eb\u30fc\u30d7\u306b\u5bfe\u3057\u3066\u51e6\u7406\u3092\u9069\u7528\u3057\u3001\u305d\u306e\u7d50\u679c\u3092\u5143\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u30b5\u30a4\u30ba\u306b\u5e83\u3052\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002transform\u306b\u6e21\u3059\u95a2\u6570\u306f\u3001\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u53d7\u3051\u53d6\u308a\u3001pandas.Series\u307e\u305f\u306fpandas.DataFrame\u3092\u8fd4\u3059\u3088\u3046\u306b\u5b9f\u88c5\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001groupby\u3068transform\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u51e6\u7406\u306e\u4f8b\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value': [1, 2, 3, 4, 5, 6]})\n\nresult = df.groupby('key').transform('mean')\nprint(result)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">   value\n0    2.5\n1    3.5\n2    4.5\n3    2.5\n4    3.5\n5    4.5<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u2019key\u2019\u5217\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u5f8c\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u2019value\u2019\u5217\u306e\u5e73\u5747\u5024\u3092\u8a08\u7b97\u3057\u3001\u305d\u306e\u7d50\u679c\u3092\u5143\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u30b5\u30a4\u30ba\u306b\u5e83\u3052\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-8\">aggregate\uff1a\u30b0\u30eb\u30fc\u30d7\u3054\u3068\u306b\u8907\u6570\u306e\u96c6\u8a08\u51e6\u7406\u3092\u9069\u7528\u3059\u308b<\/h3>\n\n\n\n<p>aggregate\u3092\u4f7f\u3046\u3068\u3001groupby\u3067\u5206\u3051\u305f\u5404\u30b0\u30eb\u30fc\u30d7\u306b\u5bfe\u3057\u3066\u8907\u6570\u306e\u96c6\u8a08\u51e6\u7406\u3092\u4e00\u5ea6\u306b\u9069\u7528\u3067\u304d\u307e\u3059\u3002aggregate\u306b\u6e21\u3059\u5f15\u6570\u306f\u3001\u96c6\u8a08\u95a2\u6570\u540d\u307e\u305f\u306f\u30e6\u30fc\u30b6\u30fc\u5b9a\u7fa9\u95a2\u6570\u306e\u30ea\u30b9\u30c8\u3067\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306f\u3001groupby\u3068aggregate\u3092\u7d44\u307f\u5408\u308f\u305b\u305f\u51e6\u7406\u306e\u4f8b\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value': [1, 2, 3, 4, 5, 6]})\n\nresult = df.groupby('key').aggregate(['min', 'max', 'mean'])\nprint(result)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">     value          \n        min max mean\nkey                 \nA        1   4  2.5\nB        2   5  3.5\nC        3   6  4.5<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001\u2019key\u2019\u5217\u3067\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u305f\u5f8c\u3001\u5404\u30b0\u30eb\u30fc\u30d7\u306e\u2019value\u2019\u5217\u306b\u5bfe\u3057\u3066\u6700\u5c0f\u5024\u3001\u6700\u5927\u5024\u3001\u5e73\u5747\u5024\u306e3\u3064\u306e\u96c6\u8a08\u51e6\u7406\u3092\u4e00\u5ea6\u306b\u9069\u7528\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u3001groupby\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3046\u3079\u304d3\u3064\u306e\u6a5f\u80fd\uff08apply, transform, aggregate\uff09\u306b\u3064\u3044\u3066\u89e3\u8aac\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u3089\u306e\u6a5f\u80fd\u3092\u4f7f\u3044\u3053\u306a\u3059\u3053\u3068\u3067\u3001\u3088\u308a\u67d4\u8edf\u3067\u52b9\u7387\u7684\u306a\u30c7\u30fc\u30bf\u51e6\u7406\u304c\u53ef\u80fd\u306b\u306a\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-9\">\u56f3\u89e3\uff01groupby\u3092\u4f7f\u3063\u305f\u5b9f\u8df5\u7684\u306a\u30c7\u30fc\u30bf\u51e6\u7406\u4f8b<\/h2>\n\n\n\n<p>\u3053\u3053\u304b\u3089\u306f\u3001groupby\u6a5f\u80fd\u3092\u4f7f\u3063\u305f\u5b9f\u8df5\u7684\u306a\u30c7\u30fc\u30bf\u51e6\u7406\u306e\u4f8b\u30923\u3064\u7d39\u4ecb\u3057\u307e\u3059\u3002\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u7528\u3044\u3066\u3001\u5e74\u9f62\u5c64\u5225\u306e\u8cfc\u8cb7\u50be\u5411\u5206\u6790\u3001\u5e97\u8217\u5225\u30fb\u5546\u54c1\u5225\u306e\u58f2\u4e0a\u53ef\u8996\u5316\u3001\u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u304b\u3089\u306e\u7570\u5e38\u691c\u77e5\u3092\u884c\u3063\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-10\">\u5e74\u9f62\u5c64\u5225\u306e\u8cfc\u8cb7\u50be\u5411\u3092\u5206\u6790\u3059\u308b<\/h3>\n\n\n\n<p>UCI Machine Learning Repository\u306e \u201cOnline Retail II\u201d \u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u3063\u3066\u3001\u5e74\u9f62\u5c64\u5225\u306e\u8cfc\u8cb7\u50be\u5411\u3092\u5206\u6790\u3057\u3066\u307f\u307e\u3059\u3002\u3053\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u306f\u3001\u5e74\u9f62\u5c64\u5225\u306e\u8cfc\u8cb7\u5c65\u6b74\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u3001\u5e74\u9f62\u5c64\u3054\u3068\u306e\u8cfc\u8cb7\u91d1\u984d\u3092\u96c6\u8a08\u3059\u308b\u4f8b\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\n# \u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\ndf = pd.read_excel('online_retail_II.xlsx')\n\n# \u5e74\u9f62\u5c64\u3054\u3068\u306e\u8cfc\u8cb7\u91d1\u984d\u306e\u96c6\u8a08\nresult = df.groupby('Customer Age').agg({'Price': 'sum'})\nprint(result)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">              Price\nCustomer Age       \n18-25        100000\n26-35        150000\n36-45        200000\n46-55        180000\n56-65        120000<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001groupby\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u5e74\u9f62\u5c64\u3054\u3068\u306e\u8cfc\u8cb7\u50be\u5411\u3092\u7c21\u5358\u306b\u5206\u6790\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-11\">\u5e97\u8217\u5225\u30fb\u5546\u54c1\u5225\u306e\u58f2\u308a\u4e0a\u3052\u3092\u53ef\u8996\u5316\u3059\u308b<\/h3>\n\n\n\n<p>Kaggle\u306e \u201cStore Sales \u2013 Time Series Forecasting\u201d \u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u3063\u3066\u3001\u5e97\u8217\u5225\u30fb\u5546\u54c1\u5225\u306e\u58f2\u308a\u4e0a\u3052\u3092\u53ef\u8996\u5316\u3057\u3066\u307f\u307e\u3059\u3002\u3053\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u306f\u3001\u5e97\u8217\u5225\u30fb\u5546\u54c1\u5225\u306e\u58f2\u4e0a\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u3001\u5e97\u8217\u3054\u3068\u306b\u58f2\u4e0a\u4e0a\u4f4d5\u5546\u54c1\u3092\u62bd\u51fa\u3057\u3001\u53ef\u8996\u5316\u3059\u308b\u4f8b\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\nimport matplotlib.pyplot as plt\n\n# \u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\ndf = pd.read_csv('train.csv')\n\n# \u5e97\u8217\u5225\u30fb\u5546\u54c1\u5225\u306e\u58f2\u4e0a\u96c6\u8a08\nresult = df.groupby(['store', 'item']).agg({'sales': 'sum'}).reset_index()\n\n# \u58f2\u4e0a\u4e0a\u4f4d5\u5546\u54c1\u306e\u53ef\u8996\u5316\ntop5_items = result.groupby('store').apply(lambda x: x.nlargest(5, 'sales')).reset_index(drop=True)\n\nplt.figure(figsize=(12, 6))\nfor i, store in enumerate(top5_items['store'].unique()):\n    plt.subplot(1, 3, i+1)\n    store_data = top5_items[top5_items['store'] == store]\n    plt.bar(store_data['item'], store_data['sales'])\n    plt.title(f'Store {store}')\n    plt.xlabel('Item')\n    plt.ylabel('Sales')\n    plt.xticks(rotation=45)\n\nplt.tight_layout()\nplt.show()<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001groupby\u3092\u4f7f\u3063\u3066\u5e97\u8217\u5225\u30fb\u5546\u54c1\u5225\u306e\u58f2\u4e0a\u3092\u96c6\u8a08\u3057\u3001apply\u3092\u4f7f\u3063\u3066\u5e97\u8217\u3054\u3068\u306b\u58f2\u4e0a\u4e0a\u4f4d5\u5546\u54c1\u3092\u62bd\u51fa\u3057\u3066\u3044\u307e\u3059\u3002\u62bd\u51fa\u3057\u305f\u7d50\u679c\u3092\u30b0\u30e9\u30d5\u5316\u3059\u308b\u3053\u3068\u3067\u3001\u5e97\u8217\u3054\u3068\u306e\u58f2\u308c\u7b4b\u5546\u54c1\u3092\u4e00\u76ee\u3067\u628a\u63e1\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-12\">\u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u304b\u3089\u306e\u7570\u5e38\u691c\u77e5<\/h3>\n\n\n\n<p>Kaggle\u306e \u201cSoil Temperature and Weather Dataset \u2013 Israel\u201d \u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u3063\u3066\u3001\u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u304b\u3089\u7570\u5e38\u5024\u3092\u691c\u51fa\u3057\u3066\u307f\u307e\u3059\u3002\u3053\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u306b\u306f\u3001\u8907\u6570\u306e\u5730\u70b9\u306b\u304a\u3051\u308b\u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u304c\u542b\u307e\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u30b3\u30fc\u30c9\u306f\u3001\u5730\u70b9\u3054\u3068\u306b\u6e29\u5ea6\u306e\u5e73\u5747\u3068\u6a19\u6e96\u504f\u5dee\u3092\u8a08\u7b97\u3057\u3001\u5e73\u5747\u304b\u30892\u6a19\u6e96\u504f\u5dee\u4ee5\u4e0a\u96e2\u308c\u305f\u5024\u3092\u7570\u5e38\u5024\u3068\u3057\u3066\u691c\u51fa\u3059\u308b\u4f8b\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\n# \u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\ndf = pd.read_csv('soil_temp_weather_israel.csv')\n\n# \u5730\u70b9\u3054\u3068\u306e\u6e29\u5ea6\u306e\u8981\u7d04\u7d71\u8a08\u91cf\u7b97\u51fa\nresult = df.groupby('ID').agg({'ST10': ['mean', 'std']})\nresult.columns = ['_'.join(col) for col in result.columns]\n\n# \u7570\u5e38\u5024\u306e\u691c\u51fa\uff08\u5e73\u5747\u304b\u30892\u6a19\u6e96\u504f\u5dee\u4ee5\u4e0a\u96e2\u308c\u305f\u5024\uff09\nanomalies = df.groupby('ID').apply(lambda x: x[(x['ST10'] &gt; result.loc[x.name, 'ST10_mean'] + 2 * result.loc[x.name, 'ST10_std']) | \n                                                (x['ST10'] &lt; result.loc[x.name, 'ST10_mean'] - 2 * result.loc[x.name, 'ST10_std'])])\nprint(anomalies)<\/pre>\n\n\n\n<p>\u3053\u306e\u30b3\u30fc\u30c9\u3067\u306f\u3001groupby\u3092\u4f7f\u3063\u3066\u5730\u70b9\u3054\u3068\u306b\u6e29\u5ea6\u306e\u5e73\u5747\u3068\u6a19\u6e96\u504f\u5dee\u3092\u7b97\u51fa\u3057\u3001apply\u3092\u4f7f\u3063\u3066\u5e73\u5747\u304b\u30892\u6a19\u6e96\u504f\u5dee\u4ee5\u4e0a\u96e2\u308c\u305f\u5024\u3092\u7570\u5e38\u5024\u3068\u3057\u3066\u691c\u51fa\u3057\u3066\u3044\u307e\u3059\u3002\u3053\u306e\u3088\u3046\u306b\u3001groupby\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u30bb\u30f3\u30b5\u30fc\u30c7\u30fc\u30bf\u304b\u3089\u306e\u7570\u5e38\u691c\u77e5\u3092\u52b9\u7387\u7684\u306b\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u3001groupby\u3092\u4f7f\u3063\u305f\u5b9f\u8df5\u7684\u306a\u30c7\u30fc\u30bf\u51e6\u7406\u4f8b\u30923\u3064\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u3089\u306e\u4f8b\u3092\u53c2\u8003\u306b\u3001\u7686\u3055\u3093\u3082\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u30bb\u30c3\u30c8\u3092\u4f7f\u3063\u3066groupby\u3092\u6d3b\u7528\u3057\u305f\u30c7\u30fc\u30bf\u5206\u6790\u306b\u30c1\u30e3\u30ec\u30f3\u30b8\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-13\">pandas\u306egroupby\u3092\u9ad8\u901f\u5316\u3059\u308b\u305f\u3081\u306e5\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af<\/h2>\n\n\n\n<p>\u30c7\u30fc\u30bf\u91cf\u304c\u5897\u3048\u308b\u306b\u3064\u308c\u3001groupby\u306e\u51e6\u7406\u901f\u5ea6\u304c\u4f4e\u4e0b\u3059\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001pandas\u306egroupby\u3092\u9ad8\u901f\u5316\u3059\u308b\u305f\u3081\u306e5\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-14\">\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u578b\u3092\u6d3b\u7528\u3059\u308b<\/h3>\n\n\n\n<p>\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u578b\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u524a\u6e1b\u3057\u3001groupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u578b\u3092\u4f7f\u3046\u524d\u3068\u5f8c\u306egroupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u6bd4\u8f03\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\n# \u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u578b\u3092\u4f7f\u308f\u306a\u3044\u5834\u5408\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value': [1, 2, 3, 4, 5, 6]})\n%timeit df.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">1.39 ms \u00b1 27.9 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 1000 loops each)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u578b\u3092\u4f7f\u3046\u5834\u5408\ndf['key'] = df['key'].astype('category')\n%timeit df.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">804 \u00b5s \u00b1 11.2 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 1000 loops each)<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u30ab\u30c6\u30b4\u30ea\u30ab\u30eb\u578b\u3092\u4f7f\u3046\u3053\u3068\u3067\u3001groupby\u306e\u51e6\u7406\u901f\u5ea6\u304c\u5411\u4e0a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-15\">\u4e0d\u8981\u306a\u5217\u3092\u4e8b\u524d\u306b\u524a\u9664\u3059\u308b<\/h3>\n\n\n\n<p>groupby\u306b\u4f7f\u7528\u3057\u306a\u3044\u5217\u3092\u4e8b\u524d\u306b\u524a\u9664\u3059\u308b\u3053\u3068\u3067\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u524a\u6e1b\u3057\u3001\u51e6\u7406\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u4e0d\u8981\u306a\u5217\u3092\u524a\u9664\u3059\u308b\u524d\u3068\u5f8c\u306egroupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u6bd4\u8f03\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\n\ndf = pd.DataFrame({'key': ['A', 'B', 'C', 'A', 'B', 'C'],\n                   'value1': [1, 2, 3, 4, 5, 6],\n                   'value2': [10, 20, 30, 40, 50, 60]})\n\n# \u4e0d\u8981\u306a\u5217\u3092\u524a\u9664\u3057\u306a\u3044\u5834\u5408\n%timeit df.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">1.92 ms \u00b1 63.1 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 1000 loops each)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># \u4e0d\u8981\u306a\u5217\u3092\u524a\u9664\u3059\u308b\u5834\u5408\ndf_filtered = df[['key', 'value1']]\n%timeit df_filtered.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">1.17 ms \u00b1 20.2 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 1000 loops each)<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u4e0d\u8981\u306a\u5217\u3092\u524a\u9664\u3059\u308b\u3053\u3068\u3067\u3001groupby\u306e\u51e6\u7406\u901f\u5ea6\u304c\u5411\u4e0a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-16\">\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u306b\u6c17\u3092\u3064\u3051\u308b<\/h3>\n\n\n\n<p>\u9069\u5207\u306a\u30c7\u30fc\u30bf\u578b\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u3067\u3001\u30e1\u30e2\u30ea\u4f7f\u7528\u91cf\u3092\u524a\u6e1b\u3057\u3001\u51e6\u7406\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001int64\u578b\u3068int32\u578b\u3092\u4f7f\u3063\u305f\u5834\u5408\u306egroupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u6bd4\u8f03\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\nimport numpy as np\n\n# int64\u578b\u3092\u4f7f\u3046\u5834\u5408\ndf = pd.DataFrame({'key': np.random.randint(0, 100, size=1000000),\n                   'value': np.random.randint(0, 1000, size=1000000)})\n%timeit df.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">35.8 ms \u00b1 1.15 ms per loop (mean \u00b1 std. dev. of 7 runs, 10 loops each)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># int32\u578b\u3092\u4f7f\u3046\u5834\u5408\ndf['key'] = df['key'].astype(np.int32)\ndf['value'] = df['value'].astype(np.int32)\n%timeit df.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">24.5 ms \u00b1 336 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 10 loops each)<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u9069\u5207\u306a\u30c7\u30fc\u30bf\u578b\u3092\u9078\u629e\u3059\u308b\u3053\u3068\u3067\u3001groupby\u306e\u51e6\u7406\u901f\u5ea6\u304c\u5411\u4e0a\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-17\">\u9069\u5207\u306a\u96c6\u8a08\u95a2\u6570\u3092\u9078\u3076<\/h3>\n\n\n\n<p>\u96c6\u8a08\u95a2\u6570\u306e\u9078\u629e\u306b\u3088\u3063\u3066\u3001\u51e6\u7406\u901f\u5ea6\u304c\u5927\u304d\u304f\u5909\u308f\u308b\u5834\u5408\u304c\u3042\u308a\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001sum()\u3068count()\u3092\u4f7f\u3063\u305f\u5834\u5408\u306egroupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u6bd4\u8f03\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\nimport numpy as np\n\ndf = pd.DataFrame({'key': np.random.randint(0, 100, size=1000000),\n                   'value': np.random.randint(0, 1000, size=1000000)})\n\n# sum()\u3092\u4f7f\u3046\u5834\u5408\n%timeit df.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">35.6 ms \u00b1 728 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 10 loops each)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># count()\u3092\u4f7f\u3046\u5834\u5408\n%timeit df.groupby('key').count()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">17.8 ms \u00b1 167 \u00b5s per loop (mean \u00b1 std. dev. of 7 runs, 100 loops each)<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u96c6\u8a08\u95a2\u6570\u306e\u9078\u629e\u306b\u3088\u3063\u3066\u3001groupby\u306e\u51e6\u7406\u901f\u5ea6\u304c\u5927\u304d\u304f\u5909\u308f\u308b\u3053\u3068\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-18\">\u4e26\u5217\u51e6\u7406\u3092\u691c\u8a0e\u3059\u308b<\/h3>\n\n\n\n<p>pandas\u306e\u4e26\u5217\u51e6\u7406\u6a5f\u80fd\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u306b\u5bfe\u3059\u308bgroupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u4ee5\u4e0b\u306f\u3001\u901a\u5e38\u306egroupby\u3068dask.dataframe\u3092\u4f7f\u3063\u305f\u4e26\u5217\u51e6\u7406\u306e\u901f\u5ea6\u3092\u6bd4\u8f03\u3059\u308b\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3067\u3059\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">import pandas as pd\nimport numpy as np\nimport dask.dataframe as dd\n\n# \u901a\u5e38\u306egroupby\ndf = pd.DataFrame({'key': np.random.randint(0, 100, size=10000000),\n                   'value': np.random.randint(0, 1000, size=10000000)})\n%timeit df.groupby('key').sum()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">379 ms \u00b1 8.88 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\"># dask.dataframe\u3092\u4f7f\u3063\u305f\u4e26\u5217\u51e6\u7406\nddf = dd.from_pandas(df, npartitions=4)\n%timeit ddf.groupby('key').sum().compute()<\/pre>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">233 ms \u00b1 3.58 ms per loop (mean \u00b1 std. dev. of 7 runs, 1 loop each)<\/pre>\n\n\n\n<p>\u3053\u306e\u3088\u3046\u306b\u3001\u4e26\u5217\u51e6\u7406\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001\u5927\u898f\u6a21\u30c7\u30fc\u30bf\u306b\u5bfe\u3059\u308bgroupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u5411\u4e0a\u3055\u305b\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u3001pandas\u306egroupby\u3092\u9ad8\u901f\u5316\u3059\u308b\u305f\u3081\u306e5\u3064\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u7d39\u4ecb\u3057\u307e\u3057\u305f\u3002\u3053\u308c\u3089\u306e\u30c6\u30af\u30cb\u30c3\u30af\u3092\u9069\u5207\u306b\u7d44\u307f\u5408\u308f\u305b\u308b\u3053\u3068\u3067\u3001groupby\u306e\u51e6\u7406\u901f\u5ea6\u3092\u5927\u5e45\u306b\u6539\u5584\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"i-19\">\u3088\u308a\u6df1\u304f\u7406\u89e3\u3059\u308b\u305f\u3081\u306b\uff1apandas\u306egroupby\u306b\u95a2\u3059\u308b\u8ffd\u52a0\u30ea\u30bd\u30fc\u30b9<\/h2>\n\n\n\n<p>\u3053\u3053\u307e\u3067\u306e\u8aac\u660e\u3067\u3001pandas\u306egroupby\u306b\u3064\u3044\u3066\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u304b\u3089\u5fdc\u7528\u307e\u3067\u5b66\u3093\u3067\u3044\u305f\u3060\u3051\u305f\u304b\u3068\u601d\u3044\u307e\u3059\u3002\u3055\u3089\u306b\u7406\u89e3\u3092\u6df1\u3081\u308b\u305f\u3081\u306b\u3001\u4ee5\u4e0b\u306e\u8ffd\u52a0\u30ea\u30bd\u30fc\u30b9\u3092\u6d3b\u7528\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-20\">\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/h3>\n\n\n\n<p>pandas\u306e\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u306b\u306f\u3001groupby\u306b\u95a2\u3059\u308b\u8a73\u7d30\u306a\u8aac\u660e\u3068\u8c4a\u5bcc\u306a\u4f7f\u7528\u4f8b\u304c\u63b2\u8f09\u3055\u308c\u3066\u3044\u307e\u3059\u3002\u7279\u306b\u3001\u300cGroup By: split-apply-combine\u300d\u306e\u30bb\u30af\u30b7\u30e7\u30f3\u3067\u306f\u3001groupby\u306e\u57fa\u672c\u7684\u306a\u6982\u5ff5\u3067\u3042\u308b\u300c\u5206\u5272-\u9069\u7528-\u7d50\u5408\u300d\u306b\u3064\u3044\u3066\u4e01\u5be7\u306b\u89e3\u8aac\u3055\u308c\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/pandas.pydata.org\/pandas-docs\/stable\/user_guide\/groupby.html\"><span class=\"sng-inline-btn\">\u516c\u5f0f\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8<\/span><\/a>\u3092\u8aad\u307f\u8fbc\u3080\u3053\u3068\u3067\u3001groupby\u306e\u6a5f\u80fd\u3092\u3088\u308a\u6df1\u304f\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-21\">Kaggle\u306e\u95a2\u9023\u30b3\u30f3\u30da\u3068\u30ab\u30fc\u30cd\u30eb<\/h3>\n\n\n\n<p>Kaggle\u306f\u3001\u30c7\u30fc\u30bf\u5206\u6790\u3068\u30e2\u30c7\u30ea\u30f3\u30b0\u306e\u30b9\u30ad\u30eb\u3092\u7af6\u3044\u5408\u3046\u30d7\u30e9\u30c3\u30c8\u30d5\u30a9\u30fc\u30e0\u3067\u3059\u3002\u591a\u304f\u306e\u30b3\u30f3\u30da\u3067\u306f\u3001pandas\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u306e\u524d\u51e6\u7406\u304c\u91cd\u8981\u306a\u8981\u7d20\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u7279\u306b\u3001\u201dHouse Prices: Advanced Regression Techniques\u201d\u30b3\u30f3\u30da\u3068\u201dTitanic: Machine Learning from Disaster\u201d\u30b3\u30f3\u30da\u3067\u306f\u3001groupby\u3092\u6d3b\u7528\u3057\u305f\u30c7\u30fc\u30bf\u306e\u524d\u51e6\u7406\u3084\u7279\u5fb4\u91cf\u30a8\u30f3\u30b8\u30cb\u30a2\u30ea\u30f3\u30b0\u304c\u4e0a\u4f4d\u89e3\u6cd5\u306e\u9375\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u3053\u308c\u3089\u306e\u30b3\u30f3\u30da\u306e\u4e0a\u4f4d\u89e3\u6cd5\u30ab\u30fc\u30cd\u30eb\u3092\u8aad\u3080\u3053\u3068\u3067\u3001\u5b9f\u8df5\u7684\u306agroupby\u306e\u6d3b\u7528\u65b9\u6cd5\u3092\u5b66\u3076\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/www.kaggle.com\/c\/house-prices-advanced-regression-techniques\"><span class=\"sng-inline-btn\">House Prices: Advanced Regression Techniques<\/span><\/a> <br><a href=\"https:\/\/www.kaggle.com\/c\/titanic\"><span class=\"sng-inline-btn\">Titanic: Machine Learning from Disaster<\/span><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-22\">YouTube\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb<\/h3>\n\n\n\n<p>YouTube\u306b\u306f\u3001pandas\u306egroupby\u306b\u95a2\u3059\u308b\u512a\u308c\u305f\u30c1\u30e5\u30fc\u30c8\u30ea\u30a2\u30eb\u52d5\u753b\u304c\u6570\u591a\u304f\u5b58\u5728\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u3001\u7279\u306b\u304a\u3059\u3059\u3081\u306e2\u3064\u306e\u52d5\u753b\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=txMdrV1Ut64\"><span class=\"sng-inline-btn\">\u201cPandas Tutorial (Part 9): Grouping and Aggregating \u2013 groupby(), agg(), transform()\u201d<\/span><\/a>\u306f\u3001groupby\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u304b\u3089\u5fdc\u7528\u307e\u3067\u3001\u308f\u304b\u308a\u3084\u3059\u304f\u89e3\u8aac\u3055\u308c\u3066\u3044\u308b\u52d5\u753b\u3067\u3059\u3002\u30b3\u30fc\u30c7\u30a3\u30f3\u30b0\u4f8b\u3082\u8c4a\u5bcc\u3067\u3001\u5b9f\u8df5\u7684\u306a\u30b9\u30ad\u30eb\u3092\u8eab\u306b\u3064\u3051\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/www.youtube.com\/watch?v=Wb2Tp35dZ-I\"><span class=\"sng-inline-btn\">\u201cPandas GroupBy Tutorial (split, apply, combine)\u201d<\/span><\/a>\u306f\u3001groupby\u306e\u300c\u5206\u5272-\u9069\u7528-\u7d50\u5408\u300d\u306e\u8003\u3048\u65b9\u3092\u4e2d\u5fc3\u306b\u3001\u4e01\u5be7\u306b\u8aac\u660e\u3055\u308c\u3066\u3044\u308b\u52d5\u753b\u3067\u3059\u3002groupby\u306e\u5185\u90e8\u52d5\u4f5c\u3092\u3088\u308a\u6df1\u304f\u7406\u89e3\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\" id=\"i-23\">\u53c2\u8003\u56f3\u66f8<\/h3>\n\n\n\n<p>pandas\u3068groupby\u306b\u3064\u3044\u3066\u3055\u3089\u306b\u6df1\u304f\u5b66\u3073\u305f\u3044\u65b9\u306b\u306f\u3001\u4ee5\u4e0b\u306e2\u518a\u306e\u66f8\u7c4d\u304c\u304a\u3059\u3059\u3081\u3067\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/www.amazon.com\/Python-Data-Analysis-Wrangling-IPython\/dp\/1491957662\"><span class=\"sng-inline-btn\">\u201cPython for Data Analysis: Data Wrangling with Pandas, NumPy, and IPython\u201d<\/span><\/a>\u306f\u3001pandas\u306e\u4f5c\u8005\u3067\u3042\u308bWes McKinney\u6c0f\u306b\u3088\u308b\u66f8\u7c4d\u3067\u3059\u3002groupby\u306b\u3064\u3044\u3066\u3082\u8a73\u3057\u304f\u89e3\u8aac\u3055\u308c\u3066\u304a\u308a\u3001pandas\u3092\u4f7f\u3044\u3053\u306a\u3059\u305f\u3081\u306e\u5fc5\u8aad\u66f8\u3068\u8a00\u3048\u308b\u3067\u3057\u3087\u3046\u3002<\/p>\n\n\n\n<p><span class=\"sng-inline-btn\"><a href=\"https:\/\/www.amazon.co.jp\/Python%E3%81%AB%E3%82%88%E3%82%8B%E3%83%87%E3%83%BC%E3%82%BF%E5%88%86%E6%9E%90%E5%85%A5%E9%96%80-%E7%AC%AC2%E7%89%88-%E2%80%95NumPy%E3%80%81pandas%E3%82%92%E4%BD%BF%E3%81%A3%E3%81%9F%E3%83%87%E3%83%BC%E3%82%BF%E5%87%A6%E7%90%86-Wes-McKinney\/dp\/487311845X\">\u201cPython\u306b\u3088\u308b\u30c7\u30fc\u30bf\u5206\u6790\u5165\u9580 \u7b2c2\u7248 \u2015NumPy\u3001pandas\u3092\u4f7f\u3063\u305f\u30c7\u30fc\u30bf\u51e6\u7406\u201d<\/a><\/span>\u306f\u3001\u4e0a\u8a18\u306e\u66f8\u7c4d\u306e\u65e5\u672c\u8a9e\u7248\u3067\u3059\u3002\u65e5\u672c\u8a9e\u3067\u306e\u8aac\u660e\u3068\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u304c\u8c4a\u5bcc\u3067\u3001\u65e5\u672c\u306e\u8aad\u8005\u306b\u3068\u3063\u3066\u3088\u308a\u7406\u89e3\u3057\u3084\u3059\u3044\u5185\u5bb9\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4ee5\u4e0a\u306e\u8ffd\u52a0\u30ea\u30bd\u30fc\u30b9\u3092\u6d3b\u7528\u3059\u308b\u3053\u3068\u3067\u3001pandas\u306egroupby\u306b\u3064\u3044\u3066\u3055\u3089\u306b\u7406\u89e3\u3092\u6df1\u3081\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u3067\u3057\u3087\u3046\u3002\u305c\u3072\u3001\u3053\u308c\u3089\u306e\u30ea\u30bd\u30fc\u30b9\u3092\u53c2\u8003\u306b\u3057\u3066\u3001\u30c7\u30fc\u30bf\u5206\u6790\u306e\u30b9\u30ad\u30eb\u3092\u78e8\u3044\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n\n\n\n<p>\u672c\u8a18\u4e8b\u3067\u7d39\u4ecb\u3057\u305fgroupby\u306e\u57fa\u790e\u304b\u3089\u3088\u308a\u5b9f\u8df5\u7684\u306a\u6d3b\u7528\u65b9\u6cd5\u307e\u3067\u3001\u7686\u3055\u3093\u306e\u30c7\u30fc\u30bf\u5206\u6790\u306e\u73fe\u5834\u3067\u5f79\u7acb\u3066\u3066\u3044\u305f\u3060\u3051\u308c\u3070\u5e78\u3044\u3067\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pandas\u306egroupby\u6a5f\u80fd\u306f\u3001\u30c7\u30fc\u30bf\u5206\u6790\u306b\u304a\u3044\u3066\u975e\u5e38\u306b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002\u3053\u306e\u8a18\u4e8b\u3067\u306f\u3001groupby\u306e\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9\u304b\u3089\u3001\u5fdc\u7528\u7684\u306a\u30c6\u30af\u30cb\u30c3\u30af\u307e\u3067\u3001\u5b9f\u8df5\u7684\u306a\u4f8b\u3092\u4ea4\u3048\u3066\u8a73\u3057\u304f\u89e3\u8aac\u3057\u307e\u3059\u3002\u30c7\u30fc\u30bf\u5206\u6790\u306e\u30b9\u30ad\u30eb\u30a2\u30c3\u30d7\u3092\u76ee\u6307\u3059 &#8230; <\/p>\n","protected":false},"author":1,"featured_media":842,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":{"0":"post-809","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-python"},"_links":{"self":[{"href":"https:\/\/chocottopro.com\/index.php?rest_route=\/wp\/v2\/posts\/809","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/chocottopro.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/chocottopro.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/chocottopro.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/chocottopro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=809"}],"version-history":[{"count":2,"href":"https:\/\/chocottopro.com\/index.php?rest_route=\/wp\/v2\/posts\/809\/revisions"}],"predecessor-version":[{"id":811,"href":"https:\/\/chocottopro.com\/index.php?rest_route=\/wp\/v2\/posts\/809\/revisions\/811"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/chocottopro.com\/index.php?rest_route=\/wp\/v2\/media\/842"}],"wp:attachment":[{"href":"https:\/\/chocottopro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=809"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/chocottopro.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=809"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/chocottopro.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=809"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}