{"action":"created","comment":{"url":"https://api.github.com/repos/hgrecco/pint/pulls/comments/214875823","pull_request_review_id":152017902,"id":214875823,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIxNDg3NTgyMw==","diff_hunk":"@@ -0,0 +1,333 @@\n+.. _pandas:\n+\n+Pandas support\n+==============\n+\n+It is convenient to use the `Pandas package`_ when dealing with numerical data, so Pint provides `PintArray`. A `PintArray` is a `Pandas Extension Array`_, which allows Pandas to recognise the Quantity and store it in Pandas DataFrames and Series.\n+\n+For this to work, we rely on `Pandas Extension Types`_ which are still experimental. As a result, we currently have to build the latest version of Pandas' master branch from source as documented in the `Pandas README`_.\n+\n+Basic example\n+-------------\n+\n+This example gives you the basics, but is slightly fiddly as you are not reading from a file. A more normal use case is given in `Reading a csv`_.\n+\n+To use Pint with Pandas, as stated above, firstly ensure that you have the latest version of Pandas installed. Then import the relevant packages and create an instance of a Pint Quantity:\n+\n+.. doctest::\n+\n+   >>> import pandas as pd\n+   >>> import numpy as np\n+   >>> import pint\n+   >>> from pint.pandas_interface import PintArray\n+\n+   >>> ureg = pint.UnitRegistry()\n+   >>> Q_ = ureg.Quantity\n+\n+.. testsetup:: *\n+\n+   import pandas as pd\n+   import numpy as np\n+   import pint\n+   from pint.pandas_interface import PintArray\n+\n+   ureg = pint.UnitRegistry()\n+   Q_ = ureg.Quantity\n+\n+Next, we can create a DataFrame with PintArray's as columns\n+\n+.. doctest::\n+\n+   >>> torque = PintArray(Q_([1, 2, 2, 3], \"lbf ft\"))\n+   >>> angular_velocity = PintArray(Q_([1000, 2000, 2000, 3000], \"rpm\"))\n+   >>> df = pd.DataFrame({\"torque\": torque, \"angular_velocity\": angular_velocity})\n+   >>> print(df)\n+                       torque             angular_velocity\n+   0  1 foot * force_pound  1000 revolutions_per_minute\n+   1  2 foot * force_pound  2000 revolutions_per_minute\n+   2  2 foot * force_pound  2000 revolutions_per_minute\n+   3  3 foot * force_pound  3000 revolutions_per_minute\n+\n+Operations with columns are units aware so behave as we would intuitively expect\n+\n+.. doctest::\n+\n+   >>> df['power'] = df['torque'] * df['angular_velocity']\n+   >>> print(df)\n+                    torque             angular_velocity  \\\n+   0  1 foot * force_pound  1000 revolutions_per_minute\n+   1  2 foot * force_pound  2000 revolutions_per_minute\n+   2  2 foot * force_pound  2000 revolutions_per_minute\n+   3  3 foot * force_pound  3000 revolutions_per_minute\n+\n+                                                 power\n+   0  1000 foot * force_pound * revolutions_per_minute\n+   1  4000 foot * force_pound * revolutions_per_minute\n+   2  4000 foot * force_pound * revolutions_per_minute\n+   3  9000 foot * force_pound * revolutions_per_minute\n+\n+Data accessing is a little bit awkward (fixing this would be helpful), but can be done as shown below","path":"docs/pandas.rst","position":69,"original_position":69,"commit_id":"2e474e2d0f8d2ba74ffc4b9ddbe421c4aa946c08","original_commit_id":"6861c06466804d439317f17bc520fcf4404af24d","user":{"login":"znicholls","id":23625371,"node_id":"MDQ6VXNlcjIzNjI1Mzcx","avatar_url":"https://avatars2.githubusercontent.com/u/23625371?v=4","gravatar_id":"","url":"https://api.github.com/users/znicholls","html_url":"https://github.com/znicholls","followers_url":"https://api.github.com/users/znicholls/followers","following_url":"https://api.github.com/users/znicholls/following{/other_user}","gists_url":"https://api.github.com/users/znicholls/gists{/gist_id}","starred_url":"https://api.github.com/users/znicholls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znicholls/subscriptions","organizations_url":"https://api.github.com/users/znicholls/orgs","repos_url":"https://api.github.com/users/znicholls/repos","events_url":"https://api.github.com/users/znicholls/events{/privacy}","received_events_url":"https://api.github.com/users/znicholls/received_events","type":"User","site_admin":false},"body":"ok then I guess it has to stay like this","created_at":"2018-09-04T11:14:42Z","updated_at":"2018-09-04T11:14:42Z","html_url":"https://github.com/hgrecco/pint/pull/684#discussion_r214875823","pull_request_url":"https://api.github.com/repos/hgrecco/pint/pulls/684","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/hgrecco/pint/pulls/comments/214875823"},"html":{"href":"https://github.com/hgrecco/pint/pull/684#discussion_r214875823"},"pull_request":{"href":"https://api.github.com/repos/hgrecco/pint/pulls/684"}},"in_reply_to_id":214755448},"pull_request":{"url":"https://api.github.com/repos/hgrecco/pint/pulls/684","id":211538760,"node_id":"MDExOlB1bGxSZXF1ZXN0MjExNTM4NzYw","html_url":"https://github.com/hgrecco/pint/pull/684","diff_url":"https://github.com/hgrecco/pint/pull/684.diff","patch_url":"https://github.com/hgrecco/pint/pull/684.patch","issue_url":"https://api.github.com/repos/hgrecco/pint/issues/684","number":684,"state":"open","locked":false,"title":"Add pandas support","user":{"login":"znicholls","id":23625371,"node_id":"MDQ6VXNlcjIzNjI1Mzcx","avatar_url":"https://avatars2.githubusercontent.com/u/23625371?v=4","gravatar_id":"","url":"https://api.github.com/users/znicholls","html_url":"https://github.com/znicholls","followers_url":"https://api.github.com/users/znicholls/followers","following_url":"https://api.github.com/users/znicholls/following{/other_user}","gists_url":"https://api.github.com/users/znicholls/gists{/gist_id}","starred_url":"https://api.github.com/users/znicholls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znicholls/subscriptions","organizations_url":"https://api.github.com/users/znicholls/orgs","repos_url":"https://api.github.com/users/znicholls/repos","events_url":"https://api.github.com/users/znicholls/events{/privacy}","received_events_url":"https://api.github.com/users/znicholls/received_events","type":"User","site_admin":false},"body":"This pull request adds pandas support to pint (hence is related to #645, #401 and pandas-dev/pandas#10349).\r\n\r\nAn example can be seen in `example-notebooks/basic-example.ipynb`.\r\n\r\nIt's a little bit hacksih, feedback would be greatly appreciated by me and @andrewgsavage. One obvious example is that we have to run all the interface tests with `pytest` to fit with `pandas` test suite, which introduces a dependency for the CI and currently gives us this awkward testing setup (see the alterations we had to make to `testsuite`). This also means that our code coverage tests are fiddly too.\r\n\r\nIf you'd like us to squash the commits, that can be done.\r\n\r\nIf pint has a linter, it would be good to run that over this pull request too as we're a little bit all over the place re style.\r\n\r\nThings to discuss:\r\n\r\n- [ ]  general feedback and changes\r\n- [ ] test setup, especially need for pytest for pandas tests and hackish way to get around automatic discovery\r\n- [ ] squashing/rebasing\r\n- [ ] linting/other code style (related to #664 and #628: we're happy with whatever, I've found using an automatic linter e.g. black and/or flake8 has made things much simpler in other projects)\r\n- [ ] including notebooks in the repo (if we want to, I'm happy to put them under CI so we can make sure they run)\r\n- [ ] setting up the docs correctly","created_at":"2018-08-28T19:54:44Z","updated_at":"2018-09-04T11:14:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cca9954f4bfb997c41209604f0de90492776463e","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/hgrecco/pint/pulls/684/commits","review_comments_url":"https://api.github.com/repos/hgrecco/pint/pulls/684/comments","review_comment_url":"https://api.github.com/repos/hgrecco/pint/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hgrecco/pint/issues/684/comments","statuses_url":"https://api.github.com/repos/hgrecco/pint/statuses/2e474e2d0f8d2ba74ffc4b9ddbe421c4aa946c08","head":{"label":"znicholls:master","ref":"master","sha":"2e474e2d0f8d2ba74ffc4b9ddbe421c4aa946c08","user":{"login":"znicholls","id":23625371,"node_id":"MDQ6VXNlcjIzNjI1Mzcx","avatar_url":"https://avatars2.githubusercontent.com/u/23625371?v=4","gravatar_id":"","url":"https://api.github.com/users/znicholls","html_url":"https://github.com/znicholls","followers_url":"https://api.github.com/users/znicholls/followers","following_url":"https://api.github.com/users/znicholls/following{/other_user}","gists_url":"https://api.github.com/users/znicholls/gists{/gist_id}","starred_url":"https://api.github.com/users/znicholls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znicholls/subscriptions","organizations_url":"https://api.github.com/users/znicholls/orgs","repos_url":"https://api.github.com/users/znicholls/repos","events_url":"https://api.github.com/users/znicholls/events{/privacy}","received_events_url":"https://api.github.com/users/znicholls/received_events","type":"User","site_admin":false},"repo":{"id":143659693,"node_id":"MDEwOlJlcG9zaXRvcnkxNDM2NTk2OTM=","name":"pint","full_name":"znicholls/pint","owner":{"login":"znicholls","id":23625371,"node_id":"MDQ6VXNlcjIzNjI1Mzcx","avatar_url":"https://avatars2.githubusercontent.com/u/23625371?v=4","gravatar_id":"","url":"https://api.github.com/users/znicholls","html_url":"https://github.com/znicholls","followers_url":"https://api.github.com/users/znicholls/followers","following_url":"https://api.github.com/users/znicholls/following{/other_user}","gists_url":"https://api.github.com/users/znicholls/gists{/gist_id}","starred_url":"https://api.github.com/users/znicholls/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/znicholls/subscriptions","organizations_url":"https://api.github.com/users/znicholls/orgs","repos_url":"https://api.github.com/users/znicholls/repos","events_url":"https://api.github.com/users/znicholls/events{/privacy}","received_events_url":"https://api.github.com/users/znicholls/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/znicholls/pint","description":"Operate and manipulate physical quantities in Python","fork":true,"url":"https://api.github.com/repos/znicholls/pint","forks_url":"https://api.github.com/repos/znicholls/pint/forks","keys_url":"https://api.github.com/repos/znicholls/pint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/znicholls/pint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/znicholls/pint/teams","hooks_url":"https://api.github.com/repos/znicholls/pint/hooks","issue_events_url":"https://api.github.com/repos/znicholls/pint/issues/events{/number}","events_url":"https://api.github.com/repos/znicholls/pint/events","assignees_url":"https://api.github.com/repos/znicholls/pint/assignees{/user}","branches_url":"https://api.github.com/repos/znicholls/pint/branches{/branch}","tags_url":"https://api.github.com/repos/znicholls/pint/tags","blobs_url":"https://api.github.com/repos/znicholls/pint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/znicholls/pint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/znicholls/pint/git/refs{/sha}","trees_url":"https://api.github.com/repos/znicholls/pint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/znicholls/pint/statuses/{sha}","languages_url":"https://api.github.com/repos/znicholls/pint/languages","stargazers_url":"https://api.github.com/repos/znicholls/pint/stargazers","contributors_url":"https://api.github.com/repos/znicholls/pint/contributors","subscribers_url":"https://api.github.com/repos/znicholls/pint/subscribers","subscription_url":"https://api.github.com/repos/znicholls/pint/subscription","commits_url":"https://api.github.com/repos/znicholls/pint/commits{/sha}","git_commits_url":"https://api.github.com/repos/znicholls/pint/git/commits{/sha}","comments_url":"https://api.github.com/repos/znicholls/pint/comments{/number}","issue_comment_url":"https://api.github.com/repos/znicholls/pint/issues/comments{/number}","contents_url":"https://api.github.com/repos/znicholls/pint/contents/{+path}","compare_url":"https://api.github.com/repos/znicholls/pint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/znicholls/pint/merges","archive_url":"https://api.github.com/repos/znicholls/pint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/znicholls/pint/downloads","issues_url":"https://api.github.com/repos/znicholls/pint/issues{/number}","pulls_url":"https://api.github.com/repos/znicholls/pint/pulls{/number}","milestones_url":"https://api.github.com/repos/znicholls/pint/milestones{/number}","notifications_url":"https://api.github.com/repos/znicholls/pint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/znicholls/pint/labels{/name}","releases_url":"https://api.github.com/repos/znicholls/pint/releases{/id}","deployments_url":"https://api.github.com/repos/znicholls/pint/deployments","created_at":"2018-08-06T01:03:44Z","updated_at":"2018-09-04T11:13:49Z","pushed_at":"2018-09-04T11:13:46Z","git_url":"git://github.com/znicholls/pint.git","ssh_url":"git@github.com:znicholls/pint.git","clone_url":"https://github.com/znicholls/pint.git","svn_url":"https://github.com/znicholls/pint","homepage":"http://pint.readthedocs.org/","size":1776,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":2,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":2,"watchers":0,"default_branch":"master"}},"base":{"label":"hgrecco:master","ref":"master","sha":"241bf7df1404e26d202df64e12e772d111803c31","user":{"login":"hgrecco","id":278566,"node_id":"MDQ6VXNlcjI3ODU2Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/278566?v=4","gravatar_id":"","url":"https://api.github.com/users/hgrecco","html_url":"https://github.com/hgrecco","followers_url":"https://api.github.com/users/hgrecco/followers","following_url":"https://api.github.com/users/hgrecco/following{/other_user}","gists_url":"https://api.github.com/users/hgrecco/gists{/gist_id}","starred_url":"https://api.github.com/users/hgrecco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgrecco/subscriptions","organizations_url":"https://api.github.com/users/hgrecco/orgs","repos_url":"https://api.github.com/users/hgrecco/repos","events_url":"https://api.github.com/users/hgrecco/events{/privacy}","received_events_url":"https://api.github.com/users/hgrecco/received_events","type":"User","site_admin":false},"repo":{"id":5021892,"node_id":"MDEwOlJlcG9zaXRvcnk1MDIxODky","name":"pint","full_name":"hgrecco/pint","owner":{"login":"hgrecco","id":278566,"node_id":"MDQ6VXNlcjI3ODU2Ng==","avatar_url":"https://avatars0.githubusercontent.com/u/278566?v=4","gravatar_id":"","url":"https://api.github.com/users/hgrecco","html_url":"https://github.com/hgrecco","followers_url":"https://api.github.com/users/hgrecco/followers","following_url":"https://api.github.com/users/hgrecco/following{/other_user}","gists_url":"https://api.github.com/users/hgrecco/gists{/gist_id}","starred_url":"https://api.github.com/users/hgrecco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hgrecco/subscriptions","organizations_url":"https://api.github.com/users/hgrecco/orgs","repos_url":"https://api.github.com/users/hgrecco/repos","events_url":"https://api.github.com/users/hgrecco/events{/privacy}","received_events_url":"https://api.github.com/users/hgrecco/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hgrecco/pint","description":"Operate and manipulate physical quantities in Python","fork":false,"url":"https://api.github.com/repos/hgrecco/pint","forks_url":"https://api.github.com/repos/hgrecco/pint/forks","keys_url":"https://api.github.com/repos/hgrecco/pint/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hgrecco/pint/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hgrecco/pint/teams","hooks_url":"https://api.github.com/repos/hgrecco/pint/hooks","issue_events_url":"https://api.github.com/repos/hgrecco/pint/issues/events{/number}","events_url":"https://api.github.com/repos/hgrecco/pint/events","assignees_url":"https://api.github.com/repos/hgrecco/pint/assignees{/user}","branches_url":"https://api.github.com/repos/hgrecco/pint/branches{/branch}","tags_url":"https://api.github.com/repos/hgrecco/pint/tags","blobs_url":"https://api.github.com/repos/hgrecco/pint/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hgrecco/pint/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hgrecco/pint/git/refs{/sha}","trees_url":"https://api.github.com/repos/hgrecco/pint/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hgrecco/pint/statuses/{sha}","languages_url":"https://api.github.com/repos/hgrecco/pint/languages","stargazers_url":"https://api.github.com/repos/hgrecco/pint/stargazers","contributors_url":"https://api.github.com/repos/hgrecco/pint/contributors","subscribers_url":"https://api.github.com/repos/hgrecco/pint/subscribers","subscription_url":"https://api.github.com/repos/hgrecco/pint/subscription","commits_url":"https://api.github.com/repos/hgrecco/pint/commits{/sha}","git_commits_url":"https://api.github.com/repos/hgrecco/pint/git/commits{/sha}","comments_url":"https://api.github.com/repos/hgrecco/pint/comments{/number}","issue_comment_url":"https://api.github.com/repos/hgrecco/pint/issues/comments{/number}","contents_url":"https://api.github.com/repos/hgrecco/pint/contents/{+path}","compare_url":"https://api.github.com/repos/hgrecco/pint/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hgrecco/pint/merges","archive_url":"https://api.github.com/repos/hgrecco/pint/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hgrecco/pint/downloads","issues_url":"https://api.github.com/repos/hgrecco/pint/issues{/number}","pulls_url":"https://api.github.com/repos/hgrecco/pint/pulls{/number}","milestones_url":"https://api.github.com/repos/hgrecco/pint/milestones{/number}","notifications_url":"https://api.github.com/repos/hgrecco/pint/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hgrecco/pint/labels{/name}","releases_url":"https://api.github.com/repos/hgrecco/pint/releases{/id}","deployments_url":"https://api.github.com/repos/hgrecco/pint/deployments","created_at":"2012-07-13T16:27:11Z","updated_at":"2018-09-01T07:26:21Z","pushed_at":"2018-09-04T11:13:48Z","git_url":"git://github.com/hgrecco/pint.git","ssh_url":"git@github.com:hgrecco/pint.git","clone_url":"https://github.com/hgrecco/pint.git","svn_url":"https://github.com/hgrecco/pint","homepage":"http://pint.readthedocs.org/","size":1599,"stargazers_count":723,"watchers_count":723,"language":"Python","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":176,"mirror_url":null,"archived":false,"open_issues_count":191,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":176,"open_issues":191,"watchers":723,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hgrecco/pint/pulls/684"},"html":{"href":"https://github.com/hgrecco/pint/pull/684"},"issue":{"href":"https://api.github.com/repos/hgrecco/pint/issues/684"},"comments":{"href":"https://api.github.com/repos/hgrecco/pint/issues/684/comments"},"review_comments":{"href":"https://api.github.com/repos/hgrecco/pint/pulls/684/comments"},"review_comment":{"href":"https://api.github.com/repos/hgrecco/pint/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hgrecco/pint/pulls/684/commits"},"statuses":{"href":"https://api.github.com/repos/hgrecco/pint/statuses/2e474e2d0f8d2ba74ffc4b9ddbe421c4aa946c08"}},"author_association":"NONE"}}
{"actor":{"display_login":"znicholls"}}