{"id":91465,"date":"2024-03-21T13:55:20","date_gmt":"2024-03-21T04:55:20","guid":{"rendered":"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/"},"modified":"2024-03-28T06:13:20","modified_gmt":"2024-03-27T21:13:20","slug":"python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95","status":"publish","type":"post","link":"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/","title":{"rendered":"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>Excel \u30c7\u30fc\u30bf\u3092 Python \u3067\u6271\u3046\u306b\u306f\u3001pandas\u3001openpyxl \u306a\u3069\u306e\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3068\u3088\u3044\u3067\u3059\u3002\u307e\u305a\u3001\u305d\u308c\u3089\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code>pip install pandas\r\npip install openpyxl\r\n<\/code><\/pre>\n<p>\u307e\u305a\u3001\u5fc5\u8981\u306a\u30d1\u30c3\u30b1\u30fc\u30b8\u3092\u30a4\u30f3\u30dd\u30fc\u30c8\u3057\u307e\u3059\u3002<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\r\n<span class=\"hljs-keyword\">from<\/span> openpyxl <span class=\"hljs-keyword\">import<\/span> load_workbook\r\n<\/code><\/pre>\n<p>Excel\u30c7\u30fc\u30bf\u3092\u8aad\u307f\u8fbc\u3080\uff1a<\/p>\n<pre class=\"post-pre\"><code>df = pd.read_excel(<span class=\"hljs-string\">'data.xlsx'<\/span>)\r\n<\/code><\/pre>\n<p>\u30a8\u30af\u30bb\u30eb\u30c7\u30fc\u30bf\u51e6\u7406\uff1a<\/p>\n<pre class=\"post-pre\"><code><span class=\"hljs-comment\"># \u9009\u62e9\u67d0\u4e00\u5217\u6570\u636e<\/span>\r\ncol_data = df[<span class=\"hljs-string\">'\u5217\u540d'<\/span>]\r\n\r\n<span class=\"hljs-comment\"># \u9009\u62e9\u67d0\u4e00\u884c\u6570\u636e<\/span>\r\nrow_data = df.loc[\u884c\u7d22\u5f15]\r\n\r\n<span class=\"hljs-comment\"># \u8fc7\u6ee4\u6570\u636e<\/span>\r\nfiltered_data = df[df[<span class=\"hljs-string\">'\u5217\u540d'<\/span>] &gt; <span class=\"hljs-number\">10<\/span>]\r\n\r\n<span class=\"hljs-comment\"># \u6dfb\u52a0\u65b0\u7684\u5217<\/span>\r\ndf[<span class=\"hljs-string\">'\u65b0\u5217\u540d'<\/span>] = df[<span class=\"hljs-string\">'\u5217\u540d1'<\/span>] + df[<span class=\"hljs-string\">'\u5217\u540d2'<\/span>]\r\n\r\n<span class=\"hljs-comment\"># \u5220\u9664\u67d0\u4e00\u5217<\/span>\r\ndf.drop(<span class=\"hljs-string\">'\u5217\u540d'<\/span>, axis=<span class=\"hljs-number\">1<\/span>, inplace=<span class=\"hljs-literal\">True<\/span>)\r\n\r\n<span class=\"hljs-comment\"># \u66f4\u65b0\u67d0\u4e00\u5217\u6570\u636e<\/span>\r\ndf.loc[\u884c\u7d22\u5f15, <span class=\"hljs-string\">'\u5217\u540d'<\/span>] = \u503c\r\n\r\n<span class=\"hljs-comment\"># \u4fdd\u5b58\u6570\u636e\u5230\u65b0\u7684Excel\u6587\u4ef6<\/span>\r\ndf.to_excel(<span class=\"hljs-string\">'new_data.xlsx'<\/span>, index=<span class=\"hljs-literal\">False<\/span>)  <span class=\"hljs-comment\"># index=False\u8868\u793a\u4e0d\u4fdd\u5b58\u884c\u7d22\u5f15<\/span>\r\n\r\n<span class=\"hljs-comment\"># \u66f4\u65b0\u5df2\u6709\u7684Excel\u6587\u4ef6<\/span>\r\n<span class=\"hljs-keyword\">with<\/span> pd.ExcelWriter(<span class=\"hljs-string\">'data.xlsx'<\/span>, mode=<span class=\"hljs-string\">'a'<\/span>) <span class=\"hljs-keyword\">as<\/span> writer:\r\n    df.to_excel(writer, sheet_name=<span class=\"hljs-string\">'Sheet1'<\/span>, index=<span class=\"hljs-literal\">False<\/span>)\r\n<\/code><\/pre>\n<p>Pandas\u30e9\u30a4\u30d6\u30e9\u30ea\u304c\u63d0\u4f9b\u3059\u308b\u5404\u7a2e\u306e\u95a2\u6570\u3084\u624b\u6cd5\u3092\u4f7f\u7528\u3057\u3066\u3001Excel\u30c7\u30fc\u30bf\u306e\u51e6\u7406\u3068\u5206\u6790\u3092\u884c\u3044\u3001openpyxl\u30e9\u30a4\u30d6\u30e9\u30ea\u3067Excel\u30d5\u30a1\u30a4\u30eb\u306e\u8aad\u307f\u66f8\u304d\u3092\u884c\u3044\u307e\u3059\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Excel \u30c7\u30fc\u30bf\u3092 Python \u3067\u6271\u3046\u306b\u306f\u3001pandas\u3001openpyxl \u306a\u3069\u306e\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3068\u3088\u3044\u3067\u3059\u3002\u307e\u305a\u3001\u305d\u308c\u3089\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002 pip install pandas pip [&hellip;]<\/p>\n","protected":false},"author":9,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-91465","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v21.5 (Yoast SEO v21.5) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5 - Blog - Silicon Cloud<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.silicloud.com\/ja\/blog\/python\u3067excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\/\" \/>\n<meta property=\"og:locale\" content=\"ja_JP\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\" \/>\n<meta property=\"og:description\" content=\"Excel \u30c7\u30fc\u30bf\u3092 Python \u3067\u6271\u3046\u306b\u306f\u3001pandas\u3001openpyxl \u306a\u3069\u306e\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3068\u3088\u3044\u3067\u3059\u3002\u307e\u305a\u3001\u305d\u308c\u3089\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002 pip install pandas pip [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.silicloud.com\/ja\/blog\/python\u3067excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\/\" \/>\n<meta property=\"og:site_name\" content=\"Blog - Silicon Cloud\" \/>\n<meta property=\"article:published_time\" content=\"2024-03-21T04:55:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-03-27T21:13:20+00:00\" \/>\n<meta name=\"author\" content=\"\u590f\u6a39, \u98a8\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u57f7\u7b46\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u590f\u6a39, \u98a8\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/\",\"name\":\"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5 - Blog - Silicon Cloud\",\"isPartOf\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\"},\"datePublished\":\"2024-03-21T04:55:20+00:00\",\"dateModified\":\"2024-03-27T21:13:20+00:00\",\"author\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/#breadcrumb\"},\"inLanguage\":\"ja\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.silicloud.com\/ja\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#website\",\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/\",\"name\":\"Blog - Silicon Cloud\",\"description\":\"\",\"inLanguage\":\"ja\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d\",\"name\":\"\u590f\u6a39, \u98a8\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g\",\"caption\":\"\u590f\u6a39, \u98a8\"},\"url\":\"https:\/\/www.silicloud.com\/ja\/blog\/author\/natsukikaze\/\"},{\"@type\":\"ImageObject\",\"inLanguage\":\"ja\",\"@id\":\"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/#local-main-organization-logo\",\"url\":\"\",\"contentUrl\":\"\",\"caption\":\"Blog - Silicon Cloud\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5 - Blog - Silicon Cloud","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.silicloud.com\/ja\/blog\/python\u3067excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\/","og_locale":"ja_JP","og_type":"article","og_title":"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5","og_description":"Excel \u30c7\u30fc\u30bf\u3092 Python \u3067\u6271\u3046\u306b\u306f\u3001pandas\u3001openpyxl \u306a\u3069\u306e\u30b5\u30fc\u30c9\u30d1\u30fc\u30c6\u30a3\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u4f7f\u3046\u3068\u3088\u3044\u3067\u3059\u3002\u307e\u305a\u3001\u305d\u308c\u3089\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3092\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3057\u307e\u3059\u3002 pip install pandas pip [&hellip;]","og_url":"https:\/\/www.silicloud.com\/ja\/blog\/python\u3067excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5\/","og_site_name":"Blog - Silicon Cloud","article_published_time":"2024-03-21T04:55:20+00:00","article_modified_time":"2024-03-27T21:13:20+00:00","author":"\u590f\u6a39, \u98a8","twitter_card":"summary_large_image","twitter_misc":{"\u57f7\u7b46\u8005":"\u590f\u6a39, \u98a8"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/","url":"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/","name":"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5 - Blog - Silicon Cloud","isPartOf":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website"},"datePublished":"2024-03-21T04:55:20+00:00","dateModified":"2024-03-27T21:13:20+00:00","author":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d"},"breadcrumb":{"@id":"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/#breadcrumb"},"inLanguage":"ja","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.silicloud.com\/ja\/blog\/"},{"@type":"ListItem","position":2,"name":"Python\u3067Excel\u30c7\u30fc\u30bf\u3092\u51e6\u7406\u3059\u308b\u65b9\u6cd5"}]},{"@type":"WebSite","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#website","url":"https:\/\/www.silicloud.com\/ja\/blog\/","name":"Blog - Silicon Cloud","description":"","inLanguage":"ja"},{"@type":"Person","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/4e591db2661c4cc425470b461259391d","name":"\u590f\u6a39, \u98a8","image":{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/65e0ff40534461b1fa000382dc194e1716f793ab0bcb218ac3c40895551a08c5?s=96&d=mm&r=g","caption":"\u590f\u6a39, \u98a8"},"url":"https:\/\/www.silicloud.com\/ja\/blog\/author\/natsukikaze\/"},{"@type":"ImageObject","inLanguage":"ja","@id":"https:\/\/www.silicloud.com\/ja\/blog\/python%e3%81%a7excel%e3%83%87%e3%83%bc%e3%82%bf%e3%82%92%e5%87%a6%e7%90%86%e3%81%99%e3%82%8b%e6%96%b9%e6%b3%95\/#local-main-organization-logo","url":"","contentUrl":"","caption":"Blog - Silicon Cloud"}]}},"_links":{"self":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/91465","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/users\/9"}],"replies":[{"embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/comments?post=91465"}],"version-history":[{"count":2,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/91465\/revisions"}],"predecessor-version":[{"id":201324,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/posts\/91465\/revisions\/201324"}],"wp:attachment":[{"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/media?parent=91465"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/categories?post=91465"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.silicloud.com\/ja\/blog\/wp-json\/wp\/v2\/tags?post=91465"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}