{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/19917","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19917/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19917/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19917/events","html_url":"https://github.com/pandas-dev/pandas/issues/19917","id":300394224,"number":19917,"title":"Styler extremely slow","user":{"login":"N2ITN","id":12092115,"avatar_url":"https://avatars1.githubusercontent.com/u/12092115?v=4","gravatar_id":"","url":"https://api.github.com/users/N2ITN","html_url":"https://github.com/N2ITN","followers_url":"https://api.github.com/users/N2ITN/followers","following_url":"https://api.github.com/users/N2ITN/following{/other_user}","gists_url":"https://api.github.com/users/N2ITN/gists{/gist_id}","starred_url":"https://api.github.com/users/N2ITN/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/N2ITN/subscriptions","organizations_url":"https://api.github.com/users/N2ITN/orgs","repos_url":"https://api.github.com/users/N2ITN/repos","events_url":"https://api.github.com/users/N2ITN/events{/privacy}","received_events_url":"https://api.github.com/users/N2ITN/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-02-26T21:01:02Z","updated_at":"2018-02-26T21:12:54Z","closed_at":null,"author_association":"NONE","body":"#### Code Sample\r\n\r\n```python\r\ndef highlighter(col):\r\n    '''\r\n    Highlights rows in `highlight_map` keys where df[`highlight map` values]==1\r\n    '''\r\n\r\n    highlight_map = {\r\n        'Service Type': 'ServiceType_Added',\r\n        'Store #': 'Store_Added',\r\n    }\r\n    if col.name in highlight_map:\r\n        vals = [\r\n            True if final[highlight_map[col.name]][v] else False\r\n            for v in col.index.tolist()\r\n        ]\r\n        return ['background-color: yellow' if v else '' for v in vals]\r\n    else:\r\n        return [''] * len(col)\r\n    \r\nstyled = final.style.apply(highlighter)\r\nstyled.to_excel('highlights.xlsx', engine='openpyxl') \r\n\r\n```\r\n#### Problem description\r\n\r\nHere I have some conditional highlighting on a df with 18k rows. The issue is that despite preceding complex operations on the df (such as conditional merges and `df.apply` by row) taking ~300ms at the most, the `Styler.apply` part takes over two minutes. I realize this feature is in development but I am wondering if there is a way to make it faster or if this is a known issue. \r\n\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/368652252","html_url":"https://github.com/pandas-dev/pandas/issues/19917#issuecomment-368652252","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/19917","id":368652252,"user":{"login":"TomAugspurger","id":1312546,"avatar_url":"https://avatars3.githubusercontent.com/u/1312546?v=4","gravatar_id":"","url":"https://api.github.com/users/TomAugspurger","html_url":"https://github.com/TomAugspurger","followers_url":"https://api.github.com/users/TomAugspurger/followers","following_url":"https://api.github.com/users/TomAugspurger/following{/other_user}","gists_url":"https://api.github.com/users/TomAugspurger/gists{/gist_id}","starred_url":"https://api.github.com/users/TomAugspurger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TomAugspurger/subscriptions","organizations_url":"https://api.github.com/users/TomAugspurger/orgs","repos_url":"https://api.github.com/users/TomAugspurger/repos","events_url":"https://api.github.com/users/TomAugspurger/events{/privacy}","received_events_url":"https://api.github.com/users/TomAugspurger/received_events","type":"User","site_admin":false},"created_at":"2018-02-26T21:12:54Z","updated_at":"2018-02-26T21:12:54Z","author_association":"CONTRIBUTOR","body":"Is it `Styler.apply` that's slow, or your function, or the writer? Have you profiled it to get a sense for where the time being spent?\r\n\r\nNote that `Styler` builds up a list of tasks lazily. To actually run it you'll have to call `_compute`, so you'll want to profile something like\r\n\r\n```python\r\nstyled = final.style.apply(highlighter)._compute()\r\n```"}}
{"actor":{"display_login":"TomAugspurger"}}