3.\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u627e\u5230\u6307\u5b9a\u884c\u6570\u636e<\/strong><\/div>\n\u4f8b\u5982\u67e5\u627eA\u90e8\u95e8\u6240\u6709\u6210\u5458\u7684\u7684\u59d3\u540d\u548c\u5de5\u8d44\u6216\u8005\u5de5\u8d44\u4f4e\u4e8e3000\u7684\u4eba\uff1a<\/p>\n
\u4ee3\u7801\u5982\u4e0b\uff1a<\/p>\n
\"\"\"\u6839\u636e\u6761\u4ef6\u67e5\u8be2\u67d0\u884c\u6570\u636e\"\"\"\r\nimport pandas as pd #\u5bfc\u5165pandas\u5e93\r\n \r\nexcel_file = '.\/try.xlsx' #\u5bfc\u5165\u6587\u4ef6\r\ndata = pd.read_excel(excel_file) #\u8bfb\u5165\u6570\u636e\r\n \r\nprint(data.loc[data['\u90e8\u95e8'] == 'A', ['\u59d3\u540d', '\u5de5\u8d44']]) #\u90e8\u95e8\u4e3aA\uff0c\u6253\u5370\u59d3\u540d\u548c\u5de5\u8d44\r\nprint(data.loc[data['\u5de5\u8d44'] < 3000, ['\u59d3\u540d','\u5de5\u8d44']]) #\u67e5\u627e\u5de5\u8d44\u5c0f\u4e8e3000\u7684\u4eba<\/pre>\n\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n
<\/p>\n
\u82e5\u8981\u628a\u8fd9\u4e9b\u6570\u636e\u72ec\u7acb\u751f\u6210excel\u6587\u4ef6\u6216\u8005csv\u6587\u4ef6\uff1a<\/p>\n
\u6dfb\u52a0\u4ee5\u4e0b\u4ee3\u7801<\/p>\n
\"\"\"\u5bfc\u51fa\u4e3aexcel\u6216csv\u6587\u4ef6\"\"\"\r\n#\u5355\u6761\u4ef6\r\ndataframe_1 = data.loc[data['\u90e8\u95e8'] == 'A', ['\u59d3\u540d', '\u5de5\u8d44']]\r\n#\u5355\u6761\u4ef6\r\ndataframe_2 = data.loc[data['\u5de5\u8d44'] < 3000, ['\u59d3\u540d', '\u5de5\u8d44']]\r\n#\u591a\u6761\u4ef6\r\ndataframe_3 = data.loc[(data['\u90e8\u95e8'] == 'A')&(data['\u5de5\u8d44'] < 3000), ['\u59d3\u540d', '\u5de5\u8d44']]\r\n#\u5bfc\u51fa\u4e3aexcel\r\ndataframe_1.to_excel('dataframe_1.xlsx')\r\ndataframe_2.to_excel('dataframe_2.xlsx')<\/pre>\n4.\u627e\u51fa\u6307\u5b9a\u5217<\/strong><\/div>\ndata['columns'] #columns\u5373\u4f60\u9700\u8981\u7684\u5b57\u6bb5\u540d\u79f0\u5373\u53ef\r\n#\u6ce8\u610f\u8fd9\u5217\u7684columns\u4e0d\u80fd\u662findex\u7684\u540d\u79f0\r\n#\u5982\u679c\u8981\u6253\u5370index\u7684\u8bdd\u5c31data.index\r\ndata.columns #\u4e0e\u4e0a\u9762\u7684\u4e00\u6837<\/pre>\n\u4ee5\u4e0a\u5168\u8fc7\u7a0b\u7528\u5230\u7684\u5e93\uff1a<\/p>\n
pandas\uff0cxlrd , openpyxl<\/p>\n
5.\u627e\u51fa\u6307\u5b9a\u7684\u884c\u548c\u6307\u5b9a\u7684\u5217<\/strong><\/div>\n\u4e3b\u8981\u4f7f\u7528\u7684\u5c31\u662f\u51fd\u6570iloc<\/p>\n
data.iloc[:,:2] #\u5373\u5168\u90e8\u884c\uff0c\u524d\u4e24\u5217\u7684\u6570\u636e<\/pre>\n\u9017\u53f7\u524d\u662f\u884c\uff0c\u9017\u53f7\u540e\u662f\u5217\u7684\u8303\u56f4\uff0c\u5f88\u5bb9\u6613\u7406\u89e3<\/p>\n
6.\u5728\u89c4\u5b9a\u8303\u56f4\u5185\u627e\u51fa\u7b26\u5408\u6761\u4ef6\u7684\u6570\u636e<\/strong><\/div>\ndata.iloc[:10,:][data.\u5de5\u8d44>6000]<\/pre>\n\u8fd9\u6837\u5373\u53ef\u627e\u51fa\u524d11\u884c\u91cc\u5de5\u8d44\u5927\u4e8e6000\u7684\u6240\u6709\u4eba\u7684\u4fe1\u606f\u4e86<\/p>\n
\u5230\u6b64\u8fd9\u7bc7\u5173\u4e8epython pandas\u5e93\u8bfb\u53d6excel\/csv\u4e2d\u6307\u5b9a\u884c\u6216\u5217\u6570\u636e\u7684\u6587\u7ae0\u5c31\u4ecb\u7ecd\u5230\u8fd9\u4e86<\/p>\n","protected":false},"excerpt":{"rendered":"
\u5173\u952e\uff01\uff01\uff01\uff01\u4f7f\u7528loc\u51fd\u6570\u6765\u67e5\u627e\u3002 \u8bdd\u4e0d\u591a\u8bf4\uff0c\u76f4\u63a5\u6f14\u793a\uff1a \u6709\u4ee5\u4e0b\u540d\u4e3atry.xlsx\u8868\uff1a \u6761\u4ef6\uff1a\u9996\u5148\u5bfc\u5165\u7684\u6570\u636e […]<\/p>\n","protected":false},"author":1479,"featured_media":231815,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-237052","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/237052","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1479"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=237052"}],"version-history":[{"count":5,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/237052\/revisions"}],"predecessor-version":[{"id":237059,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/237052\/revisions\/237059"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/231815"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=237052"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=237052"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=237052"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}