{"task_id": 37146, "prompt": "def f_37146(arr):\n\treturn ", "suffix": "", "canonical_solution": "arr[:, 0]", "test_start": "\nimport numpy as np\n\ndef check(candidate):", "test": ["\n arr = np.array([[1,2],[3,4]])\n assert all(candidate(arr) == np.array([1,3]))\n", "\n arr = np.array([[3,4,5]])\n assert all(candidate(arr) == np.array([3]))\n"], "entry_point": "f_37146", "intent": "2\u6b21\u5143\u914d\u5217`arr`\u306e\u8981\u7d20\u3068\u306a\u3063\u3066\u3044\u308b1\u6b21\u5143\u914d\u5217\u304b\u3089\u5148\u982d\u306e\u5024\u306e\u307f\u3092\u629c\u304d\u51fa\u3059", "library": ["numpy"]} {"task_id": 25263, "prompt": "def f_25263(df):\n\treturn ", "suffix": "", "canonical_solution": "df.to_dict()", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame([[1,2,3], [4,5,6], [6,5,4], [2,1,0]], columns=[\"AA\", \"b\", \"3\"])\n assert candidate(df) == {'AA': {0: 1, 1: 4, 2: 6, 3: 2},\n 'b': {0: 2, 1: 5, 2: 5, 3: 1},\n '3': {0: 3, 1: 6, 2: 4, 3: 0}}\n", "\n df = pd.DataFrame([[1,2,3], [4,5,6], [6,5,4], [2,1,0]])\n assert candidate(df) == {0: {0: 1, 1: 4, 2: 6, 3: 2},\n 1: {0: 2, 1: 5, 2: 5, 3: 1},\n 2: {0: 3, 1: 6, 2: 4, 3: 0}}\n"], "entry_point": "f_25263", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u8f9e\u66f8\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306b\u5909\u63db\u3059\u308b", "library": ["pandas"]} {"task_id": 28178, "prompt": "def f_28178(soup):\n\treturn ", "suffix": "", "canonical_solution": "soup.find('tbody').find_all('tr')", "test_start": "\nfrom bs4 import BeautifulSoup\n\ndef check(candidate):", "test": ["\n soup = BeautifulSoup(\"Address:My home address\")\n result = candidate(soup)\n assert len(result) == 1\n assert result[0].contents == ['My home address']\n"], "entry_point": "f_28178", "intent": "HTML\u30c6\u30fc\u30d6\u30eb\u304b\u3089\u5404\u884c\u3092\u53d6\u5f97\u3059\u308b", "library": ["bs4"]} {"task_id": 8656, "prompt": "def f_8656():\n\t", "suffix": "\n\treturn handler", "canonical_solution": "class handler(http.server.BaseHTTPRequestHandler):\n\t def do_POST(self):\n\t os.environ['REQUEST_METHOD'] = 'POST'\n\t form = cgi.FieldStorage(self.rfile, self.headers)", "test_start": "\nimport cgi\nimport http.server\n\ndef check(candidate):", "test": ["\n try:\n handler = candidate()\n srvr = http.server.HTTPServer(('127.0.0.1', 8889), handler)\n except:\n assert False\n"], "entry_point": "f_8656", "intent": "POST\u30c7\u30fc\u30bf\u3092cgi.FieldStrage\u3067\u53d7\u3051\u53d6\u308b", "library": ["cgi", "http"]} {"task_id": 9836, "prompt": "def f_9836(li):\n\treturn ", "suffix": "", "canonical_solution": "random.choice(li)", "test_start": "\nimport random\n\ndef check(candidate):", "test": ["\n assert candidate([1,2,3]) in [1,2,3]\n"], "entry_point": "f_9836", "intent": "\u30ea\u30b9\u30c8`li`\u306e\u4e2d\u304b\u3089\u30e9\u30f3\u30c0\u30e0\u306b\u4e00\u3064\u306e\u8981\u7d20\u3092\u9078\u629e\u3059\u308b", "library": ["random"]} {"task_id": 1589, "prompt": "def f_1589(d):\n\t", "suffix": "\n\treturn ", "canonical_solution": "X = np.array(d, dtype='float32')\n\tX.tofile('binaryVec.bin')", "test_start": "\nimport numpy as np\n\ndef check(candidate):", "test": ["\n f = open('binaryVec.bin', 'w')\n f.close()\n \n d = np.array([1., 2., 3.])\n candidate(d)\n d1 = np.fromfile('binaryVec.bin', dtype='float32')\n assert np.all(d == d1)\n"], "entry_point": "f_1589", "intent": "\u8981\u7d20\u304c\u6570\u5024\u306e\u30ea\u30b9\u30c8\u578b\u30c7\u30fc\u30bf`d`\u3092\u30d0\u30a4\u30ca\u30ea\u30c7\u30fc\u30bf`binaryVrc.bin`\u3068\u3057\u3066\u4fdd\u5b58\u3059\u308b", "library": ["numpy"]} {"task_id": 38532, "prompt": "def f_38532(f):\n\t", "suffix": "\n\treturn ", "canonical_solution": "f.close()", "test_start": "\ndef check(candidate):", "test": ["\n f = open('tmp.txt', 'w')\n candidate(f)\n assert f.closed\n"], "entry_point": "f_38532", "intent": "\u958b\u3044\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb'f'\u3092\u9589\u3058\u308b", "library": []} {"task_id": 37696, "prompt": "def f_37696(files, url, data):\n\treturn ", "suffix": "", "canonical_solution": "requests.post(url, files=files, data=data)", "test_start": "\nimport requests\nfrom unittest.mock import Mock\n\ndef check(candidate):", "test": ["\n r = requests.Response()\n r.status_code = 200\n requests.post = Mock(return_value = r)\n file_path = 'a.txt'\n with open (file_path, 'w') as f:\n f.write('abc')\n files = {'file': open(file_path, 'rb')}\n assert candidate(files, 'https://def.xyz', {'key':'value'}).status_code == 200\n"], "entry_point": "f_37696", "intent": "multipart\u306e\u30ea\u30af\u30a8\u30b9\u30c8\u3067\u8907\u6570\u306e\u30c7\u30fc\u30bf`files`, `data`\u3092`url'\u306bPOST\u3059\u308b", "library": ["requests"]} {"task_id": 29368, "prompt": "def f_29368(X, y):\n\t", "suffix": "\n\treturn sss", "canonical_solution": "sss = StratifiedShuffleSplit()\n\tsss.get_n_splits(X, y)", "test_start": "\nimport numpy as np\nimport sklearn\nfrom sklearn.model_selection import StratifiedShuffleSplit\n\ndef check(candidate):", "test": ["\n X = np.array([[1, 2], [3, 4], [1, 2], [3, 4], [1, 2], [3, 4]])\n y = np.array([0, 0, 0, 1, 1, 1])\n assert candidate(X, y).__class__ == sklearn.model_selection._split.StratifiedShuffleSplit\n"], "entry_point": "f_29368", "intent": "\u30af\u30e9\u30b9\u6570\u306e\u6bd4\u7387\u3092\u4fdd\u3063\u305f\u307e\u307e\u30c7\u30fc\u30bf\u3092\u5206\u5272\u3059\u308b", "library": ["numpy", "sklearn"]} {"task_id": 40699, "prompt": "def f_40699(low, high):\n\treturn ", "suffix": "", "canonical_solution": "plt.yticks(range(low,high))", "test_start": "\nimport matplotlib.pyplot as plt\n\ndef check(candidate):", "test": ["\n assert len(candidate(20, 50)[0]) == 30\n", "\n assert len(candidate(0, 10)[0]) == 10\n"], "entry_point": "f_40699", "intent": "y\u8ef8\u306e\u30d7\u30ed\u30c3\u30c8\u306e\u7bc4\u56f2\u3092\u4e0b\u9650`low`\u3001\u4e0a\u9650`high`\u306b\u8a2d\u5b9a\u3059\u308b", "library": ["matplotlib"]} {"task_id": 11011, "prompt": "def f_11011(fig, onclick):\n\t", "suffix": "\n\treturn ", "canonical_solution": "fig.canvas.mpl_connect('pick_event', onclick)", "test_start": "\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom mpl_toolkits.mplot3d import Axes3D\n\ndef check(candidate):", "test": ["\n def onclick(event):\n pass\n fig = plt.figure()\n X = [[1,2,3,4,5],[1,2,3,4,5],[1,2,3,4,5]]\n Y = [[1,1,1,1,1],[2,2,2,2,2],[3,3,3,3,3]]\n Z = [[10,11,13,14,16],[5,8,7,7,7,],[0,0,0,9,8]]\n ax = Axes3D(fig)\n ax.scatter3D(np.ravel(X),np.ravel(Y),np.ravel(Z))\n try:\n candidate(fig, onclick)\n except:\n assert False\n"], "entry_point": "f_11011", "intent": "\u30b0\u30e9\u30d5\u4e0a\u3067\u9078\u629e\u3055\u308c\u305f\u30c7\u30fc\u30bf\u306e\u5ea7\u6a19\u3092\u8868\u793a\u3059\u308b", "library": ["matplotlib", "mpl_toolkits", "numpy"]} {"task_id": 42344, "prompt": "def f_42344():\n\treturn ", "suffix": "", "canonical_solution": "re.compile('[\u3041-\u3093\u30a1-\u30f3\u4e00-\u9fa5]+')", "test_start": "\nimport re\n\ndef check(candidate):", "test": ["\n pattern = candidate()\n words = ['\u3042\u3044\u3046\u3048\u304a', '546', '\u305f\u306c\u304d', '\u9945\u982d', 'abdf', '#%&', ' ']\n ja_words = [pattern.findall(w) for w in words]\n ja_words = [a for jw in ja_words for a in jw]\n assert ja_words == ['\u3042\u3044\u3046\u3048\u304a', '\u305f\u306c\u304d', '\u9945\u982d']\n"], "entry_point": "f_42344", "intent": "\u65e5\u672c\u8a9e\uff08\u3072\u3089\u304c\u306a\u3001\u30ab\u30bf\u30ab\u30ca\u3001\u6f22\u5b57\uff09\u306e\u5224\u5225\u3092\u3059\u308b\u6b63\u898f\u8868\u73fe\u3092\u5f97\u308b", "library": ["re"]} {"task_id": 17145, "prompt": "def f_17145(br):\n\treturn ", "suffix": "", "canonical_solution": "br.submit().read()", "test_start": "\nimport mechanize\nimport urllib.request\nfrom unittest.mock import Mock\n\ndef check(candidate):", "test": ["\n br = mechanize.Browser()\n x = urllib.request.urlopen('https://www.wikipedia.org')\n br.submit = Mock(return_value = x)\n assert b'Wikipedia' in candidate(br)\n"], "entry_point": "f_17145", "intent": "\u30d6\u30e9\u30a6\u30b6\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`br`\u304b\u3089submit\u3057\u305f\u969b\u306e\u8fd4\u308a\u5024\u3092\u8aad\u307f\u3053\u3080", "library": ["mechanize", "urllib"]} {"task_id": 38824, "prompt": "def f_38824(data):\n\treturn ", "suffix": "", "canonical_solution": "[print(*i) for i in data]", "test_start": "\nimport sys\nfrom io import StringIO\n\ndef check(candidate):", "test": ["\n stdout = sys.stdout\n s = StringIO()\n sys.stdout = s\n candidate([[1],[2],[3],[4],[5],[6]])\n sys.stdout = stdout \n s.seek(0)\n assert len(s.read()) == 12\n"], "entry_point": "f_38824", "intent": "\u30bf\u30d7\u30eb`data`\u3092\u7a7a\u767d\u533a\u5207\u308a\u3067\u8868\u793a\u3059\u308b", "library": ["io", "sys"]} {"task_id": 38824, "prompt": "def f_38824(data):\n\t", "suffix": "\n\treturn ", "canonical_solution": "for i in data:\n\t print(' '.join(str(j) for j in i))", "test_start": "\nimport sys\nfrom io import StringIO\n\ndef check(candidate):", "test": ["\n stdout = sys.stdout\n s = StringIO()\n sys.stdout = s\n candidate([[1],[2],[3],[4],[5],[6]])\n sys.stdout = stdout \n s.seek(0)\n assert len(s.read()) == 12\n"], "entry_point": "f_38824", "intent": "\u30bf\u30d7\u30eb`data`\u3092\u7a7a\u767d\u533a\u5207\u308a\u3067\u8868\u793a\u3059\u308b", "library": ["io", "sys"]} {"task_id": 38824, "prompt": "def f_38824(data):\n\t", "suffix": "\n\treturn ", "canonical_solution": "for i in data:\n\t print(' '.join(map(str, i)))", "test_start": "\nimport sys\nfrom io import StringIO\n\ndef check(candidate):", "test": ["\n stdout = sys.stdout\n s = StringIO()\n sys.stdout = s\n candidate([[1],[2],[3],[4],[5],[6]])\n sys.stdout = stdout \n s.seek(0)\n assert len(s.read()) == 12\n"], "entry_point": "f_38824", "intent": "\u30bf\u30d7\u30eb`data`\u3092\u7a7a\u767d\u533a\u5207\u308a\u3067\u8868\u793a\u3059\u308b", "library": ["io", "sys"]} {"task_id": 35299, "prompt": "def f_35299(n):\n\t", "suffix": "\n\treturn result", "canonical_solution": "\n\tt = 5\n\tz = tf.constant(0, shape=[n, n], dtype=tf.int32)\n\tabs = tf.maximum(t, z)\n\tresult = tf.reduce_sum(abs)\n", "test_start": "\nimport tensorflow as tf\n\ndef check(candidate):", "test": ["\n assert str(type(candidate(4))).split(' ')[1] == \"'tensorflow.python.framework.ops.EagerTensor'>\"\n"], "entry_point": "f_35299", "intent": "`n`\u00d7`n`\u306e\u30c6\u30f3\u30bd\u30eb\u306e\u8981\u7d20\u306e\u3046\u30610\u4ee5\u4e0a\u306e\u5024\u306e\u548c\u3092\u8a08\u7b97\u3059\u308b", "library": ["tensorflow"]} {"task_id": 38328, "prompt": "def f_38328(df, pat):\n\treturn ", "suffix": "", "canonical_solution": "df.x.str.extract(pat)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame({'x': ['\u8eca5(0.8km)', '5', '\u8eca27(8.6km)']}, index=[1, 2, 3])\n pat = r'\u8eca(\\d*)'\n ref = df.x.str.extract(pat)\n assert candidate(df, pat).count()[0] == 2\n"], "entry_point": "f_38328", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u306e\u5217\u30e9\u30d9\u30eb`x`\u306e\u5404\u884c\u306e\u30c7\u30fc\u30bf\u306b\u5bfe\u3057\u3066\u6b63\u898f\u8868\u73fe`pat`\u3092\u9069\u7528\u3059\u308b", "library": ["pandas"]} {"task_id": 37418, "prompt": "def f_37418(file):\n\treturn ", "suffix": "", "canonical_solution": "open(file, 'w')", "test_start": "\ndef check(candidate):", "test": ["\n f = candidate('test.txt')\n assert f.name == 'test.txt'\n assert f.mode == 'w'\n"], "entry_point": "f_37418", "intent": "\u30d5\u30a1\u30a4\u30eb`file`\u3092\u4e0a\u66f8\u304d\u30e2\u30fc\u30c9\u3067\u958b\u304f", "library": []} {"task_id": 41200, "prompt": "def f_41200(x_list, y_list):\n\treturn ", "suffix": "", "canonical_solution": "plt.plot(x_list, y_list)", "test_start": "\nimport matplotlib.pyplot as plt\n\ndef check(candidate):", "test": ["\n assert isinstance(candidate([1, 3, 5], [2, 4, 6]), list)\n"], "entry_point": "f_41200", "intent": "\u30c7\u30fc\u30bf`x_list`\u3001`y_list`\u304b\u3089\u306a\u308b\u30b0\u30e9\u30d5\u3092\u63cf\u753b\u3059\u308b\u6307\u5b9a\u3059\u308b", "library": ["matplotlib"]} {"task_id": 43369, "prompt": "def f_43369(a, b):\n\treturn ", "suffix": "", "canonical_solution": "pd.DataFrame([a, b])", "test_start": "\nimport numpy as np\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n assert candidate([1,1,1], [2,2,2]).equals(pd.DataFrame([[1,1,1], [2,2,2]]))\n", "\n assert candidate([1,2,1], [2,3,4]).equals(pd.DataFrame([[1,2,1], [2,3,4]]))\n", "\n assert candidate([0], [1]).equals(pd.DataFrame([[0], [1]]))\n"], "entry_point": "f_43369", "intent": "2\u3064\u306e\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`a`\u3068`b`\u3092\u884c\u65b9\u5411\u306b\u7d50\u5408\u3059\u308b", "library": ["numpy", "pandas"]} {"task_id": 24438, "prompt": "def f_24438(file):\n\treturn ", "suffix": "", "canonical_solution": "codecs.open(file, 'r', 'utf-8')", "test_start": "\nimport codecs\n\ndef check(candidate):", "test": ["\n with open('test.txt', 'w') as fw:\n fw.write('hello world!')\n fr = candidate('test.txt')\n assert fr.name == 'test.txt'\n"], "entry_point": "f_24438", "intent": "\u6587\u5b57\u30b3\u30fc\u30c9\u3092utf-8\u306b\u6307\u5b9a\u3057\u3066\u30d5\u30a1\u30a4\u30eb`file`\u3092\u958b\u304f", "library": ["codecs"]} {"task_id": 10215, "prompt": "def f_10215(file):\n\t", "suffix": "\n\treturn data", "canonical_solution": "with open(file, 'rb') as f:\n\t data = f.read()", "test_start": "\ndef check(candidate):", "test": ["\n with open('tmp.pkl', 'wb') as fw:\n fw.write(b\"hello world!\")\n assert candidate('tmp.pkl') == b\"hello world!\"\n"], "entry_point": "f_10215", "intent": "\u30d5\u30a1\u30a4\u30eb`file`\u3092\u30d0\u30a4\u30ca\u30ea\u30c7\u30fc\u30bf\u3068\u3057\u3066\u958b\u304f", "library": []} {"task_id": 18992, "prompt": "def f_18992(x):\n\treturn ", "suffix": "", "canonical_solution": "pickle.dump(x, open('hoge.pkl', 'wb'))", "test_start": "\nimport pickle\n\ndef check(candidate):", "test": ["\n x = [100, 435, 56, 2, 99]\n candidate(x)\n with open('hoge.pkl', 'rb') as fr:\n data = pickle.load(fr)\n assert data == x\n"], "entry_point": "f_18992", "intent": "\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`x`\u3092\u30d5\u30a1\u30a4\u30eb`hoge.pkl`\u306b\u4fdd\u5b58\u3059\u308b", "library": ["pickle"]} {"task_id": 38400, "prompt": "def f_38400(df, change_dict):\n\treturn ", "suffix": "", "canonical_solution": "df.replace(change_dict)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame({'kai': ['2', 'B1', '23-49', 'M2']}, index=[1, 2, 3, 4])\n change_dict = {'2': '22', 'B1': 'B2'}\n assert candidate(df, change_dict).equals(df.replace(change_dict))\n"], "entry_point": "f_38400", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u306e\u8907\u6570\u306e\u7570\u306a\u308b\u8981\u7d20\u3092\u8f9e\u66f8\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`change_dict`\u306e\u30ad\u30fc\u3068\u8981\u7d20\u306e\u30da\u30a2\u306b\u5f93\u3063\u3066\u7f6e\u304d\u63db\u3048\u308b", "library": ["pandas"]} {"task_id": 35793, "prompt": "def f_35793():\n\t", "suffix": "\n\treturn data", "canonical_solution": "data = []\n\ti = 0\n\twhile(i<100):\n\t data.append(pd.read_csv('file_%d.csv'%i))\n\t i+=1", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n for i in range(0, 100):\n with open ('file_'+str(i)+'.csv', 'w') as f:\n f.write(str(i))\n \n assert len(candidate()) == 100\n"], "entry_point": "f_35793", "intent": "\u9023\u756a\u306b\u306a\u3063\u3066\u3044\u308b100\u500b\u306eCSV\u30d5\u30a1\u30a4\u30eb'file_%d'\u3092\u30ea\u30b9\u30c8\u306b\u53d6\u308a\u8fbc\u3080", "library": ["pandas"]} {"task_id": 20549, "prompt": "def f_20549(vectorized):\n\t", "suffix": "\n\treturn ", "canonical_solution": "numpy.save('my_vector.npy', vectorized.toarray())", "test_start": "\nimport os\nimport numpy\nfrom sklearn.feature_extraction import DictVectorizer\n\ndef check(candidate):", "test": ["\n measurements = [\n {'city': 'Dubai', 'temperature': 33.},\n {'city': 'London', 'temperature': 12.},\n {'city': 'San Francisco', 'temperature': 18.},\n ]\n vec = DictVectorizer()\n candidate(vec.fit_transform(measurements))\n assert os.path.exists('my_vector.npy')\n"], "entry_point": "f_20549", "intent": "\u5b66\u7fd2\u30c7\u30fc\u30bf\u306e\u30d9\u30af\u30c8\u30eb`vectorized`\u3092\u30d5\u30a1\u30a4\u30eb'my_vector.npy`\u306b\u4fdd\u5b58\u3059\u308b", "library": ["numpy", "os", "sklearn"]} {"task_id": 9518, "prompt": "def f_9518(li):\n\t", "suffix": "\n\treturn ", "canonical_solution": "for i, name in enumerate(li):\n\t print(i, name)", "test_start": "\nimport sys\n\ndef check(candidate):", "test": ["\n file_name = 'output.txt'\n f = open(file_name, 'w')\n sys.stdout = f\n candidate([1, 3])\n f.close()\n with open (file_name, 'r') as f:\n lines = f.readlines()\n assert lines[0] == '0 1\\n'\n assert lines[1] == '1 3\\n'\n \n f = open(file_name, 'w')\n sys.stdout = f\n candidate(['abc', 'def'])\n f.close()\n with open (file_name, 'r') as f:\n lines = f.readlines()\n assert lines[0] == '0 abc\\n'\n assert lines[1] == '1 def\\n'\n"], "entry_point": "f_9518", "intent": "\u30ea\u30b9\u30c8'li'\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3068\u8981\u7d20\u306b\u7e70\u308a\u8fd4\u3057\u51e6\u7406\u3092\u884c\u3063\u3066\u8868\u793a\u3059\u308b", "library": ["sys"]} {"task_id": 38760, "prompt": "def f_38760(arr, n):\n\treturn ", "suffix": "", "canonical_solution": "arr[arr > n].sum(), numpy.sum(arr > n)", "test_start": "\nimport numpy\nimport numpy as np \n\ndef check(candidate):", "test": ["\n assert candidate(np.array([1,2,3,4]), 3) == (4, 1)\n"], "entry_point": "f_38760", "intent": "numpy\u914d\u5217`arr`\u306b\u5bfe\u3057\u3066\u6570\u5024`n`\u3088\u308a\u5927\u304d\u3044\u8981\u7d20\u306e\u5408\u8a08\u53ca\u3073\u500b\u6570\u3092\u6c42\u3081\u3066\u8868\u793a\u3059\u308b", "library": ["numpy"]} {"task_id": 35102, "prompt": "def f_35102(data):\n\t", "suffix": "\n\treturn results", "canonical_solution": "results = {}\n\tfor item in data:\n\t results[item.find('areacode').text] = item.find('prefecture').text", "test_start": "\nimport xml.etree.ElementTree as ET\n\ndef check(candidate):", "test": ["\n data_temp = [\n 'area1prefecture1', \n 'area2prefecture2'\n ]\n data = []\n for tr in data_temp:\n data.append(ET.ElementTree(ET.fromstring(tr)))\n \n res = candidate(data)\n assert \"area1\" in res\n assert \"area2\" in res\n assert \"prefecture1\" == res[\"area1\"]\n assert \"prefecture2\" == res[\"area2\"]\n"], "entry_point": "f_35102", "intent": "\u30a4\u30c6\u30e9\u30d6\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`data`\u306e\u8981\u7d20\u304b\u3089\u6587\u5b57\u5217`area_code`\u3068`prefecture`\u3092\u63a2\u3057\u3001\u305d\u308c\u305e\u308c\u30ad\u30fc\u3068\u8981\u7d20\u306b\u6301\u3064\u8f9e\u66f8`results`\u3092\u4f5c\u308b", "library": ["xml"]} {"task_id": 41440, "prompt": "def f_41440(arr_list):\n\treturn ", "suffix": "", "canonical_solution": "np.stack(arr_list)", "test_start": "\nimport numpy as np \n\ndef check(candidate):", "test": ["\n arr_list = [np.array([1,2]), np.array([3,4]), np.array([5,6])]\n assert candidate(arr_list).tolist() == [[1, 2], [3, 4], [5, 6]]\n"], "entry_point": "f_41440", "intent": "\u8981\u7d20\u304cNumPy\u914d\u5217\u306e\u30ea\u30b9\u30c8`arr_list`\u30922\u6b21\u5143\u306eNumPy\u914d\u5217\u306b\u5909\u63db\u3059\u308b", "library": ["numpy"]} {"task_id": 35741, "prompt": "def f_35741(soup):\n\treturn ", "suffix": "", "canonical_solution": "soup.find_all('p')", "test_start": "\nfrom bs4 import BeautifulSoup\n\ndef check(candidate):", "test": ["\n soup = BeautifulSoup('

text

')\n assert candidate(soup)[0].contents == ['text']\n"], "entry_point": "f_35741", "intent": "HTML\u3092\u30d1\u30fc\u30b9\u3057\u305f\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`soup`\u304b\u3089\u30bf\u30b0`p`\u3092\u3059\u3079\u3066\u898b\u3064\u3051\u308b", "library": ["bs4"]} {"task_id": 40444, "prompt": "def f_40444(df, c_label):\n\treturn ", "suffix": "", "canonical_solution": "df.groupby([c_label]).last()", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame({'\u5229\u7528\u8005ID': [1, 2], '\u30b3\u30f3\u30c6\u30f3\u30c4ID': ['a', 'b'], '\u5024': [170, 45]})\n c_label = ['\u5229\u7528\u8005ID', '\u30b3\u30f3\u30c6\u30f3\u30c4ID']\n assert candidate(df, c_label).equals(df.groupby([c_label]).last())\n"], "entry_point": "f_40444", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u306e\u5217`c_label`\u3092Groupby\u3067\u307e\u3068\u3081\u305f\u30c7\u30fc\u30bf\u306e\u6700\u5f8c\u306e\u884c\u3092\u53d6\u308a\u51fa\u3059", "library": ["pandas"]} {"task_id": 39240, "prompt": "def f_39240(a_list, b_list):\n\treturn ", "suffix": "", "canonical_solution": "[i for i in b_list if i in a_list]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1,2,3], [4,1,2]) == [1,2]\n", "\n assert sorted(candidate([1,2,3,4,5], [4,1,2])) == [1,2,4]\n", "\n assert candidate([1,2,3], []) == []\n"], "entry_point": "f_39240", "intent": "\u30ea\u30b9\u30c8`a_list`\u306e\u8981\u7d20\u306e\u4e2d\u306e\u30ea\u30b9\u30c8`b_list`\u306e\u8981\u7d20\u3068\u4e00\u81f4\u3059\u308b\u3082\u306e\u3092\u8868\u793a\u3059\u308b", "library": []} {"task_id": 39375, "prompt": "def f_39375(dt_s):\n\treturn ", "suffix": "", "canonical_solution": "datetime.strptime(dt_s,'%d%b%Y')", "test_start": "\nfrom datetime import datetime\n\ndef check(candidate):", "test": ["\n assert candidate('10OCT2017') == datetime.strptime('10OCT2017','%d%b%Y')\n"], "entry_point": "f_39375", "intent": "\u82f1\u540d\u306e\u6708\u3092\u542b\u3080\u65e5\u4ed8\u30d5\u30a9\u30fc\u30de\u30c3\u30c8'%d%b%Y'\u306e\u6587\u5b57\u5217`dt_s`\u3092datetime\u578b\u306b\u5909\u63db\u3059\u308b", "library": ["datetime"]} {"task_id": 38960, "prompt": "def f_38960(n):\n\treturn ", "suffix": "", "canonical_solution": "[int(c) for c in n]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate('12345') == [1,2,3,4,5]\n", "\n assert candidate('') == []\n", "\n assert candidate('0') == [0]\n"], "entry_point": "f_38960", "intent": "\u6570\u5024`n`\u3092\u5206\u5272\u3057\u3066\u30ea\u30b9\u30c8\u306b\u683c\u7d0d\u3059\u308b", "library": []} {"task_id": 33908, "prompt": "def f_33908():\n\t", "suffix": "\n\treturn profile", "canonical_solution": "profile = webdriver.FirefoxProfile()\n\tprofile.DEFAULT_PREFERENCES['frozen']['javascript.enabled'] = False\n\tprofile.set_preference(\"app.update.auto\", False)\n\tprofile.set_preference(\"app.update.enabled\", False)\n\tprofile.update_preferences()", "test_start": "\nimport selenium\nfrom selenium import webdriver\nfrom selenium.webdriver.firefox.options import Options\n\ndef check(candidate):", "test": ["\n profile = candidate()\n assert profile.__class__ == selenium.webdriver.firefox.firefox_profile.FirefoxProfile\n"], "entry_point": "f_33908", "intent": "seleniumt\u3067Firefox\u4ed5\u69d8\u6642\u306bjavascript\u3092\u7121\u52b9\u306b\u3059\u308b", "library": ["selenium"]} {"task_id": 33908, "prompt": "def f_33908():\n\t", "suffix": "\n\treturn options", "canonical_solution": "\n\toptions = Options()\n\toptions.set_preference('javascript.enabled', False)\n", "test_start": "\nimport selenium\nfrom selenium import webdriver\nfrom selenium.webdriver.firefox.options import Options\n\ndef check(candidate):", "test": ["\n options = candidate()\n assert options.preferences == {'javascript.enabled': False}\n"], "entry_point": "f_33908", "intent": "seleniumt\u3067Firefox\u4ed5\u69d8\u6642\u306bjavascript\u3092\u7121\u52b9\u306b\u3059\u308b", "library": ["selenium"]} {"task_id": 19770, "prompt": "def f_19770(s):\n\treturn ", "suffix": "", "canonical_solution": "s.isnumeric()", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate('1') == True\n", "\n assert candidate('a') == False\n"], "entry_point": "f_19770", "intent": "\u6587\u5b57\u5217`s`\u304c\u6570\u3092\u8868\u3059\u6587\u5b57\u304b\u3069\u3046\u304b\u5224\u5b9a\u3059\u308b", "library": []} {"task_id": 29614, "prompt": "def f_29614():\n\treturn ", "suffix": "", "canonical_solution": "socket.socket()", "test_start": "\nimport socket\n\ndef check(candidate):", "test": ["\n assert candidate().__class__ == socket.socket\n"], "entry_point": "f_29614", "intent": "\u30bd\u30b1\u30c3\u30c8\u60c5\u5831\u3092\u4fdd\u5b58\u3059\u308b", "library": ["socket"]} {"task_id": 41032, "prompt": "def f_41032(dir):\n\treturn ", "suffix": "", "canonical_solution": "os.listdir(dir)", "test_start": "\nimport os\n\ndef check(candidate):", "test": ["\n assert candidate('.') == os.listdir('.')\n"], "entry_point": "f_41032", "intent": "\u30c7\u30a3\u30ec\u30af\u30c8\u30ea`dir`\u5185\u306b\u3042\u308b\u30d5\u30a1\u30a4\u30eb\u306e\u30ea\u30b9\u30c8\u3092\u53d6\u5f97\u3059\u308b", "library": ["os"]} {"task_id": 37709, "prompt": "def f_37709(img):\n\treturn ", "suffix": "", "canonical_solution": "img is None", "test_start": "\nimport cv2\nimport numpy as np \n\ndef check(candidate):", "test": ["\n assert candidate(None) == True\n blank_image = np.zeros((10,5,3), np.uint8)\n assert candidate(blank_image) == False\n"], "entry_point": "f_37709", "intent": "\u753b\u50cf`img`\u304c\u7a7a\u304b\u3069\u3046\u304b\u3092\u5224\u5b9a\u3059\u308b", "library": ["cv2", "numpy"]} {"task_id": 33677, "prompt": "def f_33677(f):\n\t", "suffix": "\n\treturn coeffs", "canonical_solution": "\n\tp = Poly(f, x)\n\tcoeffs = p.coeffs()\n", "test_start": "\nfrom sympy import Poly, var\n\ndef check(candidate):", "test": ["\n var('x a b')\n f = a*(2*x**2 - 1) + 4*x**3 + x*(b - 3)\n co = candidate(f)\n assert co == [4, 2*a, b - 3, -a]\n"], "entry_point": "f_33677", "intent": "`x`\u306b\u95a2\u3059\u308b\u591a\u9805\u5f0f`f`\u306e\u5404\u6b21\u6570\u306e\u4fc2\u6570\u3092\u6c42\u3081\u3066\u30ea\u30b9\u30c8\u306b\u3059\u308b `coeffs`", "library": ["sympy"]} {"task_id": 37449, "prompt": "def f_37449(a, b):\n\treturn ", "suffix": "", "canonical_solution": "a & b", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(22, 56678) == 6\n", "\n assert candidate(0, -1) == 0\n", "\n assert candidate(1000, 1) == 0\n", "\n assert candidate(479, 234) == 202\n"], "entry_point": "f_37449", "intent": "\u5909\u6570`a`\u3068`b`\u306e\u30d3\u30c3\u30c8\u6f14\u7b97", "library": []} {"task_id": 42442, "prompt": "def f_42442():\n\treturn ", "suffix": "", "canonical_solution": "globals()", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate() == globals()\n"], "entry_point": "f_42442", "intent": "\u30b0\u30ed\u30fc\u30d0\u30eb\u5909\u6570\u306e\u4e00\u89a7\u3092\u5f97\u308b", "library": []} {"task_id": 38030, "prompt": "def f_38030(word_list):\n\treturn ", "suffix": "", "canonical_solution": "Counter(word_list)", "test_start": "\nfrom collections import Counter\n\ndef check(candidate):", "test": ["\n assert candidate(['this', 'is', 'a', 'word', 'List']) == Counter({'List': 1, 'a': 1, 'is': 1, 'this': 1, 'word': 1})\n", "\n assert candidate(['List']) == Counter({'List': 1})\n", "\n assert candidate(['this', 'this', 'this', 'this', 'this']) == Counter({'this': 5})\n", "\n assert candidate([]) == Counter({})\n"], "entry_point": "f_38030", "intent": "\u30ea\u30b9\u30c8`word_list'\u5185\u306b\u51fa\u73fe\u3059\u308b\u5358\u8a9e\u3092\u6570\u3048\u308b", "library": ["collections"]} {"task_id": 38724, "prompt": "def f_38724(f, g):\n\t", "suffix": "\n\treturn add_functions", "canonical_solution": "def add_functions(f, g):\n\t return lambda x: f(x) + g(x)", "test_start": "\ndef check(candidate):", "test": ["\n def f(x): return x\n def g(y): return 1\n assert candidate(f,g)(f,g)(3) == 4\n"], "entry_point": "f_38724", "intent": "\u95a2\u6570`f`\u3068`g`\u3092\u53d7\u3051\u53d6\u3063\u3066\u95a2\u6570\u540c\u58eb\u306e\u548c\u3092\u8a08\u7b97\u3059\u308b\u95a2\u6570`add_functions`\u3092\u5b9a\u7fa9\u3059\u308b", "library": []} {"task_id": 22439, "prompt": "def f_22439(obj):\n\treturn ", "suffix": "", "canonical_solution": "type(obj)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate('this is a string') == str\n", "\n assert candidate(123.4) == float\n", "\n assert candidate(400) == int\n", "\n assert candidate({}) == dict \n", "\n assert candidate([{}]) == list\n"], "entry_point": "f_22439", "intent": "\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`obj`\u306e\u30af\u30e9\u30b9\u3092\u5f97\u308b", "library": []} {"task_id": 22439, "prompt": "def f_22439(obj):\n\treturn ", "suffix": "", "canonical_solution": "obj.__class__", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate('this is a string') == str\n", "\n assert candidate(123.4) == float\n", "\n assert candidate(400) == int\n", "\n assert candidate({}) == dict \n", "\n assert candidate([{}]) == list\n"], "entry_point": "f_22439", "intent": "\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`obj`\u306e\u30af\u30e9\u30b9\u3092\u5f97\u308b", "library": []} {"task_id": 39340, "prompt": "def f_39340(url):\n\treturn ", "suffix": "", "canonical_solution": "urllib.request.urlopen(url).read()", "test_start": "\nimport urllib\n\ndef check(candidate):", "test": ["\n url = \"http://www.google.com\"\n text = b\"google\"\n assert text in candidate(url)\n"], "entry_point": "f_39340", "intent": "\u6307\u5b9a\u3057\u305fURL`url`\u306e\u5185\u5bb9\u3092\u8868\u793a\u3059\u308b", "library": ["urllib"]} {"task_id": 39589, "prompt": "def f_39589(foldername, filename):\n\treturn ", "suffix": "", "canonical_solution": "os.path.join(foldername, filename)", "test_start": "\nimport os\n\ndef check(candidate):", "test": ["\n assert candidate('folder', 'file') == 'folder/file'\n", "\n assert candidate('', 'file') == 'file'\n", "\n assert candidate('.', 'file') == './file'\n"], "entry_point": "f_39589", "intent": "\u30d5\u30a9\u30eb\u30c0\u540d`foldername'\u3068\u30d5\u30a1\u30a4\u30eb\u540d`filename`\u3092\u7d50\u5408\u3057\u305f\u30d1\u30b9\u3092\u5f97\u308b", "library": ["os"]} {"task_id": 23577, "prompt": "def f_23577(ax, l, h):\n\treturn ", "suffix": "", "canonical_solution": "ax.set_xlim(l, h)", "test_start": "\nimport matplotlib.pyplot as plt\n\ndef check(candidate):", "test": ["\n fig, ax = plt.subplots()\n assert candidate(ax, 10, 100) == (10.0, 100.0)\n"], "entry_point": "f_23577", "intent": "X\u8ef8\u306e\u7bc4\u56f2\u3092\u4e0b\u9650`l`\u3068\u4e0a\u9650`h`\u306b\u6307\u5b9a\u3059\u308b", "library": ["matplotlib"]} {"task_id": 41087, "prompt": "def f_41087(src, range):\n\treturn ", "suffix": "", "canonical_solution": "int(math.ceil(src/float(range)) * range)", "test_start": "\nimport math\n\ndef check(candidate):", "test": ["\n assert candidate(22, 50) == 50\n", "\n assert candidate(100, 23) == 115\n", "\n assert candidate(0, 13) == 0\n", "\n assert candidate(12, 1) == 12\n", "\n assert candidate(34, 23) == 46\n"], "entry_point": "f_41087", "intent": "\u6574\u6570`src`\u3092\u7279\u5b9a\u306e\u7bc4\u56f2`range`\u306e\u500d\u6570\u3067\u5207\u308a\u4e0a\u3052\u308b", "library": ["math"]} {"task_id": 41087, "prompt": "def f_41087(src, range):\n\treturn ", "suffix": "", "canonical_solution": "src if src % range == 0 else src + range - src % range", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(22, 50) == 50\n", "\n assert candidate(100, 23) == 115\n", "\n assert candidate(0, 13) == 0\n", "\n assert candidate(12, 1) == 12\n", "\n assert candidate(34, 23) == 46\n"], "entry_point": "f_41087", "intent": "\u6574\u6570`src`\u3092\u7279\u5b9a\u306e\u7bc4\u56f2`range`\u306e\u500d\u6570\u3067\u5207\u308a\u4e0a\u3052\u308b", "library": []} {"task_id": 40711, "prompt": "def f_40711(n, N):\n\t", "suffix": "\n\treturn answer", "canonical_solution": "random_numbers = np.random.rand(n)\n\tanswer = N * random_numbers / np.sum(random_numbers)", "test_start": "\nimport numpy as np \n\ndef check(candidate):", "test": ["\n answer = candidate(20, 5)\n assert answer.shape == (20,)\n assert max(answer) < 5\n"], "entry_point": "f_40711", "intent": "\u8981\u7d20\u6570\u306e\u7dcf\u548c\u304c`N`\u3068\u306a\u308b\u5236\u7d04\u306e\u4e0b\u3001`n`\u6b21\u5143\u306e\u30e9\u30f3\u30c0\u30e0\u30d9\u30af\u30c8\u30eb`answer`\u3092\u751f\u6210\u3059\u308b", "library": ["numpy"]} {"task_id": 40711, "prompt": "def f_40711(n, N):\n\t", "suffix": "\n\treturn answer", "canonical_solution": "answer = np.random.dirichlet(np.ones(n)) * N", "test_start": "\nimport numpy as np \n\ndef check(candidate):", "test": ["\n answer = candidate(20, 5)\n assert answer.shape == (20,)\n"], "entry_point": "f_40711", "intent": "\u8981\u7d20\u6570\u306e\u7dcf\u548c\u304c`N`\u3068\u306a\u308b\u5236\u7d04\u306e\u4e0b\u3001`n`\u6b21\u5143\u306e\u30e9\u30f3\u30c0\u30e0\u30d9\u30af\u30c8\u30eb`answer`\u3092\u751f\u6210\u3059\u308b", "library": ["numpy"]} {"task_id": 31924, "prompt": "def f_31924(li):\n\t", "suffix": "\n\treturn li", "canonical_solution": "random.shuffle(li)", "test_start": "\nimport random\n\ndef check(candidate):", "test": ["\n li_a = [i for i in range(10)]\n li_a = candidate(li_a)\n assert sorted(li_a) == [i for i in range(10)]\n"], "entry_point": "f_31924", "intent": "\u30ea\u30b9\u30c8`li`\u3092\u30e9\u30f3\u30c0\u30e0\u306b\u4e26\u3073\u66ff\u3048\u308b", "library": ["random"]} {"task_id": 40343, "prompt": "def f_40343(a, b):\n\treturn ", "suffix": "", "canonical_solution": "itertools.product(a,b)", "test_start": "\nimport itertools\n\ndef check(candidate):", "test": ["\n assert list(candidate([1,2],[3,4])) == [(1, 3), (1, 4), (2, 3), (2, 4)]\n"], "entry_point": "f_40343", "intent": "\u8907\u6570\u306e\u30ea\u30b9\u30c8`a`\u3068`b`\u306e\u76f4\u7a4d\uff08\u30c7\u30ab\u30eb\u30c8\u7a4d\uff09\u3092\u751f\u6210\u3057\u3001\u8981\u7d20\u306e\u7d44\u307f\u5408\u308f\u305b\u306e\u7d50\u679c\u3092\u5f97\u308b", "library": ["itertools"]} {"task_id": 36217, "prompt": "def f_36217(df, reg):\n\treturn ", "suffix": "", "canonical_solution": "df['a'].str.extract(reg, expand=True)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame([['abc def'],['123 567'], ['qqq eee']], columns=['a'])\n reg = r'(.{3})$'\n assert candidate(df, reg).equals(df['a'].str.extract(reg, expand=True))\n"], "entry_point": "f_36217", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u306e\u5217`a`\u3092\u6b63\u898f\u8868\u73fe`reg'\u3067\u62bd\u51fa\u3059\u308b", "library": ["pandas"]} {"task_id": 27871, "prompt": "def f_27871(factories, shops, costs):\n\treturn ", "suffix": "", "canonical_solution": "{f+s : cost for ((f,s), cost) in zip(product(factories,shops), costs)}", "test_start": "\nfrom itertools import product\n\ndef check(candidate):", "test": ["\n assert candidate(['A', 'B'], ['1', '2'], [8, 10, 12, 16]) == {'A1': 8, 'A2': 10, 'B1': 12, 'B2': 16}\n"], "entry_point": "f_27871", "intent": "2\u3064\u306e\u30ea\u30b9\u30c8`factories'\u3068`shops`\u306e\u8981\u7d20\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u30ad\u30fc\u3068\u3057\u3001\u30bf\u30d7\u30eb`costs`\u5404\u8981\u7d20\u3092\u8981\u7d20\u7b49\u3059\u308b\u8f9e\u66f8\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u308b", "library": ["itertools"]} {"task_id": 27871, "prompt": "def f_27871(factories, shops, cost):\n\t", "suffix": "\n\treturn d", "canonical_solution": "root = [''.join((x, y)) for x, y in itertools.product(factories, shops)]\n\td = dict(zip(root, cost))", "test_start": "\nimport itertools\n\ndef check(candidate):", "test": ["\n factories = ['A', 'B', 'C', 'D']\n shops = ['1', '2', '3', '4', '5']\n costs = ( 8, 10, 12, 16, 20,\n 12, 8, 6, 10, 16,\n 18, 7, 4, 3, 4,\n 12, 10, 12, 16, 20 ) \n res_dict = candidate(factories, shops, costs)\n assert list(res_dict.items()) == [\n ('A1', 8), ('A2', 10), ('A3', 12), ('A4', 16), ('A5', 20), \n ('B1', 12), ('B2', 8), ('B3', 6), ('B4', 10), ('B5', 16), \n ('C1', 18), ('C2', 7), ('C3', 4), ('C4', 3), ('C5', 4), \n ('D1', 12), ('D2', 10), ('D3', 12), ('D4', 16), ('D5', 20), \n ] \n"], "entry_point": "f_27871", "intent": "2\u3064\u306e\u30ea\u30b9\u30c8`factories'\u3068`shops`\u306e\u8981\u7d20\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u30ad\u30fc\u3068\u3057\u3001\u30bf\u30d7\u30eb`costs`\u5404\u8981\u7d20\u3092\u8981\u7d20\u7b49\u3059\u308b\u8f9e\u66f8\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u3092\u4f5c\u308b", "library": ["itertools"]} {"task_id": 40676, "prompt": "def f_40676(soup):\n\treturn ", "suffix": "", "canonical_solution": "soup.find_all(attrs={\"data-locate\": \"address\"})", "test_start": "\nfrom bs4 import BeautifulSoup\n\ndef check(candidate):", "test": ["\n soup = BeautifulSoup('
foo!
')\n res = candidate(soup)\n assert len(res) == 1\n assert res[0].attrs == {'data-locate': 'address'} \n assert res[0].text == \"foo!\"\n"], "entry_point": "f_40676", "intent": "\u30ad\u30fc\u30ef\u30fc\u30c9\u5f15\u6570\u3068\u3057\u3066\u7528\u3044\u308b\u4e8b\u304c\u3067\u304d\u306a\u3044HTML5\u306edata-\u5c5e\u6027\u3001\u4f8b\u3048\u3070`data-locel`\u304c`address`\u306b\u4e00\u81f4\u3059\u308b\u3082\u306e\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`soup`\u304b\u3089\u691c\u7d22\u3059\u308b", "library": ["bs4"]} {"task_id": 42256, "prompt": "def f_42256(li):\n\t", "suffix": "\n\treturn s", "canonical_solution": "s = ''.join(i[0] for i in li)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(['sda', 'dahkdja', 'uehjkw', 'ebhjda']) == 'sdue'\n", "\n assert candidate(['happy', 'apple', 'pear', 'pie', 'yummy']) == 'happy'\n", "\n assert candidate(['a', 'b', 'c', 'd']) == 'abcd'\n", "\n assert candidate([str(i) for i in range(10)]) == '0123456789'\n"], "entry_point": "f_42256", "intent": "\u6587\u5b57\u5217\u3092\u8981\u7d20\u306b\u6301\u3064\u30ea\u30b9\u30c8`li`\u306e\u982d\u6587\u5b57\u3092\u7d50\u5408\u3057\u305f\u6587\u5b57\u5217`s`\u3092\u5f97\u308b", "library": []} {"task_id": 42256, "prompt": "def f_42256(li):\n\t", "suffix": "\n\treturn s", "canonical_solution": "\n\ts = ''\n\tfor line in li:\n\t\ts += line[0]\n", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(['sda', 'dahkdja', 'uehjkw', 'ebhjda']) == 'sdue'\n", "\n assert candidate(['happy', 'apple', 'pear', 'pie', 'yummy']) == 'happy'\n", "\n assert candidate(['a', 'b', 'c', 'd']) == 'abcd'\n", "\n assert candidate([str(i) for i in range(10)]) == '0123456789'\n"], "entry_point": "f_42256", "intent": "\u6587\u5b57\u5217\u3092\u8981\u7d20\u306b\u6301\u3064\u30ea\u30b9\u30c8`li`\u306e\u982d\u6587\u5b57\u3092\u7d50\u5408\u3057\u305f\u6587\u5b57\u5217`s`\u3092\u5f97\u308b", "library": []} {"task_id": 18967, "prompt": "def f_18967(li, i):\n\treturn ", "suffix": "", "canonical_solution": "i not in li", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(['sda', 'dahkdja', 'uehjkw'], \"sda\") == False\n", "\n assert candidate(['happy', 'apple', 'pear', 'pie', 'yummy'], \"dog\") == True\n", "\n assert candidate([str(i) for i in range(10)], 10) == True\n"], "entry_point": "f_18967", "intent": "\u30ea\u30b9\u30c8`li`\u306e\u4e2d\u306b\u8981\u7d20`i`\u304c\u542b\u307e\u308c\u3066\u3044\u306a\u3044\u6761\u4ef6\u5206\u5c90\u3092\u884c\u3046", "library": []} {"task_id": 37648, "prompt": "def f_37648(req_data):\n\treturn ", "suffix": "", "canonical_solution": "json.dumps(req_data).encode('utf-8')", "test_start": "\nimport json\n\ndef check(candidate):", "test": ["\n assert candidate({'test': 'just a test'}) == b'{\"test\": \"just a test\"}'\n"], "entry_point": "f_37648", "intent": "\u30b5\u30fc\u30d0\u30fc\u306b\u9001\u4fe1\u3059\u308b\u30c7\u30fc\u30bf`req_data`\u3092UTF-8\u3067\u7b26\u53f7\u5316\u3059\u308b", "library": ["json"]} {"task_id": 39502, "prompt": "def f_39502(str):\n\treturn ", "suffix": "", "canonical_solution": "re.sub('([\u3042-\u3093\u30a2-\u30f3\u4e00-\u9fd0\u30fc])\\s+((?=[\u3042-\u3093\u30a2-\u30f3\u4e00-\u9fd0\u30fc]))',r'\\1\\2', str)", "test_start": "\nimport re\n\ndef check(candidate):", "test": ["\n assert candidate('\u65e5 \u672c \u8a9e \u3067 \u631f \u307e \u308c \u305f \u7a7a \u767d \u3092 \u524a \u9664 \u3059 \u308b') == '\u65e5\u672c\u8a9e\u3067\u631f\u307e\u308c\u305f\u7a7a\u767d\u3092\u524a\u9664\u3059\u308b'\n"], "entry_point": "f_39502", "intent": "\u6587\u5b57\u5217`str`\u5185\u306e\u3001\u65e5\u672c\u8a9e\u3067\u631f\u307e\u308c\u305f\u7a7a\u767d\u3092\u524a\u9664\u3059\u308b", "library": ["re"]} {"task_id": 16805, "prompt": "def f_16805(s, n):\n\treturn ", "suffix": "", "canonical_solution": "u'{0}{1}'.format(s, n)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate('abd', 35) == 'abd35'\n", "\n assert candidate('', 12.34) == '12.34'\n", "\n assert candidate([1,2,3], 'string') == '[1, 2, 3]string'\n"], "entry_point": "f_16805", "intent": "\u6587\u5b57\u5217\u306e\u5909\u6570`s`\u3068`n`\u3092UTF-8\u306b\u5909\u63db\u3057\u3066\u7d50\u5408\u3059\u308b", "library": []} {"task_id": 40978, "prompt": "def f_40978(M, N):\n\treturn ", "suffix": "", "canonical_solution": "[x+1 for x in range(M) for y in range(N)]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(2, 3) == [1,1,1,2,2,2]\n", "\n assert candidate(2, 1) == [1,2]\n"], "entry_point": "f_40978", "intent": "1\u304c`N`\u500b, 2\u304c`N`\u500b, ..., `M`\u304c`N`\u500b\u4e26\u3076\u30ea\u30b9\u30c8\u3092\u751f\u6210\u3059\u308b", "library": []} {"task_id": 40978, "prompt": "def f_40978(M, N):\n\treturn ", "suffix": "", "canonical_solution": "[i // N + 1 for i in range(N * M)]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(2, 3) == [1,1,1,2,2,2]\n", "\n assert candidate(2, 1) == [1,2]\n"], "entry_point": "f_40978", "intent": "1\u304c`N`\u500b, 2\u304c`N`\u500b, ..., `M`\u304c`N`\u500b\u4e26\u3076\u30ea\u30b9\u30c8\u3092\u751f\u6210\u3059\u308b", "library": []} {"task_id": 39379, "prompt": "def f_39379(x):\n\treturn ", "suffix": "", "canonical_solution": "[h.get_height() for h in sns.distplot(x).patches]", "test_start": "\nimport seaborn as sns\nimport numpy as np\nsns.set()\nnp.random.seed(0)\n\ndef check(candidate):", "test": ["\n x = np.random.rand(100)\n res = candidate(x)\n assert res == [\n 1.2707405677074517,\n 0.8132739633327691,\n 1.0674220768742593,\n 1.0674220768742597,\n 0.8641035860410673\n ]\n"], "entry_point": "f_39379", "intent": "distplot\u3067\u8868\u793a\u3057\u305f\u30c7\u30fc\u30bf`x`\u306b\u95a2\u3059\u308b\u30d2\u30b9\u30c8\u30b0\u30e9\u30e0\u4e0a\u306e\u30d4\u30f3\u306e\u9ad8\u3055\u3092\u30ea\u30b9\u30c8\u3068\u3057\u3066\u5f97\u308b", "library": ["numpy", "seaborn"]} {"task_id": 38415, "prompt": "def f_38415():\n\t", "suffix": "\n\treturn ax", "canonical_solution": "ax=plt.subplot(aspect='equal')", "test_start": "\nimport matplotlib.pyplot as plt \n\ndef check(candidate):", "test": ["\n res_ax = candidate()\n assert res_ax.get_xlim() == res_ax.get_ylim()\n"], "entry_point": "f_38415", "intent": "\u30b0\u30e9\u30d5\u306e\u63cf\u753b\u7bc4\u56f2`ax`\u3092\u6b63\u65b9\u5f62\u306b\u3059\u308b", "library": ["matplotlib"]} {"task_id": 37757, "prompt": "def f_37757(string):\n\treturn ", "suffix": "", "canonical_solution": "eval(string)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(\"[1,1,1,2,2,2]\") == [1,1,1,2,2,2]\n", "\n assert candidate(\"[1,2]\") == [1,2]\n"], "entry_point": "f_37757", "intent": "\u6587\u5b57\u5217\u578b\u5909\u6570`string`\u306e\u5024\u3092\u6570\u5024\u578b\u306e\u30a4\u30f3\u30b9\u30bf\u30f3\u30b9\u5909\u6570\u3068\u3057\u3066\u8a55\u4fa1\u3059\u308b", "library": []} {"task_id": 34422, "prompt": "def f_34422(s_json):\n\t", "suffix": "\n\treturn d", "canonical_solution": "d = json.loads(s_json)", "test_start": "\nimport json\n\ndef check(candidate):", "test": ["\n assert candidate('{\"a\":123,\"b\":45.6}') == {'a':123, 'b':45.6}\n"], "entry_point": "f_34422", "intent": "JSON\u3092\u8868\u3059\u6587\u5b57\u5217`s_json`\u304b\u3089\u8f9e\u66f8\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`d`\u3092\u5f97\u308b", "library": ["json"]} {"task_id": 27686, "prompt": "def f_27686(soup):\n\treturn ", "suffix": "", "canonical_solution": "soup.get('a_id')", "test_start": "\nfrom bs4 import BeautifulSoup\n\ndef check(candidate):", "test": ["\n soup = BeautifulSoup('

riginsf

')\n soup['a_id'] = 'some value'\n assert candidate(soup) == 'some value'\n"], "entry_point": "f_27686", "intent": "HTML\u30d1\u30fc\u30b9\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`soup`\u306e\u4e2d\u3067HTML\u30bf\u30b0\u306e`a_id`\u306e\u5c5e\u6027\u5024\u3092\u53d6\u5f97\u3059\u308b", "library": ["bs4"]} {"task_id": 41054, "prompt": "def f_41054():\n\treturn ", "suffix": "", "canonical_solution": "[os.rename(f, f.replace('.dat', '.gui')) for f in os.listdir('.') if not f.startswith('.')]", "test_start": "\nimport os\n\ndef check(candidate):", "test": ["\n assert all([((item is None) or item.endswiths('.gui')) for item in candidate()])\n"], "entry_point": "f_41054", "intent": "\u30ab\u30ec\u30f3\u30c8\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u3042\u308b\u7279\u5b9a\u306e\u62e1\u5f35\u5b50`.dat`\u3092\u3082\u3064\u30d5\u30a1\u30a4\u30eb\u306e\u62e1\u5f35\u5b50\u3092`.gui`\u306b\u3059\u3079\u3066\u66f8\u304d\u63db\u3048\u308b", "library": ["os"]} {"task_id": 43303, "prompt": "def f_43303(df):\n\t", "suffix": "\n\treturn df2", "canonical_solution": "df2 = df.reset_index(drop=True)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame(data={'col1':[0,1,2,3], 'col2': pd.Series([2,3], index=[2,3])}, index=[0,2,1,3])\n assert candidate(df).equals(pd.DataFrame(data={'col1': [0,1,2,3], 'col2': pd.Series([2,3], index=[1,3])}, index=[0,1,2,3]))\n"], "entry_point": "f_43303", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u30ea\u30bb\u30c3\u30c8\u3057\u305f\u65b0\u305f\u306a\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df2`\u3092\u5f97\u308b", "library": ["pandas"]} {"task_id": 43322, "prompt": "def f_43322(df):\n\treturn ", "suffix": "", "canonical_solution": "df.resample('1min').ffill()", "test_start": "\nimport io\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n data = (\n \"\u5e74\u6708\u65e5\u6642,\u6c17\u6e29(\u2103),\u964d\u6c34\u91cf(mm),\u98a8\u901f(m/s),\u65e5\u5c04\u91cf(MJ/\u33a1)\\n\"\n \"2017-01-01 00:00:00,5.8,0.0,1.5,0.0\\n\"\n \"2017-01-01 01:00:00,4.9,0.0,0.8,0.0\\n\"\n \"2017-01-01 02:00:00,4.9,0.0,1.5,0.0\\n\"\n \"2017-01-01 03:00:00,4.2,0.0,0.8,0.0\\n\"\n \"2017-01-01 04:00:00,4.4,0.0,1.0,0.0\\n\"\n )\n df = pd.read_csv(io.StringIO(data), parse_dates=['\u5e74\u6708\u65e5\u6642'], index_col='\u5e74\u6708\u65e5\u6642')\n res = candidate(df)\n assert len(res) == 241\n"], "entry_point": "f_43322", "intent": "\u6642\u7cfb\u5217\u30c7\u30fc\u30bf\u306e\u5165\u3063\u305f\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u30921\u5206\u3054\u3068\u306b\u30ea\u30b5\u30f3\u30d7\u30eb\u3057\u3001\u9593\u306e\u5024\u306f\u76f4\u524d\u306e\u5024\u3067\u88dc\u5b8c\u3059\u308b", "library": ["io", "pandas"]} {"task_id": 35683, "prompt": "def f_35683(z):\n\treturn ", "suffix": "", "canonical_solution": "z.real", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(1.23-0j) == 1.23\n", "\n assert candidate(1.23+0j) == 1.23\n", "\n assert candidate(0.0-1j) == 0.0\n"], "entry_point": "f_35683", "intent": "\u8907\u7d20\u6570`z`\u306e\u5b9f\u6570\u90e8\u306e\u307f\u3092\u5f97\u308b", "library": []} {"task_id": 41058, "prompt": "def f_41058(iter, r):\n\treturn ", "suffix": "", "canonical_solution": "list(itertools.combinations(iter, r))", "test_start": "\nimport itertools \n\ndef check(candidate):", "test": ["\n assert candidate([1,2,3], 2) == [(1, 2), (1, 3), (2, 3)]\n", "\n assert candidate([1], 2) == []\n", "\n assert candidate([1], 1) == [(1, )]\n"], "entry_point": "f_41058", "intent": "\u30a4\u30c6\u30e9\u30d6\u30eb\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`iter`\u306e`r`\u500b\u306e\u8981\u7d20\u306e\u7d44\u307f\u5408\u308f\u305b\u3092\u30ea\u30b9\u30c8\u3068\u3057\u3066\u5f97\u308b", "library": ["itertools"]} {"task_id": 42573, "prompt": "def f_42573(sheet, row, col):\n\treturn ", "suffix": "", "canonical_solution": "sheet.cell_value(row, col)", "test_start": "\nimport xlrd\nfrom xlwt import Workbook\n\ndef check(candidate):", "test": ["\n file_location = \"test.xlsx\"\n\n book = Workbook()\n sheet1 = book.add_sheet('Sheet 1')\n sheet1.write(0, 0, 'A1')\n sheet1.write(0, 1, 'B1')\n sheet1.write(8, 5, \"Hello, world!\")\n book.save(file_location)\n\n workbook = xlrd.open_workbook(file_location)\n sheet = workbook.sheet_by_index(0)\n assert candidate(sheet, 0, 0) == \"A1\"\n assert candidate(sheet, 0, 1) == \"B1\"\n assert candidate(sheet, 8, 5) == \"Hello, world!\"\n"], "entry_point": "f_42573", "intent": "Excel\u30b7\u30fc\u30c8\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`sheet`\u5185\u306e\u884c`row`\u3001\u5217`col`\u306e\u30bb\u30eb\u306e\u5024\u3092\u5f97\u308b", "library": ["xlrd", "xlwt"]} {"task_id": 40361, "prompt": "def f_40361(func, args):\n\treturn ", "suffix": "", "canonical_solution": "func(*args)", "test_start": "\ndef check(candidate):", "test": ["\n def func1(x, y, z): return x + y + z \n assert candidate(func1, [1,2,3]) == 6\n", "\n def func2(a): return 0.8\n assert candidate(func2, ['random']) == 0.8\n"], "entry_point": "f_40361", "intent": "\u5f15\u6570`args`\u3092\u30a2\u30f3\u30d1\u30c3\u30af\u3057\u3066\u95a2\u6570`func`\u306b\u6e21\u3059", "library": []} {"task_id": 43333, "prompt": "def f_43333(r, l):\n\treturn ", "suffix": "", "canonical_solution": "pd.DataFrame(data={'range': r, 'result': l})", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n r, l = [1,2,3], [4,5,6]\n assert candidate(r, l).equals(pd.DataFrame(data={'range': r, 'result': l}))\n"], "entry_point": "f_43333", "intent": "\u5217\u540d`range`\u306e\u8981\u7d20\u3092\u30ea\u30b9\u30c8`r`\u3001\u5217\u540d`result`\u306e\u8981\u7d20\u3092\u30ea\u30b9\u30c8`l`\u3068\u3057\u3066\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3092\u4f5c\u308b", "library": ["pandas"]} {"task_id": 11582, "prompt": "def f_11582():\n\treturn ", "suffix": "", "canonical_solution": "open('C:\\\\Users\\\\Documents\\\\python programs', 'r', encoding='utf-8')", "test_start": "\nimport builtins\nfrom unittest.mock import Mock\n\ndef check(candidate):", "test": ["\n with open('a.txt', 'w') as f:\n f.write('t')\n f1 = open('a.txt')\n builtins.open = Mock(return_value = f1)\n assert candidate() == f1\n"], "entry_point": "f_11582", "intent": "\u30d5\u30a1\u30a4\u30eb`C:\\Users\\Documents\\python programs`\u3092\u958b\u304f", "library": ["builtins"]} {"task_id": 12174, "prompt": "def f_12174():\n\treturn ", "suffix": "", "canonical_solution": "sys.path", "test_start": "\nimport sys\n\ndef check(candidate):", "test": ["\n assert candidate() == sys.path\n"], "entry_point": "f_12174", "intent": "PYTHONPATH\u3092\u8868\u793a\u3059\u308b", "library": ["sys"]} {"task_id": 6225, "prompt": "def f_6225():\n\treturn ", "suffix": "", "canonical_solution": "sum(1 for line in open('myfile.txt'))", "test_start": "\ndef check(candidate):", "test": ["\n with open('myfile.txt', 'w') as fw:\n for i in range(10): fw.write(f\"{i}\\n\")\n assert candidate() == 10\n", "\n with open('myfile.txt', 'w') as fw:\n for i in range(88): fw.write(f\"{i}\\n\")\n assert candidate() == 88\n"], "entry_point": "f_6225", "intent": "\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb`myfile.txt`\u306e\u884c\u6570\u3092\u53d6\u5f97\u3059\u308b", "library": []} {"task_id": 6225, "prompt": "def f_6225():\n\treturn ", "suffix": "", "canonical_solution": "len(open('myfile.txt').readlines())", "test_start": "\ndef check(candidate):", "test": ["\n with open('myfile.txt', 'w') as fw:\n for i in range(10): fw.write(f\"{i}\\n\")\n assert candidate() == 10\n", "\n with open('myfile.txt', 'w') as fw:\n for i in range(88): fw.write(f\"{i}\\n\")\n assert candidate() == 88\n"], "entry_point": "f_6225", "intent": "\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb`myfile.txt`\u306e\u884c\u6570\u3092\u53d6\u5f97\u3059\u308b", "library": []} {"task_id": 47199, "prompt": "def f_47199(a):\n\treturn ", "suffix": "", "canonical_solution": "a is not None", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(None) == False\n", "\n assert candidate(0) == True\n", "\n assert candidate(0.00) == True\n", "\n assert candidate([]) == True\n", "\n assert candidate(102) == True\n"], "entry_point": "f_47199", "intent": "\u5909\u6570`a`\u304cNone\u3067\u306a\u3044\u5834\u5408\u306b\u5909\u6570\u3092\u8868\u793a\u3059\u308b", "library": []} {"task_id": 23332, "prompt": "def f_23332(data):\n\t", "suffix": "\n\treturn list", "canonical_solution": "\n\tlist = []\n\tfor r in data:\n\t\tlist.append(', '.join(r))\n", "test_start": "\ndef check(candidate):", "test": ["\n data = [['a','b','c','x','y','z'],\n ['f', 'g', 'h', 'i', 'j', 'k']]\n assert candidate(data) == [\"a, b, c, x, y, z\", \"f, g, h, i, j, k\"]\n"], "entry_point": "f_23332", "intent": "\u4e8c\u6b21\u5143\u30ea\u30b9\u30c8`list`\u306e\u4e2d\u8eab\u3092\u5168\u3066", "library": []} {"task_id": 34431, "prompt": "def f_34431():\n\t", "suffix": "\n\treturn f", "canonical_solution": "f = open('all_names.csv', 'w', encoding='UTF-8') ", "test_start": "\ndef check(candidate):", "test": ["\n f = candidate()\n assert f.name == 'all_names.csv'\n assert f.mode == 'w'\n assert f.encoding == 'UTF-8'\n"], "entry_point": "f_34431", "intent": "\u6587\u5b57\u30b3\u30fc\u30c9", "library": []} {"task_id": 33700, "prompt": "def f_33700(list):\n\t", "suffix": "\n\treturn newlist", "canonical_solution": "\n\tnewlist = []\n\tfor s in list: \n\t\tif s.endswith('string'): \n\t\t\tnewlist.append(s)\n", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(['abcstring', 'bbbb', 'fhstringyjn', '1326546']) == ['abcstring']\n"], "entry_point": "f_33700", "intent": "\u30ea\u30b9\u30c8`list`\u304b\u3089\u6761\u4ef6\u3068\u306a\u308b\u6587\u5b57\u5217`string`\u3068\u90e8\u5206\u4e00\u81f4\u3059\u308b\u8981\u7d20\u3092\u53d6\u308a\u51fa\u3057\u3066\u65b0\u3057\u3044\u30ea\u30b9\u30c8`newlist`\u3092\u4f5c\u308b", "library": []} {"task_id": 33700, "prompt": "def f_33700(list):\n\t", "suffix": "\n\treturn newlist", "canonical_solution": "newlist = []\n\tfor s in list:\n\t if 'string' in s:\n\t newlist.append(s)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(['abcstring', 'bbbb', 'fhstringyjn', '1326546']) == ['abcstring', 'fhstringyjn']\n"], "entry_point": "f_33700", "intent": "\u30ea\u30b9\u30c8`list`\u304b\u3089\u6761\u4ef6\u3068\u306a\u308b\u6587\u5b57\u5217`string`\u3068\u90e8\u5206\u4e00\u81f4\u3059\u308b\u8981\u7d20\u3092\u53d6\u308a\u51fa\u3057\u3066\u65b0\u3057\u3044\u30ea\u30b9\u30c8`newlist`\u3092\u4f5c\u308b", "library": []} {"task_id": 27556, "prompt": "def f_27556():\n\treturn ", "suffix": "", "canonical_solution": "plt.figure() ", "test_start": "\nimport matplotlib\nimport matplotlib.pyplot as plt\n\ndef check(candidate):", "test": ["\n assert isinstance(candidate(), matplotlib.figure.Figure)\n"], "entry_point": "f_27556", "intent": "\u30b0\u30e9\u30d5\u3092\u8868\u793a\u3059\u308b", "library": ["matplotlib"]} {"task_id": 37060, "prompt": "def f_37060(data_frame):\n\treturn ", "suffix": "", "canonical_solution": "display(data_frame)", "test_start": "\nimport pandas as pd\nfrom IPython.display import display\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame([1, 2, 3])\n try:\n candidate(df)\n except:\n assert False\n"], "entry_point": "f_37060", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`data_frame`\u3092\u8868\u793a\u3059\u308b", "library": ["IPython", "pandas"]} {"task_id": 12310, "prompt": "def f_12310():\n\t", "suffix": "\n\treturn table", "canonical_solution": "table = Texttable()\n\tprint(table.draw())", "test_start": "\nfrom texttable import Texttable\n\ndef check(candidate):", "test": ["\n try:\n candidate()\n except:\n assert False\n"], "entry_point": "f_12310", "intent": "\u8868`table`\u3092\u753b\u9762\u306b\u8868\u793a\u3059\u308b\uff08texttable)", "library": ["texttable"]} {"task_id": 19311, "prompt": "def f_19311():\n\treturn ", "suffix": "", "canonical_solution": "pd.read_csv('arena.txt', header=None, delim_whitespace=True, decimal=',')", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n file_name = 'arena.txt'\n with open(file_name, 'w') as f:\n f.write('1 0,000000 4,219309 4,219309 8,988674 8,988674 10,848450\\n')\n f.write('2 4,219309 7,414822 7,414822 12,430150 12,430150 14,198310\\n')\n f.write('3 8,000000 10,478795 10,478795 15,417747 15,417747 17,297929\\n')\n f.write('1 11,000000 14,257995 14,257995 19,009302 19,009302 20,873072\\n')\n df = candidate()\n assert df.shape[0] == 4\n assert df.shape[1] == 7\n"], "entry_point": "f_19311", "intent": "\u5c11\u6570\u70b9\u306b\u30b3\u30f3\u30de\u304c\u4f7f\u308f\u308c\u3066\u3044\u308b\u30d5\u30a1\u30a4\u30eb`arena.txt`\u3092\u8aad\u307f\u8fbc\u3080", "library": ["pandas"]} {"task_id": 42268, "prompt": "def f_42268(json_data):\n\t", "suffix": "\n\treturn json_str", "canonical_solution": "json_str = json.dumps(json_data)", "test_start": "\nimport json\n\ndef check(candidate):", "test": ["\n assert candidate({'a': 134, 'bvgdfbh': 46.7576}) == '{\"a\": 134, \"bvgdfbh\": 46.7576}'\n", "\n assert candidate(['foo', {'bar': ('baz', None, 1.0, 2)}]) == '[\"foo\", {\"bar\": [\"baz\", null, 1.0, 2]}]'\n"], "entry_point": "f_42268", "intent": "\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`json_data`\u3092JSON\u6587\u5b57\u5217`json_str`\u306b\u5909\u63db\u3059\u308b", "library": ["json"]} {"task_id": 51387, "prompt": "def f_51387():\n\t", "suffix": "\n\treturn data", "canonical_solution": "data = np.genfromtxt('file.csv')", "test_start": "\nimport numpy as np\nfrom unittest.mock import Mock\n\ndef check(candidate):", "test": ["\n np.genfromtxt = Mock(return_value = np.array([[2, 3, 5], [1, 5, 6]]))\n assert candidate().shape == (2, 3)\n", "\n np.genfromtxt = Mock(return_value = np.array([['abc'], ['lkm']]))\n assert candidate().shape == (2, 1)\n"], "entry_point": "f_51387", "intent": "CSV\u30d5\u30a1\u30a4\u30eb`file.csv`\u3092`data`\u306b\u8aad\u307f\u8fbc\u3080", "library": ["numpy"]} {"task_id": 38598, "prompt": "def f_38598(df):\n\t", "suffix": "\n\treturn ", "canonical_solution": "df.drop(df.index[df.row == \"condition\"], inplace=True)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame({'row': ['\u540c\u610f\u3057\u307e\u3059', 'condition', '\u540c\u610f\u3057\u307e\u3059', '\u540c\u610f\u3057\u307e\u305b\u3093',]},\n index=[1, 2, 3, 4, ])\n candidate(df)\n assert df.shape == (3, 1)\n"], "entry_point": "f_38598", "intent": "\u6761\u4ef6`condition`\u3092\u6e80\u305f\u3059\u884c\u3092\u524a\u9664\u3059\u308b", "library": ["pandas"]} {"task_id": 20094, "prompt": "def f_20094(list, x, y):\n\treturn ", "suffix": "", "canonical_solution": "list[x][y]", "test_start": "\nimport json\n\ndef check(candidate):", "test": ["\n mat = [[i+j for i in range(2)] for j in range(3)]\n assert candidate(mat, 0, 0) == 0\n", "\n mat = [[i+j for i in range(2)] for j in range(3)]\n assert candidate(mat, 2, 1) == 3\n"], "entry_point": "f_20094", "intent": "\u4e8c\u6b21\u5143\u30ea\u30b9\u30c8`list`\u5185\u306e\u8981\u7d20", "library": ["json"]} {"task_id": 18780, "prompt": "def f_18780(x, y):\n\t", "suffix": "\n\treturn ", "canonical_solution": "for i in range(x):\n\t for j in range(y):\n\t exec(\"list_\" + str(i) + \"_\" + str(j) + \"= [i, j]\")", "test_start": "\ndef check(candidate):", "test": ["\n try:\n candidate(3, 4)\n except:\n assert False\n"], "entry_point": "f_18780", "intent": "for\u30eb\u30fc\u30d7\u3067\u6570\u5b57\u3092\u6dfb\u5b57\u306b\u6301\u3064\u4e8c\u6b21\u5143\u30ea\u30b9\u30c8`list`\u3092\u751f\u6210\u3059\u308b", "library": []} {"task_id": 19552, "prompt": "def f_19552():\n\t", "suffix": "\n\treturn file_name", "canonical_solution": "now = datetime.datetime.now()\n\tfile_name = 'file_{0:%Y%m%d-%H%M%S}.txt'.format(now)", "test_start": "\nimport datetime\n\ndef check(candidate):", "test": ["\n file_name = candidate()\n later_name = 'file_{0:%Y%m%d-%H%M%S}.txt'.format(datetime.datetime.now())\n assert file_name.split('-')[0] == later_name.split('-')[0]\n", "\n file_time = int(file_name.split('-')[1].split('.')[0])\n later_time = int(later_name.split('-')[1].split('.')[0])\n assert (later_time - file_time) < 100\n"], "entry_point": "f_19552", "intent": "\u30d5\u30a1\u30a4\u30eb\u540d\u306b\u73fe\u5728\u306e\u65e5\u4ed8\u3092\u5165\u308c\u308b", "library": ["datetime"]} {"task_id": 38755, "prompt": "def f_38755(x, y):\n\t", "suffix": "\n\treturn img", "canonical_solution": "\n\ta, b = np.polyfit(x, y, 1)\n\tlinear = a * x + b\n\timg = plt.plot(x, linear,color=\"black\")\n", "test_start": "\nimport numpy as np\nimport matplotlib\nimport matplotlib.pyplot as plt\n\ndef check(candidate):", "test": ["\n x = np.linspace(0,1,100)\n y = np.random.rand(100)\n try:\n img = candidate(x, y)\n assert type(img[0]) == matplotlib.lines.Line2D\n except:\n assert False\n"], "entry_point": "f_38755", "intent": "\u30b0\u30e9\u30d5\u306b\u7dda\u5f62\u56de\u5e30\u76f4\u7dda\u3092\u8ffd\u52a0\u3059\u308b", "library": ["matplotlib", "numpy"]} {"task_id": 4556, "prompt": "def f_4556():\n\t", "suffix": "\n\treturn ", "canonical_solution": "class Foo:\n\t def whoAmI(self):\n\t print( \"I am \" + self.__class__.__name__)\n\t\n\tFoo().whoAmI()", "test_start": "\nimport sys\n\ndef check(candidate):", "test": ["\n f = open('output', 'w')\n sys.stdout = f\n candidate()\n f.close()\n with open ('output', 'r') as f1:\n lines = f1.readlines()\n assert 'I am Foo' in lines[0]\n"], "entry_point": "f_4556", "intent": "\u30e1\u30f3\u30d0\u95a2\u6570\u304b\u3089\u30af\u30e9\u30b9\u306e\u540d\u524d\u3092\u53d6\u5f97\u3059\u308b", "library": ["sys"]} {"task_id": 27922, "prompt": "def f_27922():\n\treturn ", "suffix": "", "canonical_solution": "{\"User-Agent\": \"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:47.0) Gecko/20100101 Firefox/47.0\"}", "test_start": "\nimport urllib.request\n\ndef check(candidate):", "test": ["\n url = \"https://en.wikipedia.org/wiki/List_of_national_independence_days\"\n request = urllib.request.Request(url=url, headers=candidate())\n response = urllib.request.urlopen(request)\n assert response.getcode() == 200\n"], "entry_point": "f_27922", "intent": "\u30e6\u30fc\u30b6\u30fc\u30a8\u30fc\u30b8\u30a7\u30f3\u30c8\u3092Firefox\u306b\u5909\u66f4\u3059\u308b", "library": ["urllib"]} {"task_id": 35394, "prompt": "def f_35394(file):\n\treturn ", "suffix": "", "canonical_solution": "pd.read_csv(file, sep='\\s+')", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n file_name = 'a.csv'\n with open (file_name, 'w') as f:\n f.write('1 2\\n')\n df = candidate(file_name)\n assert df.shape == (0, 2)\n", "\n with open (file_name, 'w') as f:\n f.write('abc def\\nefg hij')\n df = candidate(file_name)\n assert df.shape == (1, 2)\n"], "entry_point": "f_35394", "intent": "\u7a7a\u767d\u3067\u533a\u5207\u3089\u308c\u305fCSV\u30d5\u30a1\u30a4\u30eb`file`\u3092\u8aad\u307f\u8fbc\u3080", "library": ["pandas"]} {"task_id": 35394, "prompt": "def f_35394(file):\n\treturn ", "suffix": "", "canonical_solution": "pd.read_csv(file, delim_whitespace=True)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n file_name = 'a.csv'\n with open (file_name, 'w') as f:\n f.write('1 2\\n')\n df = candidate(file_name)\n assert df.shape == (0, 2)\n", "\n with open (file_name, 'w') as f:\n f.write('abc def\\nefg hij')\n df = candidate(file_name)\n assert df.shape == (1, 2)\n"], "entry_point": "f_35394", "intent": "\u7a7a\u767d\u3067\u533a\u5207\u3089\u308c\u305fCSV\u30d5\u30a1\u30a4\u30eb`file`\u3092\u8aad\u307f\u8fbc\u3080", "library": ["pandas"]} {"task_id": 37591, "prompt": "def f_37591(variable, value):\n\t", "suffix": "\n\treturn variable", "canonical_solution": "variable = value if variable is None else variable", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(123, 1) == 123\n", "\n assert candidate(None, 1) == 1\n", "\n assert candidate([], 1) == []\n"], "entry_point": "f_37591", "intent": "\u5909\u6570`variable`\u306b\u5024\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u306e\u307f\u5024\u3092\u4ee3\u5165\u3092\u3059\u308b", "library": []} {"task_id": 37591, "prompt": "def f_37591(variable, value):\n\t", "suffix": "\n\treturn variable", "canonical_solution": "variable = value if variable is None else variable", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(123, 1) == 123\n", "\n assert candidate(None, 1) == 1\n", "\n assert candidate([], 1) == []\n"], "entry_point": "f_37591", "intent": "\u5909\u6570`variable`\u306b\u5024\u304c\u5165\u3063\u3066\u3044\u306a\u3044\u5834\u5408\u306e\u307f\u5024\u3092\u4ee3\u5165\u3092\u3059\u308b", "library": []} {"task_id": 11601, "prompt": "def f_11601():\n\t", "suffix": "\n\treturn ", "canonical_solution": "os.startfile('C:\\Program Files\\....\\app.exe')", "test_start": "\nimport os\nfrom unittest.mock import Mock\n\ndef check(candidate):", "test": ["\n os.startfile = Mock()\n try:\n candidate()\n except:\n assert False\n"], "entry_point": "f_11601", "intent": "Windows\u4e0a\u306e\u30a2\u30d7\u30ea\u30b1\u30fc\u30b7\u30e7\u30f3`app`\u3092\u5b9f\u884c\u3059\u308b", "library": ["os"]} {"task_id": 26837, "prompt": "def f_26837(number):\n\t", "suffix": "\n\treturn num_list", "canonical_solution": "\n\tnum_list = []\n\twhile number != 0:\n\t\tnum_list.append(number % 10)\n\t\tnumber //= 10\n\tnum_list.reverse()\n", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(123) == [1,2,3]\n"], "entry_point": "f_26837", "intent": "\u6570\u5024`number`\u3092\u4e00\u6841\u305a\u3064\u53d6\u5f97\u3057\u3066\u30ea\u30b9\u30c8`num_list`\u306b\u3059\u308b", "library": []} {"task_id": 26837, "prompt": "def f_26837(number):\n\t", "suffix": "\n\treturn num_list", "canonical_solution": "num_list = map(int, str(number))", "test_start": "\ndef check(candidate):", "test": ["\n assert list(candidate(123)) == [1,2,3]\n"], "entry_point": "f_26837", "intent": "\u6570\u5024`number`\u3092\u4e00\u6841\u305a\u3064\u53d6\u5f97\u3057\u3066\u30ea\u30b9\u30c8`num_list`\u306b\u3059\u308b", "library": []} {"task_id": 59780, "prompt": "def f_59780():\n\t", "suffix": "\n\treturn result", "canonical_solution": "\n\tdef example(a, b): return b\n\thello = tf.constant(\"Hello\")\n\tf = tf.function(example)\n\tresult = eval(f([], hello))\n", "test_start": "\nimport tensorflow as tf\nfrom tensorflow.keras.backend import eval\n\ndef check(candidate):", "test": ["\n assert candidate() == b'Hello'\n"], "entry_point": "f_59780", "intent": "\u5b9a\u6570\u306e\u8a55\u4fa1\u7d50\u679c\u3092\u8868\u793a\u3059\u308b", "library": ["tensorflow"]} {"task_id": 38276, "prompt": "def f_38276(text):\n\t", "suffix": "\n\treturn list", "canonical_solution": "\n\tpattern = r\"([0-9]+)\"\n\tlist=re.findall(pattern,text)\n", "test_start": "\nimport re\n\ndef check(candidate):", "test": ["\n assert candidate('fg456fgxnd') == ['456']\n"], "entry_point": "f_38276", "intent": "\u6b63\u898f\u8868\u73fe\u3067\u6587\u5b57\u5217`text`\u306e\u4e2d\u304b\u3089\u6570\u5024\u3060\u3051\u3092\u62bd\u51fa\u3057\u3066\u30ea\u30b9\u30c8`list`\u306b\u3059\u308b", "library": ["re"]} {"task_id": 49558, "prompt": "def f_49558(x, y, df):\n\t", "suffix": "\n\treturn rp", "canonical_solution": "rp = sns.regplot(x, y, data=df, order=1, line_kws={\"color\":\"indianred\"})\n\trp.axes.set_ylim(0,)", "test_start": "\nimport pandas as pd\nimport seaborn as sns\n\ndef check(candidate):", "test": ["\n df = pd.DataFrame([[0, 1, 2], [7, 8, 9]])\n rp = candidate(df[0], df[1], df)\n assert 'Axes' in str(type(rp))\n"], "entry_point": "f_49558", "intent": "y\u8ef8\u306e\u4e0b\u9650\u5024\u3092\u6307\u5b9a\u3057\u3001\u4e0a\u9650\u5024\u306f\u81ea\u52d5\u306b\u3059\u308b", "library": ["pandas", "seaborn"]} {"task_id": 65284, "prompt": "def f_65284(word, h):\n\t", "suffix": "\n\treturn word", "canonical_solution": "tmp1 = word[:h]\n\tword = word[h:]\n\tword.extend(tmp1)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([\"a\",\"b\",\"c\",\"d\",\"e\",\"f\",\"g\"], 4) == [\"e\",\"f\",\"g\",\"a\",\"b\",\"c\",\"d\"]\n"], "entry_point": "f_65284", "intent": "\u6587\u5b57\u5217`word`\u306e\u9806\u756a\u3092`h`\u756a\u76ee\u3067\u5165\u308c\u66ff\u3048\u308b", "library": []} {"task_id": 31916, "prompt": "def f_31916(attributes):\n\t", "suffix": "\n\treturn attributes", "canonical_solution": "for i, attribute in enumerate(attributes):\n\t attributes[i] = attribute-1", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1,2,3]) == [0,1,2]\n", "\n assert candidate([100]) == [99]\n"], "entry_point": "f_31916", "intent": "\u30ea\u30b9\u30c8`attributes`\u306e\u5168\u8981\u7d20\u306e\u6570\u5024\u306b\u5bfe\u3057\u3066for\u6587\u3067\u30de\u30a4\u30ca\u30b91\u3059\u308b", "library": []} {"task_id": 31916, "prompt": "def f_31916(attributes):\n\t", "suffix": "\n\treturn attributes", "canonical_solution": "for i in range(len(attributes)):\n\t attributes[i] = attributes[i]-1", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1,2,3,4]) == [0,1,2,3]\n", "\n assert candidate([1., 2, 3.4, 5.5]) == [0., 1, 2.4, 4.5]\n"], "entry_point": "f_31916", "intent": "\u30ea\u30b9\u30c8`attributes`\u306e\u5168\u8981\u7d20\u306e\u6570\u5024\u306b\u5bfe\u3057\u3066for\u6587\u3067\u30de\u30a4\u30ca\u30b91\u3059\u308b", "library": []} {"task_id": 31916, "prompt": "def f_31916(attributes):\n\t", "suffix": "\n\treturn attributes", "canonical_solution": "attributes = [attribute-1 for attribute in attributes]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1,2,3,4]) == [0,1,2,3]\n", "\n assert candidate([1., 2, 3.4, 5.5]) == [0., 1, 2.4, 4.5]\n"], "entry_point": "f_31916", "intent": "\u30ea\u30b9\u30c8`attributes`\u306e\u5168\u8981\u7d20\u306e\u6570\u5024\u306b\u5bfe\u3057\u3066for\u6587\u3067\u30de\u30a4\u30ca\u30b91\u3059\u308b", "library": []} {"task_id": 21171, "prompt": "def f_21171(list):\n\treturn ", "suffix": "", "canonical_solution": "Counter(map(tuple, list))", "test_start": "\nfrom collections import Counter\n\ndef check(candidate):", "test": ["\n li=[[1,2,3],[2,3,4],[3,4,5],[4,5,6],[2,3,4],[1,2,3],[2,3,4],[5,6,7]]\n c = candidate(li)\n assert c.most_common() == [((2, 3, 4), 3), ((1, 2, 3), 2), ((3, 4, 5), 1), ((4, 5, 6), 1), ((5, 6, 7), 1)]\n", "\n li = [['abc', 'def'], ['hij', 'klm']]\n c = candidate(li)\n assert c.most_common() ==[(('abc', 'def'), 1), (('hij', 'klm'), 1)]\n"], "entry_point": "f_21171", "intent": "\u4e8c\u6b21\u5143\u30ea\u30b9\u30c8`list`\u304b\u3089\u91cd\u8907\u3059\u308b\u8981\u7d20\u306e\u307f\u62bd\u51fa\u3059\u308b", "library": ["collections"]} {"task_id": 45204, "prompt": "def f_45204(num_of_file):\n\t", "suffix": "\n\treturn data", "canonical_solution": "data = [None] * num_of_file\n\tfor i in range(num_of_file):\n\t with open('data{}.txt'.format(i + 1), mode=\"r\", encoding=\"utf-8\") as f:\n\t data[i] = f.read()", "test_start": "\ndef check(candidate):", "test": ["\n num_of_file = 4\n for i in range(0, num_of_file):\n with open ('data'+str(i + 1)+'.txt', 'w') as f:\n f.write(str(i + 1)+'\\n')\n data = candidate(4)\n for i in range(0, num_of_file):\n assert data[i] == str(i + 1)+'\\n'\n"], "entry_point": "f_45204", "intent": "\u9023\u756a\u500b\u6570`num_of_file`\u306etxt\u30d5\u30a1\u30a4\u30eb`data{}.txt`\u3092\u8aad\u307f\u8fbc\u3080", "library": []} {"task_id": 24786, "prompt": "def f_24786(string):\n\treturn ", "suffix": "", "canonical_solution": "urllib.parse.urlencode(string).encode('ascii')", "test_start": "\nimport urllib\n\ndef check(candidate):", "test": ["\n s = {'mail':'admin@getgo.com', 'password':34}\n assert candidate(s) == b'mail=admin%40getgo.com&password=34'\n"], "entry_point": "f_24786", "intent": "\u6587\u5b57\u5217`string`\u3092byte\u578b", "library": ["urllib"]} {"task_id": 5822, "prompt": "def f_5822(imgAry):\n\t", "suffix": "\n\treturn restoredImgAry", "canonical_solution": "pca = PCA()\n\tpca.fit(imgAry)\n\tpca_res = pca.transform(imgAry)\n\trestoredImgAry = pca.inverse_transform(pca_res)", "test_start": "\nimport numpy as np \nfrom sklearn.decomposition import PCA\n\ndef check(candidate):", "test": ["\n imgAry = np.array([[1, 2], [4, 3]])\n assert np.allclose(candidate(imgAry), np.array([[1,2],[4,3]], dtype=float))\n"], "entry_point": "f_5822", "intent": "\u4e3b\u6210\u5206\u5206\u6790 ", "library": ["numpy", "sklearn"]} {"task_id": 42516, "prompt": "def f_42516(fnameF):\n\treturn ", "suffix": "", "canonical_solution": "plt.savefig(fnameF, dpi=200, bbox_inches=\"tight\", pad_inches=0.1)", "test_start": "\nimport os\nimport matplotlib.pyplot as plt\n\ndef check(candidate):", "test": ["\n candidate('v.jpg')\n assert os.path.exists('v.jpg')\n"], "entry_point": "f_42516", "intent": "\u30b0\u30e9\u30d5\u30b5\u30a4\u30ba\u3092\u8abf\u6574\u3057\u3066\u4fdd\u5b58\u3059\u308b", "library": ["matplotlib", "os"]} {"task_id": 18685, "prompt": "def f_18685(list):\n\t", "suffix": "\n\treturn list", "canonical_solution": "list = [x for x in list if x]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(['afrg ', 'fdbf', 13254, 54765.6]) == ['afrg ', 'fdbf', 13254, 54765.6]\n", "\n assert candidate(['', None, 0]) == []\n"], "entry_point": "f_18685", "intent": "\u4e8c\u6b21\u5143\u30ea\u30b9\u30c8`list`\u304b\u3089\u7a7a\u767d\u306e\u8981\u7d20\u3092\u524a\u9664\u3059\u308b", "library": []} {"task_id": 18685, "prompt": "def f_18685(list):\n\t", "suffix": "\n\treturn list", "canonical_solution": "for i in range(len(list) - 1, -1, -1):\n\t if not list[i]:\n\t del list[i]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([4,3,2,0,1,0]) == [4,3,2,1]\n", "\n assert candidate([4,3,2,[],1,0]) == [4,3,2,1]\n"], "entry_point": "f_18685", "intent": "\u4e8c\u6b21\u5143\u30ea\u30b9\u30c8`list`\u304b\u3089\u7a7a\u767d\u306e\u8981\u7d20\u3092\u524a\u9664\u3059\u308b", "library": []} {"task_id": 34692, "prompt": "def f_34692(json_string):\n\t", "suffix": "\n\treturn json_obj", "canonical_solution": "json_obj = json.loads(json_string)", "test_start": "\nimport json\n\ndef check(candidate):", "test": ["\n assert candidate('{\"a\": 5}') == {'a': 5}\n"], "entry_point": "f_34692", "intent": "JSON\u6587\u5b57\u5217`json_string`\u3092\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`json_obj`\u306b\u8aad\u307f\u8fbc\u3080\uff08json)", "library": ["json"]} {"task_id": 35864, "prompt": "def f_35864(img):\n\t", "suffix": "\n\treturn gray_img", "canonical_solution": "gray_img = cv2.cvtColor(img, cv2.COLOR_RGB2GRAY)\n\tplt.imshow(gray_img)\n\tplt.gray()\n\tplt.show()", "test_start": "\nimport os\nimport cv2\nimport numpy as np\nimport matplotlib.pyplot as plt\nfrom PIL import Image\n\ndef check(candidate):", "test": ["\n im = Image.new('RGBA', (200, 200), (255, 255, 255, 255))\n im.save('v.png')\n img = cv2.imread('v.png')\n gray_img = candidate(img)\n cv2.imwrite('v_gray.png', gray_img)\n assert os.path.exists('v_gray.png')\n"], "entry_point": "f_35864", "intent": "\u30ab\u30e9\u30fc\u753b\u50cf`img`\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u3067\u8868\u793a\u3059\u308b", "library": ["PIL", "cv2", "matplotlib", "numpy", "os"]} {"task_id": 49478, "prompt": "def f_49478(ticks, labels):\n\treturn ", "suffix": "", "canonical_solution": "plt.xticks(range(0, len(labels), ticks), labels[::ticks])", "test_start": "\nimport matplotlib.pyplot as plt\n\ndef check(candidate):", "test": ["\n ticks = 3\n labels = [1, 4]\n plt = candidate(ticks, labels)\n assert isinstance(plt, tuple)\n", "\n labels = ['abc', 'xcv']\n plt = candidate(ticks, labels)\n assert isinstance(plt, tuple)\n"], "entry_point": "f_49478", "intent": "X\u8ef8\u306e\u9593\u9694\u3092`ticks`\u306b\u3001\u30e9\u30d9\u30eb\u3092`labels`\u306b\u3059\u308b", "library": ["matplotlib"]} {"task_id": 16769, "prompt": "def f_16769(num_of_file):\n\t", "suffix": "\n\treturn book_list", "canonical_solution": "book_list = []\n\tfor n in range(1, num_of_file + 1):\n\t file_name = 'excel_file%d.xls' % (n)\n\t book_list.append(xlrd.open_workbook(file_name))", "test_start": "\nimport xlrd\nimport xlwt\n\ndef check(candidate):", "test": ["\n num_files = 3\n for i in range(0, num_files):\n workbook = xlwt.Workbook()\n sheet = workbook.add_sheet('test')\n sheet.write(0, 1, 1)\n\n workbook.save('excel_file%d.xls' % (i + 1))\n book_list = candidate(num_files)\n for bk in book_list:\n assert isinstance(bk, xlrd.book.Book)\n"], "entry_point": "f_16769", "intent": "\u9023\u756a\u306b\u306a\u3063\u3066\u3044\u308b`num_of_file`\u500b\u306eExcel\u30d5\u30a1\u30a4\u30eb`excel_file`\u3092\u30ea\u30b9\u30c8\u306b\u8aad\u307f\u8fbc\u3080", "library": ["xlrd", "xlwt"]} {"task_id": 2220, "prompt": "def f_2220(dt):\n\treturn ", "suffix": "", "canonical_solution": "dt.timestamp()", "test_start": "\nimport pytz\nimport datetime\n\ndef check(candidate):", "test": ["\n dt = datetime.datetime.fromtimestamp(123456789.123456, pytz.timezone('America/Los_Angeles'))\n assert candidate(dt) == 123456789.123456\n"], "entry_point": "f_2220", "intent": "datetime\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`dt`\u304b\u3089Unix Time\u3092\u6c42\u3081\u308b", "library": ["datetime", "pytz"]} {"task_id": 44723, "prompt": "def f_44723(df, col_name, string):\n\treturn ", "suffix": "", "canonical_solution": "df[df[col_name].str.contains(string)]", "test_start": "\nimport pandas as pd \n\ndef check(candidate):", "test": ["\n df = pd.DataFrame({'name': ['Mr. A', 'Ms. B'], 'age': [30, 23]})\n df_sub = pd.DataFrame({'name': ['Mr. A'], 'age': [30]})\n assert candidate(df, 'name', 'A').equals(df_sub)\n"], "entry_point": "f_44723", "intent": "\u884c`col_name`\u306b\u7279\u5b9a\u306e\u6587\u5b57\u5217`string`\u3092\u542b\u3080\u884c\u3092\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u304b\u3089\u62bd\u51fa\u3059\u308b", "library": ["pandas"]} {"task_id": 46711, "prompt": "def f_46711(list, n):\n\treturn ", "suffix": "", "canonical_solution": "list[-n:]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1,2,3,4,5,6,7], 2) == [6,7]\n", "\n assert candidate([1,2,3], 0) == [1,2,3]\n"], "entry_point": "f_46711", "intent": "\u30ea\u30b9\u30c8`list`\u306e\u672b\u5c3e\u304b\u3089`n`\u500b\u306e\u8981\u7d20\u3092\u53d6\u308a\u51fa\u3059", "library": []} {"task_id": 17648, "prompt": "def f_17648(b_string):\n\treturn ", "suffix": "", "canonical_solution": "b_string.decode('unicode-escape')", "test_start": "\nimport unicodedata\n\ndef check(candidate):", "test": ["\n assert candidate(b'example-string') == 'example-string'\n"], "entry_point": "f_17648", "intent": "Unicode\u30a8\u30b9\u30b1\u30fc\u30d7\u3055\u308c\u305f\u30d0\u30a4\u30c8\u5217`b_string`\u3092\u6587\u5b57\u5217\u306b\u5909\u63db", "library": ["unicodedata"]} {"task_id": 9633, "prompt": "def f_9633(str, old_s, new_s):\n\treturn ", "suffix": "", "canonical_solution": "str.replace(old_s, new_s)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate('mystring', 'my', 'your') == 'yourstring'\n"], "entry_point": "f_9633", "intent": "\u6587\u5b57\u5217`str`\u5185\u306e\u5bfe\u8c61\u6587\u5b57\u5217`old_s`\u3092\u5225\u306e\u6587\u5b57\u5217`new_s`\u306b\u7f6e\u63db\u3059\u308b", "library": []} {"task_id": 37327, "prompt": "def f_37327():\n\t", "suffix": "\n\treturn ", "canonical_solution": "\n\twhile True:\n\t\ttry:\n\t\t\tline = input()\n\t\t\tif line == '':\n\t\t\t\tbreak\n\t\t\telse:\n\t\t\t\tyield line\n\t\texcept EOFError:\n\t\t\tbreak\n", "test_start": "\nimport sys\n\ndef check(candidate):", "test": ["\n with open('p.txt', 'w') as f:\n f.write('1\\n\\n')\n f = open('p.txt')\n sys.stdin = f\n d = candidate()\n print(type(d))\n assert 'generator' in str(type(d))\n sys.stdin = sys.__stdin__\n"], "entry_point": "f_37327", "intent": "\u7a7a\u884c\u304c\u5165\u529b\u3055\u308c\u308b\u307e\u3067\u6a19\u6e96\u5165\u529b\u3092\u53d7\u3051\u4ed8\u3051\u308b", "library": ["sys"]} {"task_id": 37831, "prompt": "def f_37831(model, X, Y):\n\t", "suffix": "\n\treturn ", "canonical_solution": "model.fit(X, Y, epochs=200, batch_size=1, verbose=0)", "test_start": "\nimport numpy as np\nfrom tensorflow.keras import *\nfrom tensorflow.keras.layers import *\nfrom tensorflow.keras.optimizers import *\n\ndef check(candidate):", "test": ["\n model = Sequential([\n Dense(input_dim=2, units=1), Activation('sigmoid')\n ])\n model.compile(loss='binary_crossentropy', optimizer=SGD(lr=0.1))\n X = np.array([[0, 0], [0, 1], [1, 0], [1, 1]])\n Y = np.array([[0], [1], [1], [1]])\n\n try:\n candidate(model, X, Y)\n except:\n assert False\n"], "entry_point": "f_37831", "intent": "\u30ed\u30b0\u3092\u51fa\u529b\u305b\u305a\u306b\u30e2\u30c7\u30eb\u306e\u5b66\u7fd2\u3092\u884c\u3046", "library": ["numpy", "tensorflow"]} {"task_id": 53340, "prompt": "def f_53340(str):\n\treturn ", "suffix": "", "canonical_solution": "str.encode('utf-8')", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate('mystr') == b'mystr'\n"], "entry_point": "f_53340", "intent": "\u6587\u5b57\u5217`str`\u3092\u30d0\u30a4\u30c8\u5217", "library": []} {"task_id": 45120, "prompt": "def f_45120(n):\n\treturn ", "suffix": "", "canonical_solution": "[pd.DataFrame() for i in range(n)]", "test_start": "\nimport pandas as pd \n\ndef check(candidate):", "test": ["\n df_list = candidate(3)\n assert len(df_list) == 3\n assert all([type(a)==pd.DataFrame for a in df_list])\n"], "entry_point": "f_45120", "intent": "\u8981\u7d20\u304c\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0\u3067\u3001\u8981\u7d20\u6570`n`\u306e\u30ea\u30b9\u30c8\u3092\u4f5c\u308b", "library": ["pandas"]} {"task_id": 24987, "prompt": "def f_24987(str):\n\treturn ", "suffix": "", "canonical_solution": "re.sub('[\\u3000]{2,}', '\\u3000', str)", "test_start": "\nimport re\n\ndef check(candidate):", "test": ["\n text = u\"\u540d\u524d\uff11\u3000\u3000\u3000\u540d\u524d\uff12\u3000\u3000\u3000\u540d\u524d\uff13\u3000\u540d\u524d\uff14\u3000\u3000\u3000\"\n assert candidate(text) == '\u540d\u524d\uff11\u3000\u540d\u524d\uff12\u3000\u540d\u524d\uff13\u3000\u540d\u524d\uff14\u3000'\n"], "entry_point": "f_24987", "intent": "\u6587\u5b57\u5217`str`\u306e\u4e2d\u306e\u9023\u7d9a\u3057\u305f\u8907\u6570\u306e\u5168\u89d2\u7a7a\u767d\u30921\u3064\u306e\u5168\u89d2\u7a7a\u767d\u3067\u7f6e\u63db\u3059\u308b", "library": ["re"]} {"task_id": 50500, "prompt": "def f_50500(img):\n\treturn ", "suffix": "", "canonical_solution": "cv2.imwrite('file.jpg', img)", "test_start": "\nimport cv2\nfrom os import path\nfrom PIL import Image\n\ndef check(candidate):", "test": ["\n im = Image.new('RGBA', (200, 200), (255, 255, 255, 255))\n im.save('v.png')\n img = cv2.imread('v.png')\n candidate(img)\n assert path.exists('file.jpg')\n"], "entry_point": "f_50500", "intent": "\u753b\u50cf`img`\u3092\u30d5\u30a1\u30a4\u30eb\u540d`file.jpg`\u3068\u3057\u3066\u4fdd\u5b58\u3059\u308b", "library": ["PIL", "cv2", "os"]} {"task_id": 41336, "prompt": "def f_41336(a, b):\n\treturn ", "suffix": "", "canonical_solution": "np.dot(a, b)", "test_start": "\nimport numpy as np\n\ndef check(candidate):", "test": ["\n arr = np.array([[1,3,-5]])\n arr_1 = np.array([[4],[-2],[-1]])\n assert candidate(np.mat(arr),np.mat(arr_1)) == 3\n", "\n assert np.array_equal(candidate(np.zeros(shape=(5,2)), np.zeros(shape=(2,5))), np.zeros(shape=(5,5)))\n", "\n assert np.array_equal(candidate(np.array([[4]]), np.array([[0]])), np.array([[0]]))\n", "\n assert candidate(3,4) == 12\n"], "entry_point": "f_41336", "intent": "\u884c\u5217`a`\u3068`b`\u306e\u7a4d\u3092\u8a08\u7b97\u3059\u308b", "library": ["numpy"]} {"task_id": 48742, "prompt": "def f_48742():\n\t", "suffix": "\n\treturn ", "canonical_solution": "df = pd.read_table('file.txt', header=None, delim_whitespace=True)\n\tdf.to_csv('new_file.csv', index=False, header=False)", "test_start": "\nimport csv\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n with open(\"file.txt\", \"w\") as text_file:\n text_file.write('''col1 col2 col3\n''')\n text_file.write('''1 2 3\n''')\n \n candidate()\n import csv\n file = open('new_file.csv')\n csvreader = csv.reader(file)\n rows = []\n for row in csvreader:\n rows.append(row)\n \n assert rows[0] == ['col1', 'col2', 'col3'] and rows[1] == ['1', '2', '3']\n", "\n with open(\"file.txt\", \"w\") as text_file:\n text_file.write('''col1\n''')\n text_file.write('''1\n''')\n text_file.write('''2\n''')\n \n candidate()\n import csv\n file = open('new_file.csv')\n csvreader = csv.reader(file)\n rows = []\n for row in csvreader:\n rows.append(row)\n \n assert rows[0] == ['col1'] and rows[1] == ['1'] and rows[2] == ['2']\n", "\n with open(\"file.txt\", \"w\") as text_file:\n text_file.write('''col1 col2 col3 \n''')\n text_file.write(''' 1 2 3 \n''')\n \n candidate()\n import csv\n file = open('new_file.csv')\n csvreader = csv.reader(file)\n rows = []\n for row in csvreader:\n rows.append(row)\n \n assert rows[0] == ['col1', 'col2', 'col3'] and rows[1] == ['1', '2', '3']\n"], "entry_point": "f_48742", "intent": "\u7a7a\u767d\u533a\u5207\u308a\u306e\u30c6\u30ad\u30b9\u30c8\u30d5\u30a1\u30a4\u30eb`file.txt`\u3092\u30b3\u30f3\u30de\u533a\u5207\u308a\u306ecsv\u30d5\u30a1\u30a4\u30eb`new_file.csv`\u306b\u5909\u63db\u3059\u308b", "library": ["csv", "pandas"]} {"task_id": 35271, "prompt": "def f_35271(n):\n\treturn ", "suffix": "", "canonical_solution": "str(n)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(0) == '0'\n", "\n assert candidate(34.12) == '34.12'\n", "\n assert candidate(-1) == '-1'\n", "\n assert candidate(float('inf')) == 'inf'\n", "\n assert candidate(123412) == '123412'\n"], "entry_point": "f_35271", "intent": "\u6570\u5024`n`\u3092\u6587\u5b57\u5217\u306b\u5909\u63db\u3059\u308b", "library": []} {"task_id": 20048, "prompt": "def f_20048(li):\n\t", "suffix": "\n\treturn result", "canonical_solution": "\n\tc = Counter(tuple(x) for x in li)\n\tresult = [list(k) for k,v in c.items() if v >=2]\n", "test_start": "\nfrom collections import Counter\n\ndef check(candidate):", "test": ["\n li=[[1,2,3],[5,6,7],[2,3,4,5],[1,2,3],[7,8,9],[2,3,4,5],[1,2,3],[5,6,7]]\n assert candidate(li) == [[1, 2, 3], [5, 6, 7], [2, 3, 4, 5]]\n"], "entry_point": "f_20048", "intent": "2\u6b21\u5143\u30ea\u30b9\u30c8`li`\u5185\u306e\u91cd\u8907\u3057\u3066\u3044\u308b\u8981\u7d20\u3092\u53d6\u308a\u51fa\u3059", "library": ["collections"]} {"task_id": 21070, "prompt": "def f_21070(li, li2):\n\treturn ", "suffix": "", "canonical_solution": "list(filter(lambda x:x not in li2, li))", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1, 2, 3], [1, 3, 4]) == [2]\n", "\n assert candidate(['abc', 'def'], ['abc']) == ['def']\n"], "entry_point": "f_21070", "intent": "2\u3064\u306e\u30ea\u30b9\u30c8`li`\u3068`li2`\u3092\u6bd4\u8f03\u3057\u3001\u91cd\u8907\u3057\u3066\u3044\u308b\u8981\u7d20\u3092\u524a\u9664\u3059\u308b", "library": []} {"task_id": 19098, "prompt": "def f_19098(li):\n\t", "suffix": "\n\treturn result", "canonical_solution": "\n\tresult=[]\n\tli.sort()\n\tM = len(li) - 1\n\tfor i, e in enumerate(li):\n\t\tj = i + 1\n\t\tk = M\n\t\twhile k > j:\n\t\t\ts = li[i] + li[j] + li[k]\n\t\t\tif s == 0:\n\t\t\t\tresult.append([li[i], li[j], li[k]])\n\t\t\t\tk -= 1\n\t\t\telif s > 0:\n\t\t\t\tk -= 1\n\t\t\telse:\n\t\t\t\tj += 1\n", "test_start": "\ndef check(candidate):", "test": ["\n li = [1, -1, 0, 2]\n assert len(candidate(li)) == 1\n"], "entry_point": "f_19098", "intent": "\u6574\u6570\u3092\u8981\u7d20\u306b\u6301\u3064\u30ea\u30b9\u30c8`li'\u304b\u3089\u3001\u5408\u8a08\u3059\u308b\u30680\u306b\u306a\u308b3\u3064\u306e\u6574\u6570\u3092\u6c42\u3081\u308b", "library": []} {"task_id": 36377, "prompt": "def f_36377(ary):\n\treturn ", "suffix": "", "canonical_solution": "np.array2string(ary, separator=', ', formatter={'float_kind': lambda x: '{: .4f}'.format(x)})", "test_start": "\nimport numpy as np\n\ndef check(candidate):", "test": ["\n assert candidate(np.array([1, 2, 3])) == \"[1, 2, 3]\"\n", "\n assert candidate(np.array([])) == \"[]\"\n", "\n assert candidate(np.array([1, 2, 3, 4, 4])) == \"[1, 2, 3, 4, 4]\"\n", "\n assert candidate(np.array([1, 2, 3, 4, 5])) != \"[1 2 3 4 5]\"\n"], "entry_point": "f_36377", "intent": "\u914d\u5217`ary`\u306e\u5404\u8981\u7d20\u306b\u30b3\u30f3\u30de\u3092\u4ed8\u3051\u3066\u5c0f\u6570\u70b9\u56db\u6841\u307e\u3067\u8868\u793a\u3059\u308b", "library": ["numpy"]} {"task_id": 23839, "prompt": "def f_23839():\n\treturn ", "suffix": "", "canonical_solution": "subprocess.check_output('cat file', shell=True)", "test_start": "\nimport subprocess\nfrom unittest.mock import Mock\n\ndef check(candidate):", "test": ["\n subprocess.check_output = Mock(return_value = \"Success\")\n assert candidate() == \"Success\"\n"], "entry_point": "f_23839", "intent": "\u5916\u90e8\u30d7\u30ed\u30bb\u30b9`cat`\u3092\u547c\u3073\u51fa\u3057\u3001\u30d5\u30a1\u30a4\u30eb`file`\u306e\u4e2d\u8eab\u3092\u8aad\u307f\u8fbc\u3080", "library": ["subprocess"]} {"task_id": 34981, "prompt": "def f_34981():\n\treturn ", "suffix": "", "canonical_solution": "cv2.imread('file.png', 0)", "test_start": "\nimport cv2\nfrom os import path\nfrom PIL import Image\n\ndef check(candidate):", "test": ["\n im = Image.new('RGBA', (200, 200), (255, 255, 255, 255))\n im.save('file.png')\n img = candidate()\n cv2.imwrite('g.png', img)\n assert path.exists('g.png')\n"], "entry_point": "f_34981", "intent": "\u753b\u50cf'file.png'\u3092\u30b0\u30ec\u30fc\u30b9\u30b1\u30fc\u30eb\u3067\u8aad\u307f\u8fbc\u3080", "library": ["PIL", "cv2", "os"]} {"task_id": 33506, "prompt": "def f_33506(s):\n\treturn ", "suffix": "", "canonical_solution": "base64.b64decode(s).decode()", "test_start": "\nimport base64\n\ndef check(candidate):", "test": ["\n assert candidate(b'R2Vla3NGb3JHZWVrcw==') == 'GeeksForGeeks'\n"], "entry_point": "f_33506", "intent": "base64\u3067\u7b26\u53f7\u5316\u3055\u308c\u305f\u6587\u5b57\u5217`s`\u3092\u3092\u30c7\u30b3\u30fc\u30c9\u3059\u308b", "library": ["base64"]} {"task_id": 24190, "prompt": "def f_24190(x, y):\n\treturn ", "suffix": "", "canonical_solution": "plt.scatter(x, y)", "test_start": "\nimport matplotlib.pyplot as plt\n\ndef extract_data_from_plot(plot):\n x_plot, y_plot = plot.get_offsets().data.T\n return x_plot, y_plot\n \ndef check(candidate):", "test": ["\n x, y = [0, 1, 2], [0, 1, 2]\n plot = candidate(x, y)\n x_plot, y_plot = extract_data_from_plot(plot)\n assert y_plot.tolist(), float(y).tolist()\n assert x_plot.tolist(), float(x).tolist()\n", "\n x, y = [10.3, 11.12, 133.44], [4.9, 2.48, 3.67]\n plot = candidate(x, y)\n x_plot, y_plot = extract_data_from_plot(plot)\n assert y_plot.tolist(), float(y).tolist()\n assert x_plot.tolist(), float(x).tolist()\n"], "entry_point": "f_24190", "intent": "\u914d\u5217\u30c7\u30fc\u30bf`x`,`y`\u306e\u6563\u5e03\u56f3\u3092\u8868\u793a\u3059\u308b", "library": ["matplotlib"]} {"task_id": 40646, "prompt": "def f_40646(html):\n\t", "suffix": "\n\treturn new_list", "canonical_solution": "\n\tsoup = bs4.BeautifulSoup(html, 'lxml')\n\tunorder_list = soup.find_all('ul')\n\tnew_list = []\n\tfor ul_tag in unorder_list:\n\t for li in ul_tag.find_all('li'):\n\t new_list.append(li.text)\n", "test_start": "\nimport bs4\nimport urllib\nimport ssl\n \ndef check(candidate):", "test": ["\n ctx = ssl.create_default_context()\n ctx.check_hostname = False\n ctx.verify_mode = ssl.CERT_NONE\n url = 'https://en.wikipedia.org/wiki/Blue_Moon_of_Josephine'\n html = urllib.request.urlopen(url, context=ctx).read()\n assert 'List of diamonds' in candidate(html)\n"], "entry_point": "f_40646", "intent": "HTML\u30d5\u30a1\u30a4\u30eb`html`\u5185\u306e\u9806\u5e8f\u306a\u3057\u30ea\u30b9\u30c8\u3092python\u306e\u30ea\u30b9\u30c8\u3068\u3057\u3066\u53d6\u308a\u8fbc\u3080", "library": ["bs4", "ssl", "urllib"]} {"task_id": 41775, "prompt": "def f_41775(df, col_label):\n\treturn ", "suffix": "", "canonical_solution": "df[df.duplicated(subset=col_label)]", "test_start": "\nimport pandas as pd\nimport numpy as np\n\ndef check(candidate):", "test": ["\n df1 = pd.DataFrame(data={'CRcode':['Gk125', 'GK126'], 'client name & address':['Jhone', 'Mike']})\n assert candidate(df1, \"CRcode\").to_dict() == {'CRcode': {}, 'client name & address': {}}\n", "\n df2 = pd.DataFrame(data={'CRcode':['598', '2598', '341', '796'], 'client name & address':['random', 'random2', 'random3', 'random4']})\n assert candidate(df2, \"client name & address\").to_dict() == {'CRcode': {}, 'client name & address': {}}\n"], "entry_point": "f_41775", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u5185\u306e\u5217`col_label`\u304c\u91cd\u8907\u3057\u3066\u3044\u308b\u884c\u3092\u62bd\u51fa\u3059\u308b\uff08pandas)", "library": ["numpy", "pandas"]} {"task_id": 33034, "prompt": "def f_33034(df, col_1, col_2):\n\treturn ", "suffix": "", "canonical_solution": "pandas.crosstab(df[col_1], df[col_2]).plot(kind='bar',stacked=True)", "test_start": "\nimport pandas\n\ndef check(candidate):", "test": ["\n d = {'col_1':[1, 2], 'col_2':[3, 5]}\n df = pandas.DataFrame(data = d)\n x = candidate(df, 'col_1', 'col_2')\n assert str(type(x)).split(\"'\")[1] == 'matplotlib.axes._subplots.AxesSubplot'\n"], "entry_point": "f_33034", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u306e\u5217`col_1`\u3068`col_2`\u306b\u3064\u3044\u3066\u30af\u30ed\u30b9\u96c6\u8a08\u3092\u884c\u3063\u305f\u7d50\u679c\u3092\u7a4d\u307f\u4e0a\u3052\u30b0\u30e9\u30d5\u306b\u3059\u308b", "library": ["pandas"]} {"task_id": 23246, "prompt": "def f_23246(li, v):\n\t", "suffix": "\n\treturn ans", "canonical_solution": "ans = []\n\tfor index, value in enumerate(li):\n\t if value == v:\n\t ans.append(index)", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1,2,3,3,3,4,5], 3) == [2, 3, 4]\n"], "entry_point": "f_23246", "intent": "\u30ea\u30b9\u30c8`li`\u304b\u3089\u691c\u7d22\u3059\u308b\u5024`v`\u306b\u4e00\u81f4\u3059\u308b\u8981\u7d20\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u3059\u3079\u3066\u53d6\u5f97\u3057\u3066\u8868\u793a\u3059\u308b", "library": []} {"task_id": 23246, "prompt": "def f_23246(li, v):\n\t", "suffix": "\n\treturn ans", "canonical_solution": "ans = [ i for i, value in enumerate(li) if value == v]", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate([1,2,3,3,3,4,5], 3) == [2, 3, 4]\n"], "entry_point": "f_23246", "intent": "\u30ea\u30b9\u30c8`li`\u304b\u3089\u691c\u7d22\u3059\u308b\u5024`v`\u306b\u4e00\u81f4\u3059\u308b\u8981\u7d20\u306e\u30a4\u30f3\u30c7\u30c3\u30af\u30b9\u3092\u3059\u3079\u3066\u53d6\u5f97\u3057\u3066\u8868\u793a\u3059\u308b", "library": []} {"task_id": 30088, "prompt": "def f_30088(d, k):\n\treturn ", "suffix": "", "canonical_solution": "d.pop(k, None) ", "test_start": "\ndef check(candidate):", "test": ["\n d = {\"a\": 1, \"b\": 2, \"c\": 3}\n assert candidate(d, \"a\") == 1\n", "\n d = {\"a\": 1, \"b\": 2, \"c\": 3}\n assert candidate(d, \"b\") == 2\n", "\n d = {\"a\": 1, \"b\": 2, \"c\": 3}\n assert candidate(d, \"c\") == 3\n", "\n d = {\"a\": 1, \"b\": 2, \"c\": 3}\n assert candidate(d, \"d\") == None\n"], "entry_point": "f_30088", "intent": "\u8f9e\u66f8\u578b\u30aa\u30d6\u30b8\u30a7\u30af\u30c8`d`\u5185\u306e\u5b58\u5728\u3057\u306a\u3044\u53ef\u80fd\u6027\u304c\u3042\u308b\u30ad\u30fc`k`\u3092\u524a\u9664\u3059\u308b", "library": []} {"task_id": 41700, "prompt": "def f_41700(df, col_label):\n\treturn ", "suffix": "", "canonical_solution": "df.drop_duplicates(subset=col_label)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n d1 = {'A': [1, 1, 1, 2], 'B': [2, 2, 2, 3], 'C': [3, 3, 4, 5], 'D' : [1, 2, 3, 3]}\n source_df = pd.DataFrame(d1)\n\n d2 = {'A': [1, 1, 1], 'B': [2, 2, 2], 'C': [3, 3, 4], 'D' : [1, 2, 3]}\n res = pd.DataFrame(d2)\n \n assert candidate(source_df, ['D']).equals(res)\n"], "entry_point": "f_41700", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u5185\u306e\u5217`col_label`\u304c\u91cd\u8907\u3057\u3066\u3044\u308b\u884c\u3092\u524a\u9664\u3059\u308b\uff08pandas)", "library": ["pandas"]} {"task_id": 30824, "prompt": "def f_30824():\n\t", "suffix": "\n\treturn previous_month", "canonical_solution": "today = datetime.date.today()\n\tprevious_month = today - dateutil.relativedelta.relativedelta(months=1)", "test_start": "\nimport datetime\nimport dateutil\n\ndef check(candidate):", "test": ["\n assert candidate() == datetime.date.today() - dateutil.relativedelta.relativedelta(months=1)\n"], "entry_point": "f_30824", "intent": "\u4eca\u65e5\u304b\u3089\u4e00\u30f6\u6708\u524d\u306e\u65e5\u4ed8\u3092\u53d6\u5f97\u3059\u308b", "library": ["datetime", "dateutil"]} {"task_id": 42011, "prompt": "def f_42011(str):\n\treturn ", "suffix": "", "canonical_solution": "str.strip()", "test_start": "\ndef check(candidate):", "test": ["\n assert candidate(\" hello \") == \"hello\"\n", "\n assert candidate(\" hello world ! \") == \"hello world !\"\n", "\n assert candidate(\"hello\") == \"hello\"\n", "\n assert candidate(\"\") == \"\"\n"], "entry_point": "f_42011", "intent": "\u6587\u5b57\u5217`str`\u304b\u3089\u7a7a\u767d\u3068\u6539\u884c\u3092\u53d6\u308a\u9664\u304f", "library": []} {"task_id": 23218, "prompt": "def f_23218(data, fs):\n\t", "suffix": "\n\treturn plot", "canonical_solution": "\n\tf, t, Sxx = signal.spectrogram(data, fs)\n\tplot = plt.pcolormesh(t, f, Sxx)\n", "test_start": "\nfrom scipy import signal\nimport matplotlib.pyplot as plt\nimport numpy as np\n\ndef check(candidate):", "test": ["\n data = np.array([1, 4, 6])\n assert str(type(candidate(data, 1.0))).split(' ')[1] == \"'matplotlib.collections.QuadMesh'>\"\n"], "entry_point": "f_23218", "intent": "\u4fe1\u53f7\u30c7\u30fc\u30bf`data`\u3092\u30b5\u30f3\u30d7\u30ea\u30f3\u30b0\u5468\u6ce2\u6570`fs`\u3067\u5468\u6ce2\u6570\u89e3\u6790\u3057\u30b9\u30da\u30af\u30c8\u30ed\u30b0\u30e9\u30e0\u3092\u8868\u793a\u3059\u308b", "library": ["matplotlib", "numpy", "scipy"]} {"task_id": 39255, "prompt": "def f_39255(sjis_str):\n\treturn ", "suffix": "", "canonical_solution": "sjis_str.decode('shift-jis')", "test_start": "\ndef check(candidate):", "test": ["\n sjis_str = b'Wall'\n assert candidate(sjis_str) == 'Wall'\n"], "entry_point": "f_39255", "intent": "Shift_JIS\u3067\u7b26\u53f7\u5316\u3055\u308c\u305f\u6587\u5b57\u5217`sjis_str`\u3092\u30c7\u30b3\u30fc\u30c9\u3059\u308b", "library": []} {"task_id": 41519, "prompt": "def f_41519(df, col):\n\t", "suffix": "\n\treturn df", "canonical_solution": "df[col] = df[col].astype(str)", "test_start": "\nimport pandas as pd\n\ndef check(candidate):", "test": ["\n data = [1, 4, 5]\n df = pd.DataFrame(data, columns=['Vals'])\n candidate(df, 'Vals')\n assert str(type(df['Vals'][0])) == \"\"\n"], "entry_point": "f_41519", "intent": "\u30c7\u30fc\u30bf\u30d5\u30ec\u30fc\u30e0`df`\u306e\u5217`col`\u3092\u6587\u5b57\u5217\u578b\u306b\u5909\u66f4\u3059\u308b", "library": ["pandas"]}