Title: make Axis.apply return non-object dtype if possible · Issue #882 · larray-project/larray · GitHub
Open Graph Title: make Axis.apply return non-object dtype if possible · Issue #882 · larray-project/larray
X Title: make Axis.apply return non-object dtype if possible · Issue #882 · larray-project/larray
Description: this is usually called via Array.set_labels(axis, func) The trick is to either use np.vectorize instead of frompyfunc (which always returns an object array) or do it manually via: array([func(label) for label in self.labels]). The later ...
Open Graph Description: this is usually called via Array.set_labels(axis, func) The trick is to either use np.vectorize instead of frompyfunc (which always returns an object array) or do it manually via: array([func(label...
X Description: this is usually called via Array.set_labels(axis, func) The trick is to either use np.vectorize instead of frompyfunc (which always returns an object array) or do it manually via: array([func(label...
Opengraph URL: https://github.com/larray-project/larray/issues/882
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"make Axis.apply return non-object dtype if possible","articleBody":"this is usually called via Array.set_labels(axis, func)\r\n\r\nThe trick is to either use np.vectorize instead of frompyfunc (which always returns an object array) or do it manually via:\r\narray([func(label) for label in self.labels]). The later will probably handle more cases (we can make it handle mixed type labels while I am unsure vectorize would handle that properly):\r\n\r\n```python\r\n>>> mixed = np.array([2000, 2001, 'total'], dtype=object)\r\n>>> def cap(x):\r\n... return x.capitalize() if isinstance(x, str) else x\r\n>>> vcap = np.vectorize(cap)\r\n>>> vcap(mixed)\r\nValueError: invalid literal for int() with base 10: 'Total'\r\n>>> np.array([cap(l) for l in mixed])\r\narray(['2000', '2001', 'Total'],\r\n dtype='\u003cU11')\r\n>>> # but we actually need to provide an explicit dtype in that case\r\n>>> np.array([cap(l) for l in mixed], dtype=object)\r\narray([2000, 2001, 'Total'], dtype=object)\r\n```\r\n\r\nFor performance reasons, we could special case this when issubclass(func, np.generic) to do astype(func) instead","author":{"url":"https://github.com/gdementen","@type":"Person","name":"gdementen"},"datePublished":"2020-08-04T12:43:00Z","url":"https://github.com/larray-project/larray/issues/882"}
| 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:1a94729b-66b9-db43-bb15-8a6cd65f2c67 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8764:29A20E:22F7ECC:2F8C068:6B0029BC |
| html-safe-nonce | 7a29968d2bd23da494e6bc3517d451e54d4d73bcc2e2147f925d9ca67643e0f7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NzY0OjI5QTIwRToyMkY3RUNDOjJGOEMwNjg6NkIwMDI5QkMiLCJ2aXNpdG9yX2lkIjoiODcxMjY2MTQ1NDYyMjMwNDcwMCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 2cd175cb6c9bd7c40233566cd387f956e525e8436d04de2a7a4c19d1211ff958 |
| hovercard-subject-tag | issue:672763107 |
| 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/larray-project/larray/882/issue_layout |
| twitter:image | https://opengraph.githubassets.com/db56738a1205ff523e1af98c3b1b53ac305c99a23f3f14a77bbfc0aacc81087d/larray-project/larray/issues/882 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/db56738a1205ff523e1af98c3b1b53ac305c99a23f3f14a77bbfc0aacc81087d/larray-project/larray/issues/882 |
| og:image:alt | this is usually called via Array.set_labels(axis, func) The trick is to either use np.vectorize instead of frompyfunc (which always returns an object array) or do it manually via: array([func(label... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | gdementen |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7d0829bbde9e48b2486cb5dd6d147896eb01d32134627091f818958a935ef3f0 |
| turbo-cache-control | no-preview |
| go-import | github.com/larray-project/larray git https://github.com/larray-project/larray.git |
| octolytics-dimension-user_id | 26460981 |
| octolytics-dimension-user_login | larray-project |
| octolytics-dimension-repository_id | 16981067 |
| octolytics-dimension-repository_nwo | larray-project/larray |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 16981067 |
| octolytics-dimension-repository_network_root_nwo | larray-project/larray |
| 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 | f3f3a43ca095cdea3abbb394112e971f9fdb94fa |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width