{"id":901,"date":"2019-07-03T00:14:41","date_gmt":"2019-07-02T15:14:41","guid":{"rendered":"https:\/\/mindtech.jp\/?p=901"},"modified":"2019-07-05T00:32:42","modified_gmt":"2019-07-04T15:32:42","slug":"post-901","status":"publish","type":"post","link":"https:\/\/mindtech.jp\/?p=901","title":{"rendered":"\u3010Python\u3011dfply\u3092\u7528\u3044\u305fpandas\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u306e\u30c7\u30fc\u30bf\u62bd\u51fa"},"content":{"rendered":"<p>CSV\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u3067\u7528\u610f\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092pandas\u3067\u53d6\u308a\u8fbc\u3093\u3060\u5f8c\u3001\u7279\u5b9a\u306e\u6761\u4ef6\u306b\u5f53\u3066\u306f\u307e\u308b\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3057\u3066\u96c6\u8a08\u306a\u3069\u3092\u884c\u3044\u305f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u8907\u5408\u6761\u4ef6\u3092\u30b5\u30af\u30b5\u30af\u66f8\u3044\u3066\u8a66\u884c\u932f\u8aa4\u3057\u3084\u3059\u3088\u3046\u306a\u65b9\u6cd5\u304c\u6b32\u3057\u304b\u3063\u305f\u306e\u3067\u3059\u3002<\/p>\n<p>\u4f8b\u3048\u3070\u300c&#8221;20\u4ee3&#8221;\u306e&#8221;A\u5e02&#8221;\u306b\u4f4f\u3093\u3067\u3044\u308b&#8221;\u7537\u6027&#8221;\u3067\u3001&#8221;\uff0a\uff0a\u7dda&#8221;\u306b\u4e57\u3063\u3066\u901a\u52e4\u3057\u3066\u3044\u308b&#8221;\u4f1a\u793e\u54e1&#8221;\u300d\u306e\u3088\u3046\u306a\u3001\u8907\u6570\u5217\u3067\u5c5e\u6027\u3092\u7ba1\u7406\u3057\u3066\u3044\u308b\u30c6\u30fc\u30d6\u30eb\u3067\u3001\u8a72\u5f53\u3057\u305d\u3046\u306a\u6761\u4ef6\u3092\u8907\u6570\u7d44\u307f\u5408\u308f\u305b\u3066\u30bf\u30fc\u30b2\u30c3\u30c8\u3092\u7d5e\u308a\u8fbc\u3093\u3067\u3044\u304f\u3088\u3046\u306a\u30a4\u30e1\u30fc\u30b8\u3067\u3059\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u306b\u7a81\u3063\u8fbc\u3093\u3067\u3001SQL\u3067\u66f8\u3051\u3070\u3061\u3087\u3061\u3087\u3044\u3068\u51fa\u6765\u3066\u3057\u307e\u3044\u3088\u3046\u306a\u96f0\u56f2\u6c17\u3082\u3042\u308a\u307e\u3059\u304c\u3001\u305d\u306e\u3088\u3046\u306a\u30af\u30a8\u30ea\u30fc\u304c\u66f8\u3051\u308b\u3068\u304b\u6e96\u3058\u305f\u30d5\u30a3\u30eb\u30bf\u30fc\u6a5f\u80fd\u3092\u6301\u3063\u3066\u3044\u308b\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u3068\u304b\u7121\u3044\u304b\u3068\u63a2\u3057\u3066\u3044\u3066\u898b\u3064\u3051\u305f\u306e\u304c\u3001\u30bf\u30a4\u30c8\u30eb\u306b\u3082\u5165\u308c\u305fdfply\u3067\u3057\u305f\u3002<\/p>\n<h3>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h3>\n<p>Windows10\u74b0\u5883\u306eAnaconda(64bit\u7248) 3.7\u7cfb\u306e\u74b0\u5883\u306b\u5165\u308c\u307e\u3057\u305f\u3002\u4ed6\u306e\u74b0\u5883\u306f\u5229\u7528\u3055\u308c\u308b\u30d1\u30c3\u30b1\u30fc\u30b8\u30a4\u30f3\u30b9\u30c8\u30fc\u30e9\u30fc\u306a\u3069\u306b\u8aad\u307f\u66ff\u3048\u3066\u307f\u3066\u3060\u3055\u3044\u3002\u7d50\u8ad6\u304b\u3089\u8a00\u3046\u3068Anaconda Navigator\u3084conda\u3067\u306f\u5165\u308c\u3089\u308c\u307e\u305b\u3093\u3067\u3057\u305f\u3002<\/p>\n<p>pip\u3092\u4f7f\u3048\u3070\u5165\u308b\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u3068\u9762\u5012\u306a\u4e8b\u3092\u3084\u308a\u305f\u304f\u306a\u3051\u308c\u3070\u3001\u4eee\u60f3\u74b0\u5883\u3092\u4f5c\u3063\u3066\u305d\u3053\u3067<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\npip install dfply\r\n<\/pre>\n<p>\u3067\u3088\u308d\u3057\u3044\u306e\u3067\u306f\u306a\u3044\u304b\u3068\u3002(conda\u3068pip\u3092\u6df7\u305c\u308b\u3068\u5371\u967a\u3068\u3044\u3046\u8aac\u3082\u3042\u308a\u307e\u3059\u306e\u3067\u3001\u3054\u5229\u7528\u306f\u614e\u91cd\u306b\uff09\u3061\u306a\u307f\u306bPython2\u7cfb\u306f\u30b5\u30dd\u30fc\u30c8\u3057\u3066\u3044\u306a\u3044\u3088\u3046\u3067\u3059\u3002<\/p>\n<h3>\u30c7\u30fc\u30bf\u64cd\u4f5c<\/h3>\n<p>\u57fa\u672c\u7684\u306b\u306f &#8221; &gt;&gt;&#8221;\u3067\u30c7\u30fc\u30bf\u30d1\u30a4\u30d7\u30e9\u30a4\u30f3\u3092\u3064\u306a\u304e\u3001&#8221;X&#8221;\u3092\u7528\u3044\u3066\u5217\u3092\u53c2\u7167\u3057\u307e\u3059\u3002<\/p>\n<p>\u307e\u305a\u306f\u5fc5\u8981\u306a\u30e9\u30a4\u30d6\u30e9\u30ea\u30fc\u3092\u7528\u610f\u3057\u3001\u9069\u5f53\u306a\u30c6\u30b9\u30c8\u30c7\u30fc\u30bf\u3092\u7528\u610f\u3057\u307e\u3059\u3002\u3053\u3053\u3067\u306f\u307f\u3093\u306a\u5927\u597d\u304d&#8221;Iris&#8221;\u3092\u4f7f\u3063\u3066\u307f\u307e\u3059\u3002\uff08seaborn\u304canaconda\u306b\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u3044\u306a\u304b\u3063\u305f\u306e\u3067\u3001\u4e0d\u8db3\u30a8\u30e9\u30fc\u304c\u51fa\u305f\u5834\u5408\u306b\u306f\u5225\u9014\u306bconda\u30b3\u30de\u30f3\u30c9\u306a\u308aAnaconda Navigator\u3092\u4f7f\u3063\u3066\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u3066\u304f\u3060\u3055\u3044\uff09<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\nimport pandas as pd\r\nimport numpy as np\r\nfrom dfply import *\r\n\r\nimport seaborn as sns\r\niris = sns.load_dataset('iris')\r\nprint(iris.head())\r\nprint(type(iris))\r\n<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-902 size-full\" src=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-02_23h56_19.png\" alt=\"\" width=\"465\" height=\"128\" srcset=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-02_23h56_19.png 465w, https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-02_23h56_19-300x83.png 300w\" sizes=\"auto, (max-width: 465px) 100vw, 465px\" \/><\/p>\n<p>&#8220;&gt;&gt;&#8221;\u3092\u4f7f\u3063\u305f\u63a5\u7d9a\u65b9\u6cd5\u3068\u3057\u3066\u3001head()\u306b\u3064\u306a\u3044\u3067\u307f\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">iris &gt;&gt; head()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-903 size-full\" src=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-02_23h57_46.png\" alt=\"\" width=\"424\" height=\"162\" srcset=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-02_23h57_46.png 424w, https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-02_23h57_46-300x115.png 300w\" sizes=\"auto, (max-width: 424px) 100vw, 424px\" \/><\/p>\n<p>\u7279\u5b9a\u306e\u5217\u3092\u8868\u793a\u3059\u308b\u306b\u306f select \u3092\u4f7f\u3044\u307e\u3059\u3002\u5217\u306e\u53c2\u7167\u306b\u306f &#8220;X&#8221;. \u5217\u540d\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">iris &gt;&gt; select(X.sepal_width, X.petal_width) &gt;&gt; head()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-904 size-full\" src=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-02_23h59_03.png\" alt=\"\" width=\"190\" height=\"164\" \/><\/p>\n<p>\u7279\u5b9a\u306e\u6761\u4ef6\u3067\u884c\u306e\u7d5e\u308a\u8fbc\u307f\u3092\u884c\u3044\u307e\u3059\u3002\u3053\u3053\u3067\u306f mask\u3092\u4f7f\u3044\u3001sepal_length \u304c5\u4ee5\u4e0a\u3001sepal_width\u304c3\u4ee5\u4e0a\u306e\u3082\u306e\u3092\u9078\u629e\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">iris &gt;&gt; mask(X.sepal_length &gt; 5, X.sepal_width &gt; 3) &gt;&gt; head()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-905 size-full\" src=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-03_00h01_20.png\" alt=\"\" width=\"432\" height=\"169\" srcset=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-03_00h01_20.png 432w, https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-03_00h01_20-300x117.png 300w\" sizes=\"auto, (max-width: 432px) 100vw, 432px\" \/><\/p>\n<p>species\u6bce\u306esepal_length\u306e\u5e73\u5747\u5024\u3092\u96c6\u8a08\u3057\u307e\u3059\u3002group_by \u3067\u96c6\u8a08\u3092\u304b\u3051\u3001mean()\u3067\u5e73\u5747\u3092\u53d6\u308a\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">iris &gt;&gt; group_by(X.species) &gt;&gt; summarize(mean_sepal_length = X.sepal_length.mean())<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-906 size-full\" src=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-03_00h03_40.png\" alt=\"\" width=\"230\" height=\"119\" \/><\/p>\n<p>\u7279\u5b9a\u306e\u6761\u4ef6\u3092\u6301\u3064\u884c\u3060\u3051\u3092\u62bd\u51fa\u3059\u308b\u5834\u5408\u306f filter_by \u3092\u4f7f\u3044\u307e\u3059\u3002species\u304c&#8221;versicolor&#8221;\u306e\u3001petal_length, petal_width\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">iris &gt;&gt; filter_by(X.species == &quot;versicolor&quot;) &gt;&gt; select(X.petal_length, X.petal_width) &gt;&gt; head()<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-907\" src=\"https:\/\/mindtech.jp\/wp-content\/uploads\/2019\/07\/2019-07-03_00h03_40-1.png\" alt=\"\" width=\"230\" height=\"119\" \/><\/p>\n<p>\u3053\u306e\u3088\u3046\u306b\u64cd\u4f5c\u95a2\u6570\u3092\u5229\u7528\u3057\u3066\u3001\u30c7\u30fc\u30bf\u3092\u30d5\u30a3\u30eb\u30bf\u30fc\u3057\u305f\u308a\u52a0\u5de5\u3059\u308b\u3053\u3068\u304c\u51fa\u6765\u307e\u3059\u3002\u4e0a\u8a18\u4ee5\u5916\u306b\u3082\u591a\u304f\u306e\u95a2\u6570\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u3001\u5fc5\u8981\u306b\u5fdc\u3058\u3066\u4ee5\u4e0b\u306e\u914d\u5e03\u5143\u306egithub\u3092\u53c2\u7167\u3055\u308c\u308b\u3068\u826f\u3044\u3067\u3057\u3087\u3046\u3002<\/p>\n<p><a href=\"https:\/\/github.com\/kieferk\/dfply\">https:\/\/github.com\/kieferk\/dfply<\/a><\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>CSV\u30d5\u30a1\u30a4\u30eb\u306a\u3069\u3067\u7528\u610f\u3055\u308c\u305f\u30c7\u30fc\u30bf\u3092pandas\u3067\u53d6\u308a\u8fbc\u3093\u3060\u5f8c\u3001\u7279\u5b9a\u306e\u6761\u4ef6\u306b\u5f53\u3066\u306f\u307e\u308b\u30c7\u30fc\u30bf\u3092\u62bd\u51fa\u3057\u3066\u96c6\u8a08\u306a\u3069\u3092\u884c\u3044\u305f\u304b\u3063\u305f\u306e\u3067\u3059\u304c\u3001\u8907\u5408\u6761\u4ef6\u3092\u30b5\u30af\u30b5\u30af\u66f8\u3044\u3066\u8a66\u884c\u932f\u8aa4\u3057\u3084\u3059\u3088\u3046\u306a\u65b9\u6cd5\u304c\u6b32\u3057\u304b\u3063\u305f\u306e\u3067\u3059\u3002 \u4f8b\u3048\u3070\u300c&#038;#8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[6],"tags":[157,158,34],"class_list":["post-901","post","type-post","status-publish","format-standard","hentry","category-6","tag-dfply","tag-pandas","tag-python"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p4rHn0-ex","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts\/901","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=901"}],"version-history":[{"count":2,"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts\/901\/revisions"}],"predecessor-version":[{"id":934,"href":"https:\/\/mindtech.jp\/index.php?rest_route=\/wp\/v2\/posts\/901\/revisions\/934"}],"wp:attachment":[{"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=901"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=901"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mindtech.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=901"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}