{"action":"created","issue":{"url":"https://api.github.com/repos/pydata/pandas/issues/6683","labels_url":"https://api.github.com/repos/pydata/pandas/issues/6683/labels{/name}","comments_url":"https://api.github.com/repos/pydata/pandas/issues/6683/comments","events_url":"https://api.github.com/repos/pydata/pandas/issues/6683/events","html_url":"https://github.com/pydata/pandas/issues/6683","id":29920664,"number":6683,"title":"Poor performance for .loc and .iloc compared to .ix","user":{"login":"brownmk","id":6635285,"avatar_url":"https://avatars.githubusercontent.com/u/6635285?v=3","gravatar_id":"","url":"https://api.github.com/users/brownmk","html_url":"https://github.com/brownmk","followers_url":"https://api.github.com/users/brownmk/followers","following_url":"https://api.github.com/users/brownmk/following{/other_user}","gists_url":"https://api.github.com/users/brownmk/gists{/gist_id}","starred_url":"https://api.github.com/users/brownmk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brownmk/subscriptions","organizations_url":"https://api.github.com/users/brownmk/orgs","repos_url":"https://api.github.com/users/brownmk/repos","events_url":"https://api.github.com/users/brownmk/events{/privacy}","received_events_url":"https://api.github.com/users/brownmk/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2014-03-21T17:51:15Z","updated_at":"2015-10-08T09:52:29Z","closed_at":"2014-03-21T18:24:30Z","body":"When using indices, we are encouraged to use .loc instead of .ix. Also the \"SettingWithCopyWarning:\" recommends us to use .loc instead.  But it seems the performance of .loc and .iloc is 20-30 times slower than .ix (I am using Pandas 0.13.1)\r\n\r\n.ix takes 4.54897093773 sec\r\n.iloc takes 111.531260967 sec\r\n.loc takes 92.8014230728 sec\r\n\r\nThe costs for .loc and .iloc seems too high. Thanks!\r\n-- test code ---\r\n#!/usr/bin/env python\r\nimport pandas as pd\r\nimport numpy as np\r\nimport time\r\n\r\nt=pd.DataFrame(data=np.zeros([100000,6]), columns=['A','B','C','D','E','F'])\r\nstart=time.time()\r\nfor i in t.index:\r\n    for j in ['A','B','C','D','E']:\r\n        t.ix[i,j]\r\nt1=time.time()\r\nprint t1-start\r\nfor i in xrange(100000):\r\n    for j in xrange(6):\r\n        t.iloc[i,j]\r\nt2=time.time()\r\nprint t2-t1\r\nfor i in t.index:\r\n    for j in ['A','B','C','D','E']:\r\n        t.loc[i,j]\r\nt3=time.time()\r\nprint t3-t2\r\n"},"comment":{"url":"https://api.github.com/repos/pydata/pandas/issues/comments/146477855","html_url":"https://github.com/pydata/pandas/issues/6683#issuecomment-146477855","issue_url":"https://api.github.com/repos/pydata/pandas/issues/6683","id":146477855,"user":{"login":"xgdgsc","id":1189869,"avatar_url":"https://avatars.githubusercontent.com/u/1189869?v=3","gravatar_id":"","url":"https://api.github.com/users/xgdgsc","html_url":"https://github.com/xgdgsc","followers_url":"https://api.github.com/users/xgdgsc/followers","following_url":"https://api.github.com/users/xgdgsc/following{/other_user}","gists_url":"https://api.github.com/users/xgdgsc/gists{/gist_id}","starred_url":"https://api.github.com/users/xgdgsc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/xgdgsc/subscriptions","organizations_url":"https://api.github.com/users/xgdgsc/orgs","repos_url":"https://api.github.com/users/xgdgsc/repos","events_url":"https://api.github.com/users/xgdgsc/events{/privacy}","received_events_url":"https://api.github.com/users/xgdgsc/received_events","type":"User","site_admin":false},"created_at":"2015-10-08T09:52:29Z","updated_at":"2015-10-08T09:52:29Z","body":"Are you sure this is fixed? I still experience 30 time faster when using ix instead of loc when accessing with something like df.ix['row', 'col'] with pandas 0.16.2. "}}