{"id":1524,"date":"2019-05-27T12:54:54","date_gmt":"2019-05-27T03:54:54","guid":{"rendered":"http:\/\/idealive.jp\/blog\/?p=1524"},"modified":"2019-05-27T12:54:54","modified_gmt":"2019-05-27T03:54:54","slug":"python-pandas","status":"publish","type":"post","link":"https:\/\/idealive.jp\/blog\/2019\/05\/27\/python-pandas\/","title":{"rendered":"Python Pandas"},"content":{"rendered":"<p>Pandas\u3068\u306f<br \/>\nPython\u3067\u30c7\u30fc\u30bf\u5206\u6790\u3092\u52b9\u7387\u7684\u306b\u884c\u3046\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3002<br \/>\nPandas\u306f\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9(BSD\u30e9\u30a4\u30bb\u30f3\u30b9)\u3067\u516c\u958b\u3002<br \/>\n\u500b\u4eba\uff0f\u5546\u7528\u554f\u308f\u305a\u3001\u8ab0\u3067\u3082\u7121\u6599\u3067\u5229\u7528\u53ef\u80fd\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>Pandas\u3092\u4f7f\u7528\u3059\u308b\u3068\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u30fb\u7d71\u8a08\u91cf\u30fb\u30b0\u30e9\u30d5\u5316\u306a\u3069\u3001\u30c7\u30fc\u30bf\u5206\u6790\u306b\u95a2\u3059\u308b\u4f5c\u696d\u3092\u5bb9\u6613\u306b\u884c\u3046\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n\u975e\u5e38\u306b\u9ad8\u901f\u306b\u51e6\u7406\u3092\u884c\u3046\u3053\u3068\u304c\u3067\u304d\u308b\u3002<\/p>\n<p>\u30c7\u30fc\u30bf\u5206\u6790\u306f\u3001<br \/>\n\u6a5f\u68b0\u5b66\u7fd2\u3092\u884c\u3046\u307e\u3067\u306e\u524d\u51e6\u7406\uff08\u30c7\u30fc\u30bf\u306e\u8aad\u307f\u8fbc\u307f\u3001\u30af\u30ea\u30fc\u30cb\u30f3\u30b0\u3001\u6b20\u640d\u5024\u306e\u88dc\u5b8c\u3001\u6b63\u898f\u5316\u306a\u3069\uff09\u304c\u3001\u5168\u3066\u306e\u4f5c\u696d\u306e8\u30019\u5272\u3092\u5360\u3081\u308b\u3068\u8a00\u308f\u308c\u3066\u3044\u308b\u3002Pandas\u3092\u4f7f\u3046\u3068\u305d\u306e\u3088\u3046\u306a\u51e6\u7406\u304c\u52b9\u7387\u7684\u306b\u884c\u3048\u308b\u3088\u3046\u306b\u306a\u308b\u305f\u3081\u3001Python\u3067\u6a5f\u68b0\u5b66\u7fd2\u3092\u884c\u3046\u306b\u306f\u3001Pandas\u306f\u5fc5\u9808\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3068\u306a\u3063\u3066\u3044\u308b\u307f\u305f\u3044\u3067\u3059\u3002<\/p>\n<p>\u5229\u7528\u3059\u308b\u306b\u306f\uff1f<br \/>\nPandas\u3092\u5229\u7528\u3059\u308b\u306b\u306f\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3067\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u53ef\u80fd<br \/>\n$ pip install pandas<\/p>\n<p>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb\u304c\u3067\u304d\u305f\u3089import\u3092\u3059\u308b\u3002<br \/>\n(pandas\u3092\u4f7f\u7528\u3057\u305f\u3044\u3068\u304d\u306b\u30d7\u30ed\u30b0\u30e9\u30e0\u5074\u3067)<br \/>\nimport pandas as pd<\/p>\n<p>\u4e0a\u8a18\u3067\u3082\u8a18\u8f09\u3057\u307e\u3057\u305f\u304c\u3001\u30c7\u30fc\u30bf\u306e\u89e3\u6790\u3084\u7d71\u8a08\u306a\u3069\u3067\u4fbf\u5229\u3067\u8272\u3005\u306a\u4e8b\u304c\u9ad8\u901f\u3067\u5b9f\u73fe\u3067\u304d\u307e\u3059\u3002<br \/>\n\u4e0b\u8a18\u3067\u306f\u305d\u306e\u4e00\u90e8\u3092\u7d39\u4ecb\u3057\u307e\u3059\u3002<br \/>\n\uff08\u5916\u90e8\u30c7\u30fc\u30bf\uff08CSV, TSV\uff09\u306a\u3069\u3092\u8aad\u307f\u8fbc\u307f\u5b9f\u884c\u3082\u53ef\u80fd\uff09<\/p>\n<p>\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a<br \/>\n\u524d\u63d0\uff1a\u4e0b\u8a18\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u304c\u3042\u308b\u3068\u3057\u307e\u3059\u3002<br \/>\ndf = pd.DataFrame({<br \/>\n&#8216;sample1&#8217; : [1, 2, 11, 3, 12, 3],<br \/>\n&#8216;sample2&#8217; : [1, 1, 21, 3, 21, 3]<br \/>\n})<br \/>\n\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a\uff0a<\/p>\n<p>\u25c6\u7279\u5b9a\u90e8\u5206\u306e\u6307\u5b9a<br \/>\ndf.iloc[2,1]<br \/>\n\uff08\u5b9f\u884c\u7d50\u679c&#8211;&gt;21\uff09<br \/>\n\u25c6\u30c7\u30fc\u30bf\u306e\u7d71\u8a08\u91cf\u3092\u78ba\u8a8d\u3059\u308b<br \/>\ndf.describe()<br \/>\n\uff08\u5b9f\u884c\u7d50\u679c\u306f\u7d71\u8a08\u91cf\u304c\u8868\u793a\u3055\u308c\u307e\u3059\u3002count\u306f\u4ef6\u6570\u3001mean\u306f\u5e73\u5747\u5024\u3001std\u306f\u6a19\u6e96\u504f\u5dee\u3001min\u306f\u6700\u5c0f\u5024\u3001max\u306f\u6700\u5927\u5024\u2026\u306a\u3069\uff09<br \/>\n\u25c6\u5e73\u5747\u5024<br \/>\ndf.mean()<br \/>\n\u25c6\u4e2d\u592e\u5024<br \/>\ndf.median()<br \/>\n\u25c6\u5206\u6563<br \/>\ndf.var()<br \/>\n\u25c6\u30b0\u30e9\u30d5\u3092\u8868\u793a<br \/>\n\u3084\u308a\u65b9\u306f\u8272\u3005\u3042\u308b\u307f\u305f\u3044\u3067\u3059\u3002<br \/>\n\u25c6\u30c7\u30fc\u30bf\u52a0\u5de5<br \/>\ndf[&#8216;sample1&#8217;] = df[&#8216;sample1&#8217;] * 2<br \/>\ndf.astype(float)<\/p>\n<p>\u203b\u65b9\u6cd5\u306f\u4e00\u4f8b\u3067\u3059\u306e\u3067\u3001\u4ed6\u306b\u8a18\u8f09\u65b9\u6cd5\u306f\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<p>\u3053\u308c\u3092\u4f7f\u7528\u3059\u308b\u3068\u6570\u5024\u3092\u89e3\u6790\u3057\u3066\u3001\u4f55\u304b\u3092\u5c0e\u304f\u4e8b\u3082\u53ef\u80fd\u3067\u3059\u306d\u3002<br \/>\n\u66f8\u304f\u3060\u3051\u306f\u7c21\u5358\u3002\u6982\u8981\u3092\u6c7a\u5b9a\u3057\u3066\u8272\u3005\u306a\u4e8b\u3092\u6570\u5024\u5316\u3057\u3066\u3044\u304f\u306e\u304c\u3059\u3054\u304f\u96e3\u3057\u305d\u3046\u3067\u3059\u3002<\/p>\n<p>\u4ee5\u4e0a\u3001\u6a5f\u68b0\u5b66\u7fd2\u306e\u3053\u3068\u3092\u5c11\u3057\u66f8\u3044\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pandas\u3068\u306f Python\u3067\u30c7\u30fc\u30bf\u5206\u6790\u3092\u52b9\u7387\u7684\u306b\u884c\u3046\u305f\u3081\u306e\u30e9\u30a4\u30d6\u30e9\u30ea\u3002 Pandas\u306f\u30aa\u30fc\u30d7\u30f3\u30bd\u30fc\u30b9(BSD\u30e9\u30a4\u30bb\u30f3\u30b9)\u3067\u516c\u958b\u3002 \u500b\u4eba\uff0f\u5546\u7528\u554f\u308f\u305a\u3001\u8ab0\u3067\u3082\u7121\u6599\u3067\u5229\u7528\u53ef\u80fd\u3068\u306a\u3063\u3066\u3044\u307e\u3059\u3002 Pandas\u3092\u4f7f\u7528\u3059\u308b\u3068\u30c7\u30fc\u30bf&#8230;<a class=\"read-more-link button\" href=\"https:\/\/idealive.jp\/blog\/2019\/05\/27\/python-pandas\/\">\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":7,"featured_media":1525,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-1524","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1524"}],"collection":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/comments?post=1524"}],"version-history":[{"count":3,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1524\/revisions"}],"predecessor-version":[{"id":1528,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/posts\/1524\/revisions\/1528"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media\/1525"}],"wp:attachment":[{"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/media?parent=1524"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/categories?post=1524"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/idealive.jp\/blog\/wp-json\/wp\/v2\/tags?post=1524"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}