{"id":96,"date":"2025-07-03T20:25:24","date_gmt":"2025-07-03T11:25:24","guid":{"rendered":"https:\/\/hooper-lab.com\/?p=96"},"modified":"2025-07-14T18:46:00","modified_gmt":"2025-07-14T09:46:00","slug":"2-python%e3%81%a8%e3%81%af%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/hooper-lab.com\/?p=96","title":{"rendered":"2 : Python\u3068\u306f\uff1f"},"content":{"rendered":"\n<p>~Python\u3068\u306f\uff1fNBA\u30c7\u30fc\u30bf\u5206\u6790\u306b\u3082\u4f7f\u3048\u308b\u3084\u3055\u3057\u3044\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e~<br><\/p>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\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=93\">\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=108\">\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>\u300cPython\u3063\u3066\u306a\u306b\uff1f\u300d<\/strong><\/h4>\n\n\n\n<p>Python\uff08\u30d1\u30a4\u30bd\u30f3\uff09\u306f\u3001\u4eca\u3044\u3061\u3070\u3093\u6ce8\u76ee\u3055\u308c\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u3072\u3068\u3064\u3067\u3059\u3002<br>\u30b7\u30f3\u30d7\u30eb\u3067\u8aad\u307f\u3084\u3059\u304f\u3001\u521d\u5fc3\u8005\u306b\u3082\u3084\u3055\u3057\u3044\u3002\u306a\u306e\u306b\u3001AI\u958b\u767a\u304b\u3089Web\u30b5\u30fc\u30d3\u30b9\u3001\u30c7\u30fc\u30bf\u5206\u6790\u307e\u3067\u3001\u3042\u3089\u3086\u308b\u3053\u3068\u306b\u4f7f\u308f\u308c\u3066\u3044\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u300cNBA\u306e\u9078\u624b\u30c7\u30fc\u30bf\u3092\u5206\u6790\u3057\u305f\u3044\u300d\u3068\u601d\u3063\u305f\u3068\u304d\u3001Python\u306a\u3089<strong>\u305f\u3063\u305f\u6570\u884c\u306e\u30b3\u30fc\u30c9\u3067\u30c7\u30fc\u30bf\u3092\u53d6\u5f97\u3057\u3066\u3001\u3059\u3050\u306b\u30b0\u30e9\u30d5\u306b\u3059\u308b<\/strong>\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br>\u3053\u308c\u306f\u4ed6\u306e\u8a00\u8a9e\u3067\u306f\u306a\u304b\u306a\u304b\u96e3\u3057\u3044\u82b8\u5f53\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>\u306a\u305cPython\u304c\u4eba\u6c17\u306a\u306e\u304b\uff1f<\/strong><\/h4>\n\n\n\n<p>Python\u304c\u3053\u3053\u307e\u3067\u5e83\u307e\u3063\u3066\u3044\u308b\u7406\u7531\u306f\u3044\u304f\u3064\u304b\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u66f8\u304d\u65b9\u304c\u30b7\u30f3\u30d7\u30eb\u3067\u899a\u3048\u3084\u3059\u3044<\/strong><br>\u82f1\u8a9e\u306e\u3088\u3046\u306a\u81ea\u7136\u306a\u6587\u6cd5\u306a\u306e\u3067\u3001\u521d\u5fc3\u8005\u3067\u3082\u5b66\u3073\u3084\u3059\u3044\u3002<\/li>\n\n\n\n<li><strong>\u6d3b\u7528\u3067\u304d\u308b\u5206\u91ce\u304c\u5e83\u3044<\/strong><br>Web\u30a2\u30d7\u30ea\u958b\u767a\u3001AI\u3001\u30c7\u30fc\u30bf\u5206\u6790\u3001\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u3001\u696d\u52d9\u81ea\u52d5\u5316\u306a\u3069\u3001\u30b8\u30e3\u30f3\u30eb\u3092\u554f\u308f\u305a\u4f7f\u3048\u308b\u3002<\/li>\n\n\n\n<li><strong>\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u8c4a\u5bcc<\/strong><br>\u3084\u308a\u305f\u3044\u3053\u3068\u3092\u52a9\u3051\u3066\u304f\u308c\u308b\u300c\u30c4\u30fc\u30eb\uff08\u30e9\u30a4\u30d6\u30e9\u30ea\uff09\u300d\u304c\u5145\u5b9f\u3057\u3066\u3044\u307e\u3059\u3002\u305f\u3068\u3048\u3070\u3001NBA\u516c\u5f0f\u30c7\u30fc\u30bf\u306b\u30a2\u30af\u30bb\u30b9\u3067\u304d\u308b <code>nba_api<\/code> \u3068\u3044\u3046\u30e9\u30a4\u30d6\u30e9\u30ea\u3082\u3001\u305d\u306e\u3072\u3068\u3064\u3067\u3059\u3002<\/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>Python \u00d7 NBA_API\uff1a\u4f55\u304c\u3067\u304d\u308b\u306e\uff1f<\/strong><\/h4>\n\n\n\n<p>Python\u3068NBA_API\u3092\u7d44\u307f\u5408\u308f\u305b\u308b\u3068\u3001\u3053\u3093\u306a\u3053\u3068\u304c\u3067\u304d\u307e\u3059\uff1a<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u7279\u5b9a\u306e\u9078\u624b\u306e\u904e\u53bb\u306e\u6210\u7e3e\u3092\u81ea\u52d5\u3067\u53d6\u5f97\u3059\u308b<\/li>\n\n\n\n<li>\u30c1\u30fc\u30e0\u3054\u3068\u306e\u30aa\u30d5\u30a7\u30f3\u30b7\u30d6\u30fb\u30ec\u30fc\u30c6\u30a3\u30f3\u30b0\u3092\u5206\u6790\u3059\u308b<\/li>\n\n\n\n<li>\u300c\u4eca\u5b6330\u5f97\u70b9\u4ee5\u4e0a\u3092\u8a18\u9332\u3057\u305f\u9078\u624b\u300d\u3092\u62bd\u51fa\u3059\u308b<\/li>\n\n\n\n<li>\u30c7\u30fc\u30bf\u3092\u30b0\u30e9\u30d5\u5316\u3057\u3066\u30d6\u30ed\u30b0\u3084\u52d5\u753b\u3067\u7d39\u4ecb\u3059\u308b<\/li>\n<\/ul>\n\n\n\n<p>\u3064\u307e\u308a\u3001NBA\u304c\u597d\u304d\u306a\u4eba\u306b\u3068\u3063\u3066\u306f\u3001Python\u304c\u3042\u308b\u3060\u3051\u3067<strong>\u81ea\u5206\u3060\u3051\u306e\u5206\u6790\u30c4\u30fc\u30eb<\/strong>\u304c\u4f5c\u308c\u3066\u3057\u307e\u3046\u308f\u3051\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>\u3069\u3093\u306a\u30b3\u30fc\u30c9\u3092\u66f8\u304f\u306e\uff1f<\/strong><\/h4>\n\n\n\n<p>\u4f8b\u3048\u3070\u30b9\u30c6\u30d5\u30a3\u30f3\u30fb\u30ab\u30ea\u30fc\u306e\u30b7\u30fc\u30ba\u30f3\u3054\u3068\u306e\uff13P\u6210\u529f\u6570\u3092\u77e5\u308a\u305f\u3044\uff01\u3068\u601d\u3063\u305f\u3089\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u66f8\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>pip install nba_api<\/code><\/pre>\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# \u30b9\u30c6\u30d5\u30a3\u30f3\u30fb\u30ab\u30ea\u30fc\u306e\u60c5\u5831\u53d6\u5f97\nplayer = players.find_players_by_full_name(\"Stephen Curry\")&#91;0]\ncareer = playercareerstats.PlayerCareerStats(player_id=player&#91;'id'])\n\n# \u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u53d6\u5f97\ndf = career.get_data_frames()&#91;0]\n\n# \u30b7\u30fc\u30ba\u30f3\u30683\u30dd\u30a4\u30f3\u30c8\u6210\u529f\u6570\u3060\u3051\u8868\u793a\ndf_FG3M = df&#91;&#91;\"SEASON_ID\", \"FG3M\"]]\nprint(df_FG3M)<\/code><\/pre>\n\n\n\n<p>\u4ee5\u4e0a\u3092\u5b9f\u884c\u3059\u308b\u3068\u4ee5\u4e0b\u304c\u30a2\u30a6\u30c8\u30d7\u30c3\u30c8\u3055\u308c\u307e\u3059\u3002<br>   SEASON_ID  FG3M<br>0    2009-10   166<br>1     2010-11    151<br>2    2011-12     55<br>3    2012-13    272<br>4    2013-14    261<br>5    2014-15    286<br>6    2015-16    402<br>7    2016-17    324<br>8    2017-18    212<br>9    2018-19    354<br>10   2019-20   12<br>11   2020-21    337<br>12   2021-22    285<br>13   2022-23   273<br>14   2023-24   357<br>15   2024-25   311<\/p>\n\n\n\n<p>SEASON_ID\u304c\u30b7\u30fc\u30ba\u30f3\u3067\u3001FG3M\u304c\u5404\u30b7\u30fc\u30ba\u30f3\u306e\uff13P\u6210\u529f\u6570\u3067\u3059\u306d\u3002\u5168\u4f53\u7684\u306b\u51c4\u3059\u304e\u307e\u3059\u304c\u305d\u306e\u4e2d\u3067\u30822015-16\u30b7\u30fc\u30ba\u30f3\u306e402\u672c\u6210\u529f\u306f\u5225\u683c\u3067\u3059\u306d\u3002\u6d41\u77f3\u306e\u6e80\u7968MVP\u3067\u3059\u3002<br><br>\u7c21\u5358\u306b\u30b0\u30e9\u30d5\u3092\u66f8\u304f\u3053\u3068\u3082\u3067\u304d\u307e\u3059\u3002<br>\u30b9\u30c6\u30d5\u30a3\u30f3\u30fb\u30ab\u30ea\u30fc\u3068\u540c\u3058\u30c9\u30e9\u30d5\u30c8\u306e\u30b9\u30bf\u30fc\u30d7\u30ec\u30a4\u30e4\u30fc\u3068\u3044\u3048\u3070\u30b8\u30a7\u30fc\u30e0\u30ba\u30fb\u30cf\u30fc\u30c7\u30f3\u3067\u3059\u306d\u3002\u4e8c\u4eba\u306e\u30b7\u30fc\u30ba\u30f3\u3054\u3068\u306e\uff13P\u6210\u529f\u6570\u306e\u7d2f\u8a08\u3092\u6298\u308c\u7dda\u30b0\u30e9\u30d5\u3067\u898b\u3066\u307f\u307e\u3057\u3087\u3046\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\nimport pandas as pd\nimport matplotlib.pyplot as plt\n\n# \u9078\u624b\u306eID\u53d6\u5f97\ndef get_player_id(name):\n    return players.find_players_by_full_name(name)&#91;0]&#91;'id']\n\n# \u7d2f\u7a4d3PM\u30c7\u30fc\u30bf\u53d6\u5f97\ndef get_cumulative_fg3m(player_name):\n    player_id = get_player_id(player_name)\n    career = playercareerstats.PlayerCareerStats(player_id=player_id)\n    df = career.get_data_frames()&#91;0]\n    # \"TOT\"\uff08\u8907\u6570\u30c1\u30fc\u30e0\u5408\u7b97\uff09\u3092\u9664\u5916\n    df = df&#91;~df&#91;\"TEAM_ABBREVIATION\"].str.contains(\"TOT\", na=False)]\n    # \u30b7\u30fc\u30ba\u30f3\u3054\u3068\u306b3PM\u3092\u5408\u8a08\n    df = df.groupby(\"SEASON_ID\", as_index=False)&#91;&#91;\"FG3M\"]].sum()\n    # \u7d2f\u7a4d\u8a08\u7b97\n    df&#91;\"CUM_FG3M\"] = df&#91;\"FG3M\"].cumsum()\n\n    return df\n\n\n# \u30c7\u30fc\u30bf\u53d6\u5f97\ncurry_df = get_cumulative_fg3m(\"Stephen Curry\")\nharden_df = get_cumulative_fg3m(\"James Harden\")\n\n# \u30b0\u30e9\u30d5\u63cf\u753b\nplt.figure(figsize=(10, 6))\nplt.plot(curry_df&#91;\"SEASON_ID\"], curry_df&#91;\"CUM_FG3M\"], marker='o', label=\"Stephen Curry\")\nplt.plot(harden_df&#91;\"SEASON_ID\"], harden_df&#91;\"CUM_FG3M\"], marker='o', label=\"James Harden\")\nplt.title(\"Cumulative 3-Point Field Goals Made by Season\")\nplt.xlabel(\"Season\")\nplt.ylabel(\"Cumulative 3PM\")\nplt.xticks(rotation=45)\nplt.legend()\nplt.grid(True)\nplt.tight_layout()\nplt.show()\n<\/code><\/pre>\n\n\n\n<p>\u51fa\u529b\u7d50\u679c\u306f\u4ee5\u4e0b\u306b\u306a\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"989\" height=\"590\" src=\"https:\/\/hooper-lab.com\/wp-content\/uploads\/2025\/07\/image-3.png\" alt=\"\" class=\"wp-image-98\" srcset=\"https:\/\/hooper-lab.com\/wp-content\/uploads\/2025\/07\/image-3.png 989w, https:\/\/hooper-lab.com\/wp-content\/uploads\/2025\/07\/image-3-300x179.png 300w, https:\/\/hooper-lab.com\/wp-content\/uploads\/2025\/07\/image-3-768x458.png 768w\" sizes=\"auto, (max-width: 989px) 100vw, 989px\" \/><\/figure>\n\n\n\n<p>2024-25\u30b7\u30fc\u30ba\u30f3\u7d42\u4e86\u6642\u70b9\u3067\u30ab\u30ea\u30fc\u306f4058\u672c\u3001\u30cf\u30fc\u30c7\u30f3\u306f3,175\u672c\u306e\u6210\u529f\u3067\u3059\u3002\u30cf\u30fc\u30c7\u30f3\u306f\u6b74\u4ee3\uff12\u4f4d\u3067\u3059\u304c\u3001\uff11\u4f4d\u306e\u30ab\u30ea\u30fc\u3068\u30821,000\u672c\u8fd1\u304f\u5dee\u304c\u3042\u308b\u3068\u3044\u3046\u306e\u306f\u30ab\u30ea\u30fc\u304c\u53f2\u4e0a\u6700\u9ad8\u306e\u30b7\u30e5\u30fc\u30bf\u30fc\u3067\u3042\u308b\u3053\u3068\u3092\u6570\u5024\u304c\u7269\u8a9e\u3063\u3066\u3044\u307e\u3059\u306d\u3002<\/p>\n\n\n\n<p>\u4e0a\u8a18\u306e\u30d7\u30ed\u30b0\u30e9\u30e0\u306e\u5185\u5bb9\u306f\u73fe\u6bb5\u968e\u3067\u7406\u89e3\u3067\u304d\u306a\u304f\u3066\u3082\u5168\u304f\u554f\u984c\u3054\u3056\u3044\u307e\u305b\u3093\uff01\u9806\u3092\u8ffd\u3063\u3066\u9032\u3081\u3066\u3044\u3051\u3070\u57fa\u790e\u7de8\u7d42\u4e86\u5f8c\u306b\u306f\u81ea\u5206\u3067\u30d7\u30ed\u30b0\u30e9\u30e0\u3092\u8a18\u8ff0\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u3063\u3066\u3044\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>Python\u306f\u300cNBA\u30c7\u30fc\u30bf\u5206\u6790\u300d\u306e\u6700\u5f37\u30d1\u30fc\u30c8\u30ca\u30fc<\/strong><\/h4>\n\n\n\n<p>Python\u3092\u4f7f\u3048\u3070\u3001NBA\u306e\u81a8\u5927\u306a\u30c7\u30fc\u30bf\u3092\u81ea\u5206\u3067\u53d6\u5f97\u3057\u3001\u5206\u6790\u3057\u3001\u767a\u4fe1\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br>\u300c\u305f\u3060\u306e\u30d5\u30a1\u30f3\u300d\u304b\u3089\u3001\u300c\u30c7\u30fc\u30bf\u3092\u4f7f\u3063\u3066\u8a9e\u308c\u308b\u30d5\u30a1\u30f3\u300d\u306b\u306a\u308b\u305f\u3081\u306e\u7b2c\u4e00\u6b69\u3068\u3057\u3066\u3001Python\u306f\u6700\u5f37\u306e\u76f8\u68d2\u3067\u3059\u3002<\/p>\n\n\n\n<p>Python\u3063\u3066\u3069\u3046\u3059\u308c\u3070\u4f7f\u3048\u308b\u306e\uff1f\u3068\u3044\u3046\u65b9\u306b\u5411\u3051\u3066\u6b21\u56de\u306fJupyterLab\u3092\u4f7f\u3063\u3066\u5b9f\u969b\u306bPython\u3092\u52d5\u304b\u3057\u3066\u3044\u304d\u307e\u3059\u3002<\/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=93\">\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=108\">\u6b21\u9805\u76ee\u3078<\/a><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>~Python\u3068\u306f\uff1fNBA\u30c7\u30fc\u30bf\u5206\u6790\u306b\u3082\u4f7f\u3048\u308b\u3084\u3055\u3057\u3044\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e~ \u300cPython\u3063\u3066\u306a\u306b\uff1f\u300d Python\uff08\u30d1\u30a4\u30bd\u30f3\uff09\u306f\u3001\u4eca\u3044\u3061\u3070\u3093\u6ce8\u76ee\u3055\u308c\u3066\u3044\u308b\u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u8a00\u8a9e\u306e\u3072\u3068\u3064\u3067\u3059\u3002\u30b7\u30f3\u30d7\u30eb\u3067\u8aad\u307f\u3084\u3059\u304f\u3001\u521d\u5fc3\u8005\u306b\u3082 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":250,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,4],"tags":[14,15,8,11,9,12],"class_list":["post-96","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-10","category-learning","tag-curry","tag-harden","tag-nba","tag-python","tag-9","tag-12"],"_links":{"self":[{"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/posts\/96","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=96"}],"version-history":[{"count":8,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/posts\/96\/revisions"}],"predecessor-version":[{"id":260,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/posts\/96\/revisions\/260"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=\/wp\/v2\/media\/250"}],"wp:attachment":[{"href":"https:\/\/hooper-lab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=96"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=96"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/hooper-lab.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=96"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}