{"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":"4c23d84d-786d-5e57-9a92-4453a125f187","task_key":"default--test--33","task_revision_id":"2","upstream_id":"33","short_description":"I have a script that generates a pandas data frame with a varying number of…","config":"default","split":"test","body":"{\"prompt\":\"Problem:\\nI have a script that generates a pandas data frame with a varying number of value columns. As an example, this df might be\\nimport pandas as pd\\ndf = pd.DataFrame({\\n'group': ['A', 'A', 'A', 'B', 'B'],\\n'group_color' : ['green', 'green', 'green', 'blue', 'blue'],\\n'val1': [5, 2, 3, 4, 5], \\n'val2' : [4, 2, 8, 5, 7]\\n})\\n  group group_color  val1  val2\\n0     A       green     5     4\\n1     A       green     2     2\\n2     A       green     3     8\\n3     B        blue     4     5\\n4     B        blue     5     7\\n\\n\\nMy goal is to get the grouped mean for each of the value columns. In this specific case (with 2 value columns), I can use\\ndf.groupby('group').agg({\\\"group_color\\\": \\\"first\\\", \\\"val1\\\": \\\"mean\\\", \\\"val2\\\": \\\"mean\\\"})\\n      group_color      val1      val2\\ngroup                                \\nA           green  3.333333  4.666667\\nB            blue  4.500000  6.000000\\n\\n\\nbut that does not work when the data frame in question has more value columns (val3, val4 etc.).\\nIs there a way to dynamically take the mean of \\\"all the other columns\\\" or \\\"all columns containing val in their names\\\"?\\n\\n\\nA:\\n<code>\\nimport pandas as pd\\n\\n\\ndf = pd.DataFrame({ 'group': ['A', 'A', 'A', 'B', 'B'], 'group_color' : ['green', 'green', 'green', 'blue', 'blue'], 'val1': [5, 2, 3, 4, 5], 'val2' : [4, 2, 8, 5, 7],'val3':[1,1,4,5,1] })\\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":[]}