message_type
stringclasses 2
values | message
stringlengths 2
232
⌀ | message_id
int64 0
1
| conversation_id
int64 0
2.38k
|
|---|---|---|---|
instruction
|
Get a list of pairs of key-value sorted by values in dictionary `data`
| 0
| 2,300
|
output
|
sorted(list(data.items()), key=lambda x: x[1])
| 1
| 2,300
|
instruction
| null | 0
| 2,301
|
output
|
sorted(list(data.items()), key=lambda x: x[1])
| 1
| 2,301
|
instruction
|
display current time
| 0
| 2,302
|
output
|
now = datetime.datetime.now().strftime('%H:%M:%S')
| 1
| 2,302
|
instruction
|
find the index of the second occurrence of the substring `bar` in string `foo bar bar bar`
| 0
| 2,303
|
output
|
"""foo bar bar bar""".replace('bar', 'XXX', 1).find('bar')
| 1
| 2,303
|
instruction
|
check if key 'stackoverflow' and key 'google' are presented in dictionary `sites`
| 0
| 2,304
|
output
|
set(['stackoverflow', 'google']).issubset(sites)
| 1
| 2,304
|
instruction
|
replace string ' and ' in string `stuff` with character '/'
| 0
| 2,305
|
output
|
stuff.replace(' and ', '/')
| 1
| 2,305
|
instruction
|
Save array at index 0, index 1 and index 8 of array `np` to tmp file `tmp`
| 0
| 2,306
|
output
|
np.savez(tmp, *[getarray[0], getarray[1], getarray[8]])
| 1
| 2,306
|
instruction
|
substract 1 hour and 10 minutes from current time
| 0
| 2,307
|
output
|
t = datetime.datetime.now()
(t - datetime.timedelta(hours=1, minutes=10))
| 1
| 2,307
|
instruction
|
subtract 1 hour and 10 minutes from time object `t`
| 0
| 2,308
|
output
|
(t - datetime.timedelta(hours=1, minutes=10))
| 1
| 2,308
|
instruction
|
add 1 hour and 2 minutes to time object `t`
| 0
| 2,309
|
output
|
dt = datetime.datetime.combine(datetime.date.today(), t)
| 1
| 2,309
|
instruction
|
subtract 5 hours from the time object `dt`
| 0
| 2,310
|
output
|
dt -= datetime.timedelta(hours=5)
| 1
| 2,310
|
instruction
|
encode string `data` using hex 'hex' encoding
| 0
| 2,311
|
output
|
print(data.encode('hex'))
| 1
| 2,311
|
instruction
|
Return the decimal value for each hex character in data `data`
| 0
| 2,312
|
output
|
print(' '.join([str(ord(a)) for a in data]))
| 1
| 2,312
|
instruction
|
Get all the items from a list of tuple 'l' where second item in tuple is '1'.
| 0
| 2,313
|
output
|
[x for x in l if x[1] == 1]
| 1
| 2,313
|
instruction
|
Create array `a` containing integers from stdin
| 0
| 2,314
|
output
|
a.fromlist([int(val) for val in stdin.read().split()])
| 1
| 2,314
|
instruction
|
place '\' infront of each non-letter char in string `line`
| 0
| 2,315
|
output
|
print(re.sub('[_%^$]', '\\\\\\g<0>', line))
| 1
| 2,315
|
instruction
|
Get all `a` tags where the text starts with value `some text` using regex
| 0
| 2,316
|
output
|
doc.xpath("//a[starts-with(text(),'some text')]")
| 1
| 2,316
|
instruction
|
convert a list of lists `a` into list of tuples of appropriate elements form nested lists
| 0
| 2,317
|
output
|
zip(*a)
| 1
| 2,317
|
instruction
|
convert a list of strings `lst` to list of integers
| 0
| 2,318
|
output
|
[map(int, sublist) for sublist in lst]
| 1
| 2,318
|
instruction
|
convert strings in list-of-lists `lst` to ints
| 0
| 2,319
|
output
|
[[int(x) for x in sublist] for sublist in lst]
| 1
| 2,319
|
instruction
|
get index of elements in array `A` that occur in another array `B`
| 0
| 2,320
|
output
|
np.where(np.in1d(A, B))[0]
| 1
| 2,320
|
instruction
|
create a list where each element is a dictionary with keys 'key1' and 'key2' and values corresponding to each value in the lists referenced by keys 'key1' and 'key2' in dictionary `d`
| 0
| 2,321
|
output
|
[{'key1': a, 'key2': b} for a, b in zip(d['key1'], d['key2'])]
| 1
| 2,321
|
instruction
| null | 0
| 2,322
|
output
|
map(dict, zip(*[[(k, v) for v in value] for k, value in list(d.items())]))
| 1
| 2,322
|
instruction
|
Get Last Day of the first month in 2002
| 0
| 2,323
|
output
|
calendar.monthrange(2002, 1)
| 1
| 2,323
|
instruction
|
Get Last Day of the second month in 2002
| 0
| 2,324
|
output
|
calendar.monthrange(2008, 2)
| 1
| 2,324
|
instruction
|
Get Last Day of the second month in 2100
| 0
| 2,325
|
output
|
calendar.monthrange(2100, 2)
| 1
| 2,325
|
instruction
|
Get Last Day of the month `month` in year `year`
| 0
| 2,326
|
output
|
calendar.monthrange(year, month)[1]
| 1
| 2,326
|
instruction
|
Get Last Day of the second month in year 2012
| 0
| 2,327
|
output
|
monthrange(2012, 2)
| 1
| 2,327
|
instruction
|
Get Last Day of the first month in year 2000
| 0
| 2,328
|
output
|
(datetime.date(2000, 2, 1) - datetime.timedelta(days=1))
| 1
| 2,328
|
instruction
|
Calling an external command "ls -l"
| 0
| 2,329
|
output
|
from subprocess import call
| 1
| 2,329
|
instruction
|
Calling an external command "some_command with args"
| 0
| 2,330
|
output
|
os.system('some_command with args')
| 1
| 2,330
|
instruction
|
Calling an external command "some_command < input_file | another_command > output_file"
| 0
| 2,331
|
output
|
os.system('some_command < input_file | another_command > output_file')
| 1
| 2,331
|
instruction
|
Calling an external command "some_command with args"
| 0
| 2,332
|
output
|
stream = os.popen('some_command with args')
| 1
| 2,332
|
instruction
|
Calling an external command "echo Hello World"
| 0
| 2,333
|
output
|
print(subprocess.Popen('echo Hello World', shell=True, stdout=subprocess.PIPE).stdout.read())
| 1
| 2,333
|
instruction
|
Calling an external command "echo Hello World"
| 0
| 2,334
|
output
|
print(os.popen('echo Hello World').read())
| 1
| 2,334
|
instruction
|
Calling an external command "echo Hello World"
| 0
| 2,335
|
output
|
return_code = subprocess.call('echo Hello World', shell=True)
| 1
| 2,335
|
instruction
|
Calling an external command "ls"
| 0
| 2,336
|
output
|
p = subprocess.Popen('ls', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
for line in p.stdout.readlines():
print(line, end=' ')
retval = p.wait()
| 1
| 2,336
|
instruction
|
Calling an external command "ls -l"
| 0
| 2,337
|
output
|
call(['ls', '-l'])
| 1
| 2,337
|
instruction
|
decode url `url` with utf8 and print it
| 0
| 2,338
|
output
|
print(urllib.parse.unquote(url).decode('utf8'))
| 1
| 2,338
|
instruction
|
decode a urllib escaped url string `url` with `utf8`
| 0
| 2,339
|
output
|
url = urllib.parse.unquote(url).decode('utf8')
| 1
| 2,339
|
instruction
|
delete letters from string '12454v'
| 0
| 2,340
|
output
|
"""""".join(filter(str.isdigit, '12454v'))
| 1
| 2,340
|
instruction
|
Update row values for a column `Season` using vectorized string operation in pandas
| 0
| 2,341
|
output
|
df['Season'].str.split('-').str[0].astype(int)
| 1
| 2,341
|
instruction
|
sort a list of tuples `my_list` by second parameter in the tuple
| 0
| 2,342
|
output
|
my_list.sort(key=lambda x: x[1])
| 1
| 2,342
|
instruction
|
find indexes of all occurrences of a substring `tt` in a string `ttt`
| 0
| 2,343
|
output
|
[m.start() for m in re.finditer('(?=tt)', 'ttt')]
| 1
| 2,343
|
instruction
|
find all occurrences of a substring in a string
| 0
| 2,344
|
output
|
[m.start() for m in re.finditer('test', 'test test test test')]
| 1
| 2,344
|
instruction
|
split string `s` based on white spaces
| 0
| 2,345
|
output
|
re.findall('\\s+|\\S+', s)
| 1
| 2,345
|
instruction
|
set columns `['race_date', 'track_code', 'race_number']` as indexes in dataframe `rdata`
| 0
| 2,346
|
output
|
rdata.set_index(['race_date', 'track_code', 'race_number'])
| 1
| 2,346
|
instruction
|
recursively go through all subdirectories and files in `rootdir`
| 0
| 2,347
|
output
|
for (root, subFolders, files) in os.walk(rootdir):
pass
| 1
| 2,347
|
instruction
|
sort a list of dictionary values by 'date' in reverse order
| 0
| 2,348
|
output
|
list.sort(key=lambda item: item['date'], reverse=True)
| 1
| 2,348
|
instruction
|
display first 5 characters of string 'aaabbbccc'
| 0
| 2,349
|
output
|
"""{:.5}""".format('aaabbbccc')
| 1
| 2,349
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.