{"action":"created","issue":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/12640","repository_url":"https://api.github.com/repos/pandas-dev/pandas","labels_url":"https://api.github.com/repos/pandas-dev/pandas/issues/12640/labels{/name}","comments_url":"https://api.github.com/repos/pandas-dev/pandas/issues/12640/comments","events_url":"https://api.github.com/repos/pandas-dev/pandas/issues/12640/events","html_url":"https://github.com/pandas-dev/pandas/issues/12640","id":141268316,"number":12640,"title":"API: add top-level functions as method","user":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/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":183784729,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Master%20Tracker","name":"Master Tracker","color":"fbca04","default":false},{"id":13098779,"url":"https://api.github.com/repos/pandas-dev/pandas/labels/Reshaping","name":"Reshaping","color":"02d7e1","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/pandas-dev/pandas/milestones/32","html_url":"https://github.com/pandas-dev/pandas/milestone/32","labels_url":"https://api.github.com/repos/pandas-dev/pandas/milestones/32/labels","id":933188,"number":32,"title":"Next Major Release","description":"after 0.18.0 of course","creator":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"open_issues":1054,"closed_issues":170,"state":"open","created_at":"2015-01-13T10:53:19Z","updated_at":"2017-02-24T20:36:52Z","due_on":"2017-08-31T07:00:00Z","closed_at":null},"comments":3,"created_at":"2016-03-16T13:04:54Z","updated_at":"2017-02-25T23:40:56Z","closed_at":null,"body":"xref https://github.com/pydata/pandas/pull/12578\r\n\r\nso its pretty easy to add (and eventually deprecate) certain top-level functions that could/should be methods. Promotes a cleaner syntax and method chaining.\r\n\r\nIn 0.18.1 would propose adding these, deprecating in 0.19.0.\r\n\r\nThis would eliminate the ability to use directly with `np.ndarrays`, but I view this is as a positive (note we effectively did this for the `.rolling/expanding/ewm` with `np.ndarrays` as well, though deprecated for a while).\r\n- [ ] `pd.crosstab` (DataFrame)\r\n- [ ] `pd.melt` (DataFrame) (xref #14876)\r\n- [ ] `pd.pivot_table` (might need a new name as would be confusing with `DataFrame.pivot`)\r\n- [ ] `pd.get_dummies` (both)\r\n- [ ] `pd.cut/qcut` (only on Series)\r\n"},"comment":{"url":"https://api.github.com/repos/pandas-dev/pandas/issues/comments/282520937","html_url":"https://github.com/pandas-dev/pandas/issues/12640#issuecomment-282520937","issue_url":"https://api.github.com/repos/pandas-dev/pandas/issues/12640","id":282520937,"user":{"login":"jreback","id":953992,"avatar_url":"https://avatars.githubusercontent.com/u/953992?v=3","gravatar_id":"","url":"https://api.github.com/users/jreback","html_url":"https://github.com/jreback","followers_url":"https://api.github.com/users/jreback/followers","following_url":"https://api.github.com/users/jreback/following{/other_user}","gists_url":"https://api.github.com/users/jreback/gists{/gist_id}","starred_url":"https://api.github.com/users/jreback/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jreback/subscriptions","organizations_url":"https://api.github.com/users/jreback/orgs","repos_url":"https://api.github.com/users/jreback/repos","events_url":"https://api.github.com/users/jreback/events{/privacy}","received_events_url":"https://api.github.com/users/jreback/received_events","type":"User","site_admin":false},"created_at":"2017-02-25T23:40:56Z","updated_at":"2017-02-25T23:40:56Z","body":"@ResidentMario conceptually this is *very* easy, (look at something like ``.unstack()``) or this:\r\n\r\n```\r\ndef melt(self, ....):\r\n    from pandas.core.reshape import melt\r\n    return melt(self, ....)\r\n```\r\n\r\nBUT I didn't put a doc-string. And you cannot import things directly at the top-level in ``core/frame.py``. It wouldn't slow down initialization much, the issue is dependencies (e.g. these modules import DataFrame, so they can't be imported directly.\r\n\r\nso here's a way to do this.\r\n\r\ncreate ``DataFrame.melt`` (like above), but use a ``_shared_docs`` doc-string (and define it *in* ``core/frame.py``). Then you can set the doc-string directly in ``pandas.core.reshape.melt`` directly.\r\n\r\nI think this is a nice pattern that will work."}}
{"actor":{"display_login":"jreback"}}