Title: copy_to_readonly_numpy_array needlessly copies pandas series objects · Issue #1081 · plotly/plotly.py · GitHub
Open Graph Title: copy_to_readonly_numpy_array needlessly copies pandas series objects · Issue #1081 · plotly/plotly.py
X Title: copy_to_readonly_numpy_array needlessly copies pandas series objects · Issue #1081 · plotly/plotly.py
Description: the function _plotly_utils.basevalidators.copy_to_readonly_numpy_array performs a full copy of pd.Series objects which contain existing np.ndarray data as the values attribute. we could utilize the values attribute to dramatically speed ...
Open Graph Description: the function _plotly_utils.basevalidators.copy_to_readonly_numpy_array performs a full copy of pd.Series objects which contain existing np.ndarray data as the values attribute. we could utilize the...
X Description: the function _plotly_utils.basevalidators.copy_to_readonly_numpy_array performs a full copy of pd.Series objects which contain existing np.ndarray data as the values attribute. we could utilize the...
Opengraph URL: https://github.com/plotly/plotly.py/issues/1081
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"copy_to_readonly_numpy_array needlessly copies pandas series objects","articleBody":"the function `_plotly_utils.basevalidators.copy_to_readonly_numpy_array` performs a full copy of `pd.Series` objects which contain existing `np.ndarray` data as the `values` attribute. we could utilize the `values` attribute to dramatically speed up trace generation, especially for large dataframes.\r\n\r\n*environment*: `plotly` version `3.1.0`. macos high sierra 10.13.6. `plotly` installation via `conda`\r\n\r\nworking example:\r\n\r\n```python\r\nimport plotly\r\nimport _plotly_utils.basevalidators\r\nimport numpy\r\n\r\nprint('plotly version: {}'.format(plotly.__version__))\r\n\r\ndf = pd.DataFrame({'x': np.random.randint(0, 100, 1000000)})\r\n\r\n# using `ipython` time magic\r\nprint('\\ncoercing series')\r\n%time v1 = _plotly_utils.basevalidators.copy_to_readonly_numpy_array(df.x)\r\n\r\nprint('\\naccessing np values directly')\r\n%time v2 = _plotly_utils.basevalidators.copy_to_readonly_numpy_array(df.x.values)\r\n```\r\n\r\nexample output:\r\n\r\n```\r\nplotly version: 3.1.0\r\n\r\ncoercing series\r\nCPU times: user 987 ms, sys: 35.5 ms, total: 1.02 s\r\nWall time: 854 ms\r\n\r\naccessing np values directly\r\nCPU times: user 1.45 ms, sys: 17 µs, total: 1.46 ms\r\nWall time: 1.49 ms\r\n```\r\n\r\nso a performance difference of approx 1000x","author":{"url":"https://github.com/RZachLamberty","@type":"Person","name":"RZachLamberty"},"datePublished":"2018-07-28T18:12:29Z","url":"https://github.com/plotly/plotly.py/issues/1081"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:476bd51d-3e83-9085-4928-a1e3339ef610 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8552:1201C:20A6873:2B5699F:6B017A12 |
| html-safe-nonce | 90175a8609ac9f504e3b35e892c52a9166285df796817713998ff8ba9fb8983e |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NTUyOjEyMDFDOjIwQTY4NzM6MkI1Njk5Rjo2QjAxN0ExMiIsInZpc2l0b3JfaWQiOiIyODA1MDk1ODA3NzAxODQyNDUwIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | aab0d591297f4417623e26625445ee4c56f25cc61280eef097c50340f436d848 |
| hovercard-subject-tag | issue:345468149 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/plotly/plotly.py/1081/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cc504e392e8ee963c9a86bf1d3159a65439d847ee7ab0a887b84a6804fb96fad/plotly/plotly.py/issues/1081 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cc504e392e8ee963c9a86bf1d3159a65439d847ee7ab0a887b84a6804fb96fad/plotly/plotly.py/issues/1081 |
| og:image:alt | the function _plotly_utils.basevalidators.copy_to_readonly_numpy_array performs a full copy of pd.Series objects which contain existing np.ndarray data as the values attribute. we could utilize the... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | RZachLamberty |
| hostname | github.com |
| expected-hostname | github.com |
| None | cc5dfdd32f62ebd3223cab3af3aa2b268d3605218237326a48a99d1efd89495c |
| turbo-cache-control | no-preview |
| go-import | github.com/plotly/plotly.py git https://github.com/plotly/plotly.py.git |
| octolytics-dimension-user_id | 5997976 |
| octolytics-dimension-user_login | plotly |
| octolytics-dimension-repository_id | 14579099 |
| octolytics-dimension-repository_nwo | plotly/plotly.py |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 14579099 |
| octolytics-dimension-repository_network_root_nwo | plotly/plotly.py |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 8c77c9e8439031ad54c75a250694842892f693e1 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width