{"id":687,"date":"2026-08-30T06:19:10","date_gmt":"2026-08-29T21:19:10","guid":{"rendered":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/687"},"modified":"2026-08-30T06:19:10","modified_gmt":"2026-08-29T21:19:10","slug":"pandas%e3%81%ae%e3%82%b5%e3%83%b3%e3%83%97%e3%83%ab%e3%82%b3%e3%83%bc%e3%83%89%e7%b4%b9%e4%bb%8b","status":"publish","type":"post","link":"https:\/\/www.marchboy.xyz\/wordpress\/archives\/687","title":{"rendered":"pandas\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u7d39\u4ecb"},"content":{"rendered":"<h2>pandas\u3068\u306f<\/h2>\n<p>pandas\u306fPython\u3067\u30c7\u30fc\u30bf\u89e3\u6790\u3092\u884c\u3046\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002DataFrame \u3068\u547c\u3070\u308c\u308b\u8868\u5f62\u5f0f\u30c7\u30fc\u30bf\u3092\u7c21\u5358\u306b\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3002<\/p>\n<h2>\u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9<\/h2>\n<p>\u307e\u305a\u306f pandas \u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3001\u30b5\u30f3\u30d7\u30eb\u30c7\u30fc\u30bf\u3092\u4f5c\u6210\u3057\u3066\u307f\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code>import pandas as pd\n\n# \u30b5\u30f3\u30d7\u30eb\u30c7\u30fc\u30bf\u306e\u4f5c\u6210\ndata = {\n    \"\u540d\u524d\": [\"Alice\", \"Bob\", \"Charlie\"],\n    \"\u5e74\u9f62\": [25, 30, 22],\n    \"\u90fd\u5e02\": [\"\u6771\u4eac\", \"\u5927\u962a\", \"\u540d\u53e4\u5c4b\"]\n}\n\ndf = pd.DataFrame(data)\nprint(df)<\/code><\/pre>\n<h3>\u51fa\u529b\u4f8b<\/h3>\n<pre><code>       \u540d\u524d  \u5e74\u9f62   \u90fd\u5e02\n0   Alice  25   \u6771\u4eac\n1     Bob  30   \u5927\u962a\n2  Charlie  22   \u540d\u53e4\u5c4b<\/code><\/pre>\n<h2>\u5217\u30fb\u884c\u306e\u64cd\u4f5c<\/h2>\n<ul>\n<li><strong>\u5217\u306e\u8ffd\u52a0<\/strong>\uff1a\u65b0\u3057\u3044\u5217\u3092\u8a08\u7b97\u3067\u4f5c\u6210<\/li>\n<\/ul>\n<pre><code># \u5e74\u9f62\u306e2\u500d\u306e\u5217\u3092\u8ffd\u52a0\ndf[\"\u5e74\u9f62\u00d72\"] = df[\"\u5e74\u9f62\"] * 2\nprint(df)<\/code><\/pre>\n<ul>\n<li><strong>\u884c\u306e\u30d5\u30a3\u30eb\u30bf\u30ea\u30f3\u30b0<\/strong>\uff1a\u6761\u4ef6\u306b\u5408\u81f4\u3059\u308b\u884c\u3060\u3051\u62bd\u51fa<\/li>\n<\/ul>\n<pre><code># \u5e74\u9f62\u304c25\u6b73\u4ee5\u4e0a\u306e\u884c\u3092\u53d6\u5f97\nfiltered = df[df[\"\u5e74\u9f62\"] >= 25]\nprint(filtered)<\/code><\/pre>\n<h2>\u6761\u4ef6\u62bd\u51fa\u3068\u96c6\u8a08<\/h2>\n<p>\u8907\u6570\u6761\u4ef6\u3067\u62bd\u51fa\u3057\u305f\u308a\u3001\u30b0\u30eb\u30fc\u30d7\u5316\u3057\u3066\u96c6\u8a08\u3057\u305f\u308a\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code># \u8907\u6570\u6761\u4ef6\u3067\u62bd\u51fa\ncond = (df[\"\u5e74\u9f62\"] >= 25) & (df[\"\u90fd\u5e02\"] == \"\u6771\u4eac\")\nselected = df[cond]\nprint(selected)\n\n# \u90fd\u5e02\u3054\u3068\u306e\u5e73\u5747\u5e74\u9f62\u3092\u7b97\u51fa\nmean_age = df.groupby(\"\u90fd\u5e02\")[\"\u5e74\u9f62\"].mean()\nprint(mean_age)<\/code><\/pre>\n<h2>\u30c7\u30fc\u30bf\u306e\u5165\u51fa\u529b<\/h2>\n<p>CSV \u3084 Excel \u306a\u3069\u306e\u30d5\u30a1\u30a4\u30eb\u306b\u7c21\u5358\u306b\u4fdd\u5b58\u30fb\u8aad\u307f\u8fbc\u307f\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre><code># CSV \u306b\u4fdd\u5b58\ndf.to_csv(\"sample.csv\", index=False)\n\n# CSV \u304b\u3089\u8aad\u307f\u8fbc\u307f\ndf_loaded = pd.read_csv(\"sample.csv\")\nprint(df_loaded)<\/code><\/pre>\n<h2>\u307e\u3068\u3081<\/h2>\n<p>pandas \u306f\u30c7\u30fc\u30bf\u306e\u53d6\u5f97\u3001\u52a0\u5de5\u3001\u5206\u6790\u3001\u4fdd\u5b58\u307e\u3067\u3092\u30b7\u30f3\u30d7\u30eb\u306a\u30b3\u30fc\u30c9\u3067\u5b9f\u73fe\u3067\u304d\u308b\u5f37\u529b\u306a\u30c4\u30fc\u30eb\u3067\u3059\u3002\u4e0a\u8a18\u306e\u30b5\u30f3\u30d7\u30eb\u30b3\u30fc\u30c9\u3092\u30d9\u30fc\u30b9\u306b\u3001\u5b9f\u969b\u306e\u30c7\u30fc\u30bf\u306b\u5408\u308f\u305b\u3066\u30ab\u30b9\u30bf\u30de\u30a4\u30ba\u3057\u3066\u307f\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>pandas\u3068\u306f pandas\u306fPython\u3067\u30c7\u30fc\u30bf\u89e3\u6790\u3092\u884c\u3046\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002DataFrame \u3068\u547c\u3070\u308c\u308b\u8868\u5f62\u5f0f\u30c7\u30fc\u30bf\u3092\u7c21\u5358\u306b\u64cd\u4f5c\u3067\u304d\u307e\u3059\u3002 \u57fa\u672c\u7684\u306a\u4f7f\u3044\u65b9 \u307e\u305a\u306f pandas \u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u3001\u30b5\u30f3\u30d7\u30eb\u30c7\u30fc\u30bf\u3092 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[39],"tags":[],"class_list":["post-687","post","type-post","status-publish","format-standard","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/687","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/comments?post=687"}],"version-history":[{"count":0,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/posts\/687\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/media?parent=687"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/categories?post=687"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.marchboy.xyz\/wordpress\/wp-json\/wp\/v2\/tags?post=687"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}