{"action":"opened","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/20557","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/20557/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/20557/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/20557/events","html_url":"https://github.com/pandas-dev/pandas/issues/20557","id":310145944,"number":20557,"title":"API: Allow extension dtypes in NDFrame.astype","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},"labels":[{"id":35818298,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/API%20Design","name":"API Design","color":"AD7FA8","default":false},{"id":849023693,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/ExtensionArray","name":"ExtensionArray","color":"6138b5","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-30T19:14:25Z","updated_at":"2018-03-30T19:14:25Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Do we want to support this? If so, how?\r\n\r\n```python\r\nIn [22]: from pandas.tests.extension.decimal.array import DecimalArray, decimal, DecimalDtype\r\n\r\nIn [23]: ser = pd.Series(['1.0', '1.1'])\r\n```\r\n\r\nSome issues:\r\n\r\n1. unlikely, but multiple extension types could have the same name, so `ser.astype('decimal')` might be ambiguous. Let's refuse to guess, and require that an instance or subclass of `ExtensionDtype` be provided. So `DecimalDtype`\r\n2. How to go from dtype to array type? (we can currently go array to dtype, but not the other way around)\r\n3. How to get the Array's \"parser\" (something like `to_decimal`).\r\n\r\nA solution to 2 is to require that an `ExtensionDtype` have a property `array_type` that returns the class it's a type for.\r\n\r\n```\r\nclass DecimalDtype(ExtensionDtype):\r\n    @property\r\n    def array_type(self): return DecimalArray\r\n```\r\n\r\nI think that's fine. It means you can't use the same type for multiple arrays, but whatever.\r\n\r\nA solution to 3 is a bit harder... Having an arbitrary \"try to parse this sequence of things, maybe coercing / erroring\" might be generally useful (e.g. reading in from a CSV). Thoughts here? I don't think this needs to block 0.23."}}
{"actor":{"display_login":"TomAugspurger"}}