{"id":120,"date":"2025-07-06T20:45:02","date_gmt":"2025-07-06T11:45:02","guid":{"rendered":"https:\/\/hooper-lab.com\/?p=120"},"modified":"2025-07-14T18:33:15","modified_gmt":"2025-07-14T09:33:15","slug":"5%ef%bc%9apandas%e3%81%ae%e5%9f%ba%e7%a4%8e1%ef%bc%9a%e3%83%87%e3%83%bc%e3%82%bf%e3%81%ae%e8%aa%ad%e3%81%bf%e8%be%bc%e3%81%bf%e3%81%a8%e8%a1%a8%e7%a4%ba","status":"publish","type":"post","link":"https:\/\/hooper-lab.com\/?p=120","title":{"rendered":"5\uff1apandas\u306e\u57fa\u790e1(\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u3068\u8868\u793a)"},"content":{"rendered":"\n<div class=\"wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-d445cf74 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/hooper-lab.com\/?p=112\">\u524d\u9805\u76ee\u3078<\/a><\/div>\n\n\n\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/hooper-lab.com\/?p=138\">\u6b21\u9805\u76ee\u3078<\/a><\/div>\n<\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u306a\u305c\u6700\u521d\u306b\u300cpandas\u300d\u3092\u5b66\u3076\u306e\u304b\uff1f<\/strong><\/h4>\n\n\n\n<p>Python\u3067NBA\u30c7\u30fc\u30bf\u5206\u6790\u3092\u59cb\u3081\u308b\u3068\u304d\u3001\u6700\u521d\u306b\u3076\u3064\u304b\u308b\u306e\u304c\u300c<strong>\u30c7\u30fc\u30bf\u306e\u898b\u65b9\u30fb\u6271\u3044\u65b9<\/strong>\u300d\u3067\u3059\u3002<br>NBA API\u3092\u4f7f\u3048\u3070\u3001\u9078\u624b\u306e\u6210\u7e3e\u3084\u30c1\u30fc\u30e0\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u306e\u4e2d\u8eab\u306f\u3059\u3079\u3066\u300c\u8868\u30c7\u30fc\u30bf\uff08\uff1d\u884c\u3068\u5217\u306e\u69cb\u9020\uff09\u300d\u306b\u306a\u3063\u3066\u3044\u307e\u3059\u3002\u305d\u3053\u3067\u5fc5\u8981\u306b\u306a\u308b\u306e\u304c <strong>pandas\uff08\u30d1\u30f3\u30c0\u30b9\uff09<\/strong> \u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3067\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>pandas\u3092\u6700\u521d\u306b\u5b66\u3076\u3079\u304d\u7406\u7531\uff1a<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>NBA API\u306e\u30c7\u30fc\u30bf\u5f62\u5f0f\u3068\u76f8\u6027\u304c\u3088\u3044<\/strong>\uff08DataFrame\u3067\u8fd4\u3063\u3066\u304f\u308b\uff09<\/li>\n\n\n\n<li><strong>Excel\u306e\u3088\u3046\u306a\u64cd\u4f5c\u304c\u7c21\u5358\u306b\u3067\u304d\u308b<\/strong>\uff08\u62bd\u51fa\u30fb\u4e26\u3079\u66ff\u3048\u30fb\u8a08\u7b97\u306a\u3069\uff09<\/li>\n\n\n\n<li><strong>\u5f8c\u306e\u5206\u6790\u30fb\u53ef\u8996\u5316\u30fb\u6a5f\u68b0\u5b66\u7fd2\u306b\u3082\u76f4\u7d50\u3059\u308b\u57fa\u672c\u30b9\u30ad\u30eb<\/strong><\/li>\n<\/ul>\n\n\n\n<p>NBA\u306b\u9650\u3089\u305a\u3001\u30c7\u30fc\u30bf\u5206\u6790\u306e\u57fa\u790e\u3068\u306a\u308b\u306e\u304c\u3053\u306e pandas \u306a\u306e\u3067\u3001\u307e\u305a\u3053\u3053\u3092\u62bc\u3055\u3048\u3066\u304a\u304f\u3068\u3053\u306e\u5148\u305a\u3063\u3068\u30e9\u30af\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>pandas\u3063\u3066\u306a\u306b\uff1f<\/strong><\/h4>\n\n\n\n<p>pandas \u306f\u3001Python\u3067\u300c\u8868\u30c7\u30fc\u30bf\uff08\uff1dExcel\u307f\u305f\u3044\u306a\u30c7\u30fc\u30bf\uff09\u300d\u3092\u8aad\u307f\u8fbc\u3093\u3060\u308a\u52a0\u5de5\u3057\u305f\u308a\u3059\u308b\u305f\u3081\u306e\u30c4\u30fc\u30eb\u3067\u3059\u3002NBA\u306e\u8a66\u5408\u3084\u9078\u624b\u6210\u7e3e\u306e\u3088\u3046\u306b\u3001<strong>\u884c\u3068\u5217\u304c\u3042\u308b\u30c7\u30fc\u30bf<\/strong>\u3092\u304d\u308c\u3044\u306b\u6271\u3048\u308b\u306e\u304c\u6700\u5927\u306e\u5f37\u307f\u3067\u3059\u3002<\/p>\n\n\n\n<p>pandas \u306e\u57fa\u672c\u69cb\u9020\u306f2\u3064\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>Series<\/code>\uff1a1\u5217\u306e\u30c7\u30fc\u30bf\uff08\u5217\u30c7\u30fc\u30bf\uff09<\/li>\n\n\n\n<li><code>DataFrame<\/code>\uff1a\u8868\uff08\u884c \u00d7 \u5217\uff09 \u2190 \u3053\u308c\u304c\u30e1\u30a4\u30f3\u3067\u4f7f\u308f\u308c\u308b<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>pandas \u3092\u4f7f\u3046\u6e96\u5099<\/strong><\/h4>\n\n\n\n<p>\u307e\u305a\u306f\u3001\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u3057\u3066 pandas \u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3057\u3087\u3046<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import pandas as pd<\/code><\/pre>\n\n\n\n<p><code>pd<\/code> \u306f pandas \u306e\u7565\u79f0\u3067\u3001\u4ee5\u5f8c\u306e\u64cd\u4f5c\u3092\u30b3\u30f3\u30d1\u30af\u30c8\u306b\u66f8\u304f\u305f\u3081\u306e\u201c\u30cb\u30c3\u30af\u30cd\u30fc\u30e0\u201d\u306e\u3088\u3046\u306a\u3082\u306e\u3067\u3059\u3002<\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>nba_api\u3068\u7d44\u307f\u5408\u308f\u305b\u3066\u4f7f\u3063\u3066\u307f\u308b<\/strong><\/h4>\n\n\n\n<p>\u4f8b\u3068\u3057\u3066\u30b9\u30c6\u30d5\u30a3\u30f3\u30fb\u30ab\u30ea\u30fc\u306e\u30ad\u30e3\u30ea\u30a2\u30b9\u30bf\u30c3\u30c4\u3092\u8868\u793a\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>from nba_api.stats.static import players\nfrom nba_api.stats.endpoints import playercareerstats\n\n# \u30ab\u30ea\u30fc\u306eID\u3092\u53d6\u5f97\nplayer = players.find_players_by_full_name(\"Stephen Curry\")&#91;0]\n\n# \u30ad\u30e3\u30ea\u30a2\u30b9\u30bf\u30c3\u30c4\u3092\u53d6\u5f97\ncareer = playercareerstats.PlayerCareerStats(player_id=player&#91;'id'])\n\n# pandas\u306eDataFrame\u3067\u53d7\u3051\u53d6\u308b\ndf = career.get_data_frames()&#91;0]\n\n# \u8868\u793a\u3057\u3066\u307f\u308b\uff08\u6700\u521d\u306e5\u884c\uff09\nprint(df.head())\n<\/code><\/pre>\n\n\n\n<p>\u307e\u305a\u306f\u524d\u56de\u540c\u69d8\u3001\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u306e\u89e3\u8aac\u3067\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>\u2460 <code>from nba_api.stats.static import playerss<\/code><\/strong><\/h5>\n\n\n\n<p> \u610f\u5473\uff1a<br><code>nba_api<\/code> \u30e9\u30a4\u30d6\u30e9\u30ea\u306e\u4e2d\u306e\u300c\u9759\u7684\u60c5\u5831\uff08=\u540d\u524d\u3084ID\u306a\u3069\u5909\u308f\u3089\u306a\u3044\u57fa\u672c\u30c7\u30fc\u30bf\uff09\u300d\u3092\u6271\u3046\u90e8\u5206 <code>static<\/code> \u304b\u3089\u3001\u9078\u624b\u60c5\u5831\u3092\u53d6\u5f97\u3059\u308b <code>players<\/code> \u3092\u4f7f\u3048\u308b\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<p>\u4e3b\u306b\u4f7f\u3046\u76ee\u7684\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u9078\u624b\u540d\u304b\u3089<strong>ID\uff08player_id\uff09\u3092\u53d6\u5f97<\/strong>\u3059\u308b<\/li>\n\n\n\n<li>\u540d\u524d\u3084\u73fe\u5f79\u30d5\u30e9\u30b0\uff08<code><strong>is_active<\/strong><\/code>\uff09\u306a\u3069\u3092\u78ba\u8a8d\u3059\u308b<\/li>\n<\/ul>\n\n\n\n<h5 class=\"wp-block-heading\"><strong>\u2461 <code>from nba_api.stats.endpoints import playercareerstats<\/code><\/strong><\/h5>\n\n\n\n<p>\u2714 \u91cd\u8981\u30ad\u30fc\u30ef\u30fc\u30c9\uff1a<strong>endpoint\uff08\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8\uff09\u3068\u306f\uff1f<\/strong><\/p>\n\n\n\n<p><strong>\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8<\/strong>\u3068\u306f\u3001NBA\u516c\u5f0f\u30b5\u30a4\u30c8\u306e\u300c\u7d71\u8a08\u30c7\u30fc\u30bf\u3092\u63d0\u4f9b\u3057\u3066\u3044\u308bAPI\u306e\u5165\u308a\u53e3\uff08\uff1dURL\u306b\u5bfe\u5fdc\u3057\u305f\u6a5f\u80fd\uff09\u300d\u3067\u3059\u3002NBA API\u3067\u306f\u3001\u300c\u3053\u306eURL\u306b\u30a2\u30af\u30bb\u30b9\u3059\u308b\u3068\u3001\u9078\u624b\u306e\u30ad\u30e3\u30ea\u30a2\u6210\u7e3e\u304c\u8fd4\u3063\u3066\u304f\u308b\u3088\uff01\u300d<br>\u3068\u3044\u3046\u4ed5\u7d44\u307f\u304c\u3042\u308a\u3001\u305d\u308c\u3092Python\u3067\u6271\u3048\u308b\u3088\u3046\u306b\u3057\u305f\u306e\u304c <code>endpoints<\/code> \u306b\u3042\u308b\u5404\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u3002<\/p>\n\n\n\n<h5 class=\"wp-block-heading\"><code>playercareerstats<\/code> \u3068\u306f\uff1f<\/h5>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u30d7\u30ec\u30a4\u30e4\u30fc\u306e<strong>\u30ad\u30e3\u30ea\u30a2\u901a\u7b97\u30fb\u30b7\u30fc\u30ba\u30f3\u5225\u6210\u7e3e<\/strong>\u3092\u53d6\u5f97\u3067\u304d\u308b\u30a8\u30f3\u30c9\u30dd\u30a4\u30f3\u30c8<\/li>\n\n\n\n<li><code>player_id<\/code> \u3092\u6307\u5b9a\u3057\u3066\u5b9f\u884c\u3059\u308b\u3068\u3001<strong>\u30b7\u30fc\u30ba\u30f3\u3054\u3068\u306e\u5f97\u70b9\u30fb\u8a66\u5408\u6570\u30fb\u30a2\u30b7\u30b9\u30c8\u306a\u3069<\/strong>\u306e\u30c7\u30fc\u30bf\u304c\u8fd4\u3063\u3066\u304d\u307e\u3059<\/li>\n<\/ul>\n\n\n\n<p><strong>NBA API\u306e\u69cb\u9020\uff08\u30a4\u30e1\u30fc\u30b8\uff09<\/strong><\/p>\n\n\n\n<p>nba_api\/<br>\u251c\u2500 stats\/<br>\u2502 \u251c\u2500 static\/ \u2190 \u9078\u624b\u3084\u30c1\u30fc\u30e0\u306e\u540d\u524d\u30fbID\u306a\u3069\uff08\u5909\u308f\u3089\u306a\u3044\u60c5\u5831\uff09<br>\u2502 \u2514\u2500 endpoints\/ \u2190 \u5404\u7a2e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3059\u308b\u300cAPI\u306e\u5165\u308a\u53e3\u300d<br>\u2502        \u251c\u2500 playercareerstats.py \u2190 \u30ad\u30e3\u30ea\u30a2\u6210\u7e3e\u7528\u306eendpoint<br>\u2502        \u251c\u2500 boxscoretraditionalv2.py \u2190 \u8a66\u5408\u306e\u30dc\u30c3\u30af\u30b9\u30b9\u30b3\u30a2<br>\u2502        \u251c\u2500 leaguedashplayerstats.py \u2190 \u30ea\u30fc\u30b0\u5168\u4f53\u306e\u9078\u624b\u30b9\u30bf\u30c3\u30c4<\/p>\n\n\n\n<p><code>df.head()<\/code>\u306f pandas \u306e\u30e1\u30bd\u30c3\u30c9\u3067\u3001<strong>\u6700\u521d\u306e5\u884c<\/strong>\u3060\u3051\u3092\u8868\u793a\u3057\u3066\u304f\u308c\u307e\u3059\u3002<br>\uff08\u30c7\u30fc\u30bf\u5168\u4f53\u3092\u898b\u3059\u304e\u3066\u6df7\u4e71\u3057\u306a\u3044\u3088\u3046\u306b\u3001\u307e\u305a\u306f\u201c\u3056\u3063\u304f\u308a\u201d\u898b\u305f\u3044\u3068\u304d\u306b\u4fbf\u5229\u3067\u3059\uff09<br>\u7d50\u679c\u306f\u3053\u306e\u3088\u3046\u306b\u6700\u521d\u306e\uff15\u884c\u3060\u3051\u8868\u793a\u3055\u308c\u305f\u306f\u305a\u3067\u3059\u3002\uff08\u672c\u5f53\u306f\u3082\u3063\u3068\u6a2a\u306b\u9577\u3044\u3067\u3059\u304c\u7701\u7565\uff09<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">   PLAYER_ID SEASON_ID LEAGUE_ID     TEAM_ID TEAM_ABBREVIATION  PLAYER_AGE\u3000\u30fb\u30fb\u30fb  <br>0     201939   2009-10        00  1610612744               GSW        22.0  \u30fb\u30fb\u30fb<br>1     201939   2010-11        00  1610612744               GSW        23.0  \u30fb\u30fb\u30fb <br>2     201939   2011-12        00  1610612744               GSW        24.0  \u30fb\u30fb\u30fb <br>3     201939   2012-13        00  1610612744               GSW        25.0  \u30fb\u30fb\u30fb <br>4     201939   2013-14        00  1610612744               GSW        26.0  \u30fb\u30fb\u30fb <\/pre>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>\u307e\u3068\u3081<\/strong><\/h4>\n\n\n\n<ul class=\"wp-block-list\">\n<li>pandas \u306f <strong>\u30c7\u30fc\u30bf\u5206\u6790\u306e\u571f\u53f0\u3068\u306a\u308b\u30e9\u30a4\u30d6\u30e9\u30ea<\/strong><\/li>\n\n\n\n<li>NBA API \u306e\u30c7\u30fc\u30bf\u306f\u307b\u307c\u3059\u3079\u3066 <code>DataFrame<\/code> \u3068\u3057\u3066\u53d7\u3051\u53d6\u308b\u305f\u3081\u3001\u307e\u305apandas\u3092\u6271\u3048\u308b\u3088\u3046\u306b\u3059\u308b\u306e\u304c\u6700\u91cd\u8981<\/li>\n\n\n\n<li><code>df.head()<\/code> \u3092\u4f7f\u3048\u3070\u3001\u8868\u306e\u4e2d\u8eab\u3092\u4e00\u77ac\u3067\u78ba\u8a8d\u3067\u304d\u308b<\/li>\n<\/ul>\n\n\n\n<p>\u6b21\u56de\u306f\u3001\u5b9f\u969b\u306bpandas\u306e\u6a5f\u80fd\u3092\u7528\u3044\u3066\u4e26\u3079\u66ff\u3048\u3001\u62bd\u51fa\u3001\u96c6\u8a08\u7b49\u3092\u5b66\u3093\u3067\u884c\u304d\u307e\u3057\u3087\u3046\uff01<\/p>\n\n\n\n<div class=\"wp-block-buttons is-content-justification-right is-layout-flex wp-container-core-buttons-is-layout-d445cf74 wp-block-buttons-is-layout-flex\">\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/hooper-lab.com\/?p=112\">\u524d\u9805\u76ee\u3078<\/a><\/div>\n\n\n\n<div class=\"wp-block-button\"><a class=\"wp-block-button__link wp-element-button\" href=\"https:\/\/hooper-lab.com\/?p=138\">\u6b21\u9805\u76ee\u3078<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>\u306a\u305c\u6700\u521d\u306b\u300cpandas\u300d\u3092\u5b66\u3076\u306e\u304b\uff1f Python\u3067NBA\u30c7\u30fc\u30bf\u5206\u6790\u3092\u59cb\u3081\u308b\u3068\u304d\u3001\u6700\u521d\u306b\u3076\u3064\u304b\u308b\u306e\u304c\u300c\u30c7\u30fc\u30bf\u306e\u898b\u65b9\u30fb\u6271\u3044\u65b9\u300d\u3067\u3059\u3002NBA API\u3092\u4f7f\u3048\u3070\u3001\u9078\u624b\u306e\u6210\u7e3e\u3084\u30c1\u30fc\u30e0\u306e\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3067\u304d\u307e\u3059\u304c\u3001\u305d\u306e\u4e2d\u8eab\u306f\u3059\u3079\u3066\u300c\u8868 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":253,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,4],"tags":[14,16,8,17,11,9,12],"class_list":["post-120","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-10","category-learning","tag-curry","tag-jupyterlab","tag-nba","tag-pandas","tag-python","tag-9","tag-12"],"_links":{"self":[{"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/posts\/120","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=120"}],"version-history":[{"count":6,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/posts\/120\/revisions"}],"predecessor-version":[{"id":258,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/posts\/120\/revisions\/258"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/media\/253"}],"wp:attachment":[{"href":"https:\/\/hooper-lab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=120"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=120"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=120"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}