message_type
stringclasses
2 values
message
stringlengths
2
232
message_id
int64
0
1
conversation_id
int64
0
2.38k
instruction
empty a list `lst`
0
300
output
lst[:] = []
1
300
instruction
empty a list `alist`
0
301
output
alist[:] = []
1
301
instruction
reset index of series `s`
0
302
output
s.reset_index(0).reset_index(drop=True)
1
302
instruction
convert unicode text from list `elems` with index 0 to normal text 'utf-8'
0
303
output
elems[0].getText().encode('utf-8')
1
303
instruction
create a list containing the subtraction of each item in list `L` from the item prior to it
0
304
output
[(y - x) for x, y in zip(L, L[1:])]
1
304
instruction
get value in string `line` matched by regex pattern '\\bLOG_ADDR\\s+(\\S+)'
0
305
output
print(re.search('\\bLOG_ADDR\\s+(\\S+)', line).group(1))
1
305
instruction
import all classes from module `some.package`
0
306
output
globals().update(importlib.import_module('some.package').__dict__)
1
306
instruction
convert a list of characters `['a', 'b', 'c', 'd']` into a string
0
307
output
"""""".join(['a', 'b', 'c', 'd'])
1
307
instruction
Slice `url` with '&' as delimiter to get "http://www.domainname.com/page?CONTENT_ITEM_ID=1234" from url "http://www.domainname.com/page?CONTENT_ITEM_ID=1234&param2&param3 "
0
308
output
url.split('&')
1
308
instruction
sort dictionary `d` by key
0
309
output
od = collections.OrderedDict(sorted(d.items()))
1
309
instruction
sort a dictionary `d` by key
0
310
output
OrderedDict(sorted(list(d.items()), key=(lambda t: t[0])))
1
310
instruction
Execute a put request to the url `url`
0
311
output
response = requests.put(url, data=json.dumps(data), headers=headers)
1
311
instruction
replace everything that is not an alphabet or a digit with '' in 's'.
0
312
output
re.sub('[\\W_]+', '', s)
1
312
instruction
create a list of aggregation of each element from list `l2` to all elements of list `l1`
0
313
output
[(x + y) for x in l2 for y in l1]
1
313
instruction
convert string `x' to dictionary splitted by `=` using list comprehension
0
314
output
dict([x.split('=') for x in s.split()])
1
314
instruction
remove index 2 element from a list `my_list`
0
315
output
my_list.pop(2)
1
315
instruction
Delete character "M" from a string `s` using python
0
316
output
s = s.replace('M', '')
1
316
instruction
null
0
317
output
newstr = oldstr.replace('M', '')
1
317
instruction
get the sum of the products of each pair of corresponding elements in lists `a` and `b`
0
318
output
sum(x * y for x, y in zip(a, b))
1
318
instruction
sum the products of each two elements at the same index of list `a` and list `b`
0
319
output
list(x * y for x, y in list(zip(a, b)))
1
319
instruction
sum the product of each two items at the same index of list `a` and list `b`
0
320
output
sum(i * j for i, j in zip(a, b))
1
320
instruction
sum the product of elements of two lists named `a` and `b`
0
321
output
sum(x * y for x, y in list(zip(a, b)))
1
321
instruction
write the content of file `xxx.mp4` to file `f`
0
322
output
f.write(open('xxx.mp4', 'rb').read())
1
322
instruction
Add 1 to each integer value in list `my_list`
0
323
output
new_list = [(x + 1) for x in my_list]
1
323
instruction
get a list of all items in list `j` with values greater than `5`
0
324
output
[x for x in j if x >= 5]
1
324
instruction
set color marker styles `--bo` in matplotlib
0
325
output
plt.plot(list(range(10)), '--bo')
1
325
instruction
set circle markers on plot for individual points defined in list `[1,2,3,4,5,6,7,8,9,10]` created by range(10)
0
326
output
plt.plot(list(range(10)), linestyle='--', marker='o', color='b')
1
326
instruction
split strings in list `l` on the first occurring tab `\t` and enter only the first resulting substring in a new list
0
327
output
[i.split('\t', 1)[0] for i in l]
1
327
instruction
Split each string in list `myList` on the tab character
0
328
output
myList = [i.split('\t')[0] for i in myList]
1
328
instruction
Sum numbers in a list 'your_list'
0
329
output
sum(your_list)
1
329
instruction
attach debugger pdb to class `ForkedPdb`
0
330
output
ForkedPdb().set_trace()
1
330
instruction
Compose keys from dictionary `d1` with respective values in dictionary `d2`
0
331
output
result = {k: d2.get(v) for k, v in list(d1.items())}
1
331
instruction
add one day and three hours to the present time from datetime.now()
0
332
output
datetime.datetime.now() + datetime.timedelta(days=1, hours=3)
1
332
instruction
null
0
333
output
[int(s[i:i + 3], 2) for i in range(0, len(s), 3)]
1
333
instruction
switch keys and values in a dictionary `my_dict`
0
334
output
dict((v, k) for k, v in my_dict.items())
1
334
instruction
sort a list `L` by number after second '.'
0
335
output
print(sorted(L, key=lambda x: int(x.split('.')[2])))
1
335
instruction
Check if the value of the key "name" is "Test" in a list of dictionaries `label`
0
336
output
any(d['name'] == 'Test' for d in label)
1
336
instruction
remove all instances of [1, 1] from list `a`
0
337
output
a[:] = [x for x in a if x != [1, 1]]
1
337
instruction
remove all instances of `[1, 1]` from a list `a`
0
338
output
[x for x in a if x != [1, 1]]
1
338
instruction
convert a list 'a' to a dictionary where each even element represents the key to the dictionary, and the following odd element is the value
0
339
output
b = {a[i]: a[i + 1] for i in range(0, len(a), 2)}
1
339
instruction
check whether elements in list `a` appear only once
0
340
output
len(set(a)) == len(a)
1
340
instruction
Generate MD5 checksum of file in the path `full_path` in hashlib
0
341
output
print(hashlib.md5(open(full_path, 'rb').read()).hexdigest())
1
341
instruction
null
0
342
output
sorted(list(data.items()), key=lambda x: x[1][0])
1
342
instruction
randomly switch letters' cases in string `s`
0
343
output
"""""".join(x.upper() if random.randint(0, 1) else x for x in s)
1
343
instruction
force bash interpreter '/bin/bash' to be used instead of shell
0
344
output
os.system('GREPDB="echo 123"; /bin/bash -c "$GREPDB"')
1
344
instruction
Run a command `echo hello world` in bash instead of shell
0
345
output
os.system('/bin/bash -c "echo hello world"')
1
345
instruction
access the class variable `a_string` from a class object `test`
0
346
output
getattr(test, a_string)
1
346
instruction
Display a image file `pathToFile`
0
347
output
Image.open('pathToFile').show()
1
347
instruction
replace single quote character in string "didn't" with empty string ''
0
348
output
"""didn't""".replace("'", '')
1
348
instruction
sort list `files` based on variable `file_number`
0
349
output
files.sort(key=file_number)
1
349