{"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":"index","profile":{"resources":[],"task_format":"","scoring":"","metric":"","size":"","answer_access":"","license":"","citation":"","maintainer":"","released":"","why_hard":"","related":[],"history":"","construction":"","limitations":"","saturation":"","scores":[]}},"task_id":"80101acc-8101-572e-9cb0-42d6aa769211","task_key":"default--test--273","task_revision_id":"1","upstream_id":"273","short_description":"I do know some posts are quite similar to my question but none of them succeded…","config":"default","split":"test","body":"{\"library\":\"Pandas\",\"prompt\":\"Problem:\\nI do know some posts are quite similar to my question but none of them succeded in giving me the correct answer. I want, for each row of a pandas dataframe, to perform the sum of values taken from several columns. As the number of columns tends to vary, I want this sum to be performed from a list of columns.\\nAt the moment my code looks like this:\\ndf['Sum'] = df['Col A'] + df['Col E'] + df['Col Z']\\n\\n\\nI want it to be something like :\\ndf['Sum'] = sum(list_of_my_columns)\\n\\n\\nor\\ndf[list_of_my_columns].sum(axis=1)\\n\\n\\nBut both of them return an error. Might be because my list isn't properly created? This is how I did it:\\nlist_of_my_columns = [df['Col A'], df['Col E'], df['Col Z']]\\n\\n\\nBut this doesn't seem to work... Any ideas ? Thank you !\\nA:\\n<code>\\nimport pandas as pd\\nimport numpy as np\\n\\n\\nnp.random.seed(10)\\ndata = {}\\nfor i in [chr(x) for x in range(65,91)]:\\n    data['Col '+i] = np.random.randint(1,100,10)\\ndf = pd.DataFrame(data)\\nlist_of_my_columns = ['Col A', 'Col E', 'Col Z']\\n</code>\\ndf = ... # 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":"index","subproblems":[],"grids":[]}