{"id":20865,"date":"2023-05-30T07:52:46","date_gmt":"2023-05-29T22:52:46","guid":{"rendered":"http:\/\/www.code-magagine.com\/?p=20865"},"modified":"2023-07-09T23:58:08","modified_gmt":"2023-07-09T14:58:08","slug":"%e3%80%90python%e3%80%91%e3%82%b9%e3%82%af%e3%83%ac%e3%82%a4%e3%83%94%e3%83%b3%e3%82%b0%e7%b5%90%e6%9e%9c%e3%82%92csv%e3%81%ab%e4%bf%9d%e5%ad%98%e3%81%99%e3%82%8b%e3%80%82","status":"publish","type":"post","link":"http:\/\/www.code-magagine.com\/?p=20865","title":{"rendered":"\u3010Python\u3011\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u7d50\u679c\u3092CSV\u306b\u4fdd\u5b58\u3059\u308b\u3002"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u524d\u63d0<\/h2>\n\n\n\n<p>\u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8f9e\u66f8\u306e\u914d\u5217\u5f62\u5f0f\u3067\u30b9\u30af\u30ec\u30d4\u30f3\u30b0\u7d50\u679c\u3092\u4f5c\u3063\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># \u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u7d50\u679c\ndictinary_list = [{'yatin': 80000, 'title': '\u65b0\u5bbf'}, {'yatin': 40000, 'title': '\u753a\u7530'}]<\/pre>\n\n\n\n<p>\u5177\u4f53\u7684\u306a\u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u7d50\u679c\u306e\u4f5c\u308a\u65b9\u306b\u3064\u3044\u3066\u306f\u4ee5\u4e0b\u306e\u8a18\u4e8b\u3067\u89e3\u8aac\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><blockquote class=\"wp-embedded-content\" data-secret=\"Kut7oFWRqh\"><a href=\"http:\/\/www.code-magagine.com\/?p=20845\">\u3010Python\u3011\u300cBeautifulSoup\u300d\u306b\u3064\u3044\u3066<\/a><\/blockquote><iframe class=\"wp-embedded-content\" sandbox=\"allow-scripts\" security=\"restricted\" style=\"position: absolute; clip: rect(1px, 1px, 1px, 1px);\" title=\"&#8220;\u3010Python\u3011\u300cBeautifulSoup\u300d\u306b\u3064\u3044\u3066&#8221; &#8212; \u30d7\u30ed\u30b0\u30e9\u30df\u30f3\u30b0\u30de\u30ac\u30b8\u30f3\" src=\"http:\/\/www.code-magagine.com\/?p=20845&#038;embed=true#?secret=f8AfZ0XrTU#?secret=Kut7oFWRqh\" data-secret=\"Kut7oFWRqh\" width=\"500\" height=\"282\" frameborder=\"0\" marginwidth=\"0\" marginheight=\"0\" scrolling=\"no\"><\/iframe><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5b9f\u88c5<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">\u30ea\u30b9\u30c8\u5f62\u5f0f\u3092\u8868\u306e\u5f62\u306b\u5909\u63db\u3059\u308b<\/h3>\n\n\n\n<p>pandas\u306eDataFrame\u3068\u3044\u3046\u30e1\u30bd\u30c3\u30c9\u3092\u4f7f\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">import pandas as pd\n\n# \u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u7d50\u679c\ndictinary_list = [{'yatin': 80000, 'title': '\u65b0\u5bbf'}, {'yatin': 40000, 'title': '\u753a\u7530'}]\n\ndf = pd.DataFrame(dictinary_list)<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8868\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u78ba\u8a8d<\/h3>\n\n\n\n<p>\u8868\u306e\u5f62\u306b\u5909\u63db\u3057\u305f\u30c7\u30fc\u30bf\u306f\u4ee5\u4e0b\u306e\u6587\u6cd5\u3067\u78ba\u8a8d\u3067\u304d\u307e\u3059\u3002<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.head())\n\n   yatin title\n0  80000    \u65b0\u5bbf\n1  40000    \u753a\u7530<\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">\u8868\u306e\u5927\u304d\u3055\u3092\u78ba\u8a8d<\/h3>\n\n\n\n<pre class=\"wp-block-preformatted\">print(df.shape)\n\n(2, 2)<\/pre>\n\n\n\n<p>\u4e0a\u8a18\u4f8b\u3067\u8a00\u3048\u3070\u3001\u8868\u304c2\u5217\u30012\u884c\u306b\u306a\u3063\u3066\u3044\u308b\u3068\u8a00\u3048\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">\u30c7\u30fc\u30bf\u4ef6\u6570\u3092\u53d6\u5f97\u3059\u308b\u3002<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">print(len(df.title))\n\n2<\/pre>\n\n\n\n<p>DataFrame\u306b\u306ftitile\u3068\u3044\u3046\u5c5e\u6027\u304c\u5fc5\u9808\u306b\u306a\u308b\u306e\u3067title\u306e\u500b\u6570\u3092\u8868\u793a\u3059\u308c\u3070\u3044\u3051\u307e\u3059\u3002<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">CSV\u306b\u5909\u63db\u3059\u308b\u3002<\/h4>\n\n\n\n<pre class=\"wp-block-preformatted\">df.to_csv('\u30d5\u30a1\u30a4\u30eb\u540d.csv', index=None, encoding='utf-8-sig')<\/pre>\n\n\n\n<div>\n<h4>index=None<\/h4>\n<div>\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u756a\u53f7\u3092\u51fa\u529b\u3057\u306a\u3044\u3068\u3044\u3046\u610f\u5473\u306b\u306a\u308a\u307e\u3059\u3002\uff08\u30c7\u30d5\u30a9\u30eb\u30c8\u3060\u30680\u304b\u3089\u63a1\u756a\u3055\u308c\u308b\u5024\u304c\u52dd\u624b\u306b\u4ed8\u4e0e\u3055\u308c\u3066\u3057\u307e\u3044\u307e\u3059\u3002\uff09<\/div>\n<h4>encoding='utf-8-sig<\/h4>\n<div>\u51fa\u529b\u30d5\u30a1\u30a4\u30eb\u306e\u6587\u5b57\u30b3\u30fc\u30c9\u3092UTF8\u306b\u3057\u307e\u3059\u3002\u3053\u308c\u3092\u6307\u5b9a\u3057\u306a\u3044\u3068Excel\u3067\u958b\u3044\u305f\u6642\u306b\u6587\u5b57\u5316\u3051\u3057\u3066\u3057\u307e\u3044\u307e\u3059\u3002<\/div>\n<\/div>\n\n\n\n<h2 class=\"wp-block-heading\">pandas\u3068csv\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u9055\u3044<\/h2>\n\n\n\n<p>\u7d50\u8ad6\u3068\u3057\u3066\u306f\u307b\u307c\u660e\u78ba\u306a\u9055\u3044\u306f\u306a\u3044\u3067\u3059\u304c\u4e16\u306e\u4e2d\u7684\u306b\u306fPandas\u3092\u4f7f\u3063\u3066CSV\u51fa\u529b\u3092\u4f7f\u3063\u305f\u65b9\u304c\u826f\u3044\u3068\u3044\u308f\u308c\u308b\u3053\u3068\u304c\u591a\u3044\u3067\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">CSV\u30e2\u30b8\u30e5\u30fc\u30eb<\/h3>\n\n\n\n<p>Python\u6a19\u6e96\u306eCSV\u51fa\u529b\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u3067\u3059\u3002Python\u6a19\u6e96\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u3055\u308c\u3066\u304a\u308a\u5225\u9014\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u4e0d\u8981\u306a\u306e\u3067\u8efd\u304f\u306a\u308b\u3068\u3044\u3046\u30e1\u30ea\u30c3\u30c8\u306f\u3042\u308a\u307e\u3059\u3002<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Pandas<\/h3>\n\n\n\n<p>CSV\u3060\u3051\u3067\u306a\u304f\u3001Excel\u3084JSON\u3001HTML\u306a\u3069\u69d8\u3005\u306a\u5f62\u5f0f\u306e\u30c7\u30fc\u30bf\u3092\u6271\u3046\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u307e\u305f\u3001AI\u306e\u305f\u3081\u306e\u30c7\u30fc\u30bf\u524d\u51e6\u7406\u306a\u3069\u69d8\u3005\u306a\u7528\u9014\u306b\u6d3b\u7528\u3055\u308c\u3066\u3044\u305f\u308a\u3057\u307e\u3059\u3002CSV\u30e2\u30b8\u30e5\u30fc\u30eb\u3060\u3068\u4e8c\u624b\u9593\u304b\u304b\u308b\u3053\u3068\u304c\u3001Pandas\u3060\u3068to_csv\u306e\u3072\u3068\u624b\u9593\u3067\u5b9f\u88c5\u53ef\u80fd\u3067\u3059\u3002\uff08\u305f\u3060\u3001\u53b3\u5bc6\u306b\u3044\u3048\u3070DataFrame\u3078\u306e\u5909\u63db\u304c\u3042\u308b\u306e\u3067\u305d\u3053\u307e\u3067\u52b4\u529b\u306f\u5909\u308f\u3089\u306a\u3044\u304b\u3082\u3067\u3059\u3002\uff09<\/p>\n","protected":false},"excerpt":{"rendered":"\u524d\u63d0 \u4ee5\u4e0b\u306e\u3088\u3046\u306b\u8f9e\u66f8\u306e\u914d\u5217\u5f62\u5f0f\u3067\u30b9\u30af\u30ec\u30d4\u30f3\u30b0\u7d50\u679c\u3092\u4f5c\u3063\u3066\u304a\u304f\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002 # \u30b9\u30af\u30ec\u30a4\u30d4\u30f3\u30b0\u7d50\u679c dictinary_list = [{'yatin': 80000, 'title': '\u65b0\u5bbf'}, {'yatin [&hellip;]","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[47],"tags":[],"_links":{"self":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/20865"}],"collection":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=20865"}],"version-history":[{"count":9,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/20865\/revisions"}],"predecessor-version":[{"id":21947,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=\/wp\/v2\/posts\/20865\/revisions\/21947"}],"wp:attachment":[{"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=20865"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=20865"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.code-magagine.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=20865"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}