{"kind":"task","effective_mode":"full","benchmark":{"kind":"benchmark","effective_mode":"full","slug":"ds-1000","formal_name":"DS-1000","introduction":"DS-1000 builds 1,000 data-science problems from real StackOverflow questions across seven libraries including NumPy, Pandas and Matplotlib. The problems are perturbed so that recalling the original answer does not solve them.","introduction_ja":"","introduction_en":"","category":"Category not supplied","task_count":null,"acquisition_status":"Acquisition status not supplied","official_url":"https://ds1000-code-gen.github.io/","indexing_mode":"noindex","profile":{"resources":[],"task_format":"","scoring":"","metric":"","size":"","answer_access":"","license":"","citation":"","maintainer":"","released":"","why_hard":"","related":[]}},"task_id":"9490b2c7-8ac6-5bb5-9e4d-6de9ea9057f2","task_key":"default--test--50","task_revision_id":"2","upstream_id":"50","short_description":"Sample dataframe:","config":"default","split":"test","body":"{\"prompt\":\"Problem:\\nSample dataframe:\\ndf = pd.DataFrame({\\\"A\\\": [1, 2, 3], \\\"B\\\": [4, 5, 6]})\\n\\nI'd like to add inverses of each existing column to the dataframe and name them based on existing column names with a prefix, e.g. inv_A is an inverse of column A and so on.\\nThe resulting dataframe should look like so:\\nresult = pd.DataFrame({\\\"A\\\": [1, 2, 3], \\\"B\\\": [4, 5, 6], \\\"inv_A\\\": [1/1, 1/2, 1/3], \\\"inv_B\\\": [1/4, 1/5, 1/6]})\\n\\n\\nObviously there are redundant methods like doing this in a loop, but there should exist much more pythonic ways of doing it and after searching for some time I didn't find anything. I understand that this is most probably a duplicate; if so, please point me to an existing answer.\\n\\n\\nA:\\n<code>\\nimport pandas as pd\\n\\n\\ndf = pd.DataFrame({\\\"A\\\": [1, 2, 3], \\\"B\\\": [4, 5, 6]})\\n</code>\\nresult = ... # put solution in this variable\\nBEGIN SOLUTION\\n<code>\\n\"}","display_format":"code","language":"","answer_status":"published","assets":[],"source_url":"https://ds1000-code-gen.github.io/","history":"initial import","indexing_mode":"noindex","subproblems":[],"grids":[]}