message_type
stringclasses
2 values
message
stringlengths
2
232
message_id
int64
0
1
conversation_id
int64
0
2.38k
instruction
remove all whitespace in a string `sentence`
0
350
output
sentence.replace(' ', '')
1
350
instruction
remove all whitespace in a string `sentence`
0
351
output
pattern = re.compile('\\s+') sentence = re.sub(pattern, '', sentence)
1
351
instruction
remove whitespace in string `sentence` from beginning and end
0
352
output
sentence.strip()
1
352
instruction
remove all whitespaces in string `sentence`
0
353
output
sentence = re.sub('\\s+', '', sentence, flags=re.UNICODE)
1
353
instruction
remove all whitespaces in a string `sentence`
0
354
output
sentence = ''.join(sentence.split())
1
354
instruction
sum all the values in a counter variable `my_counter`
0
355
output
sum(my_counter.values())
1
355
instruction
find the euclidean distance between two 3-d arrays `A` and `B`
0
356
output
np.sqrt(((A - B) ** 2).sum(-1))
1
356
instruction
create list `levels` containing 3 empty dictionaries
0
357
output
levels = [{}, {}, {}]
1
357
instruction
find the sums of length 7 subsets of a list `daily`
0
358
output
weekly = [sum(visitors[x:x + 7]) for x in range(0, len(daily), 7)]
1
358
instruction
Delete an element `key` from a dictionary `d`
0
359
output
del d[key]
1
359
instruction
Delete an element 0 from a dictionary `a`
0
360
output
{i: a[i] for i in a if (i != 0)}
1
360
instruction
Delete an element "hello" from a dictionary `lol`
0
361
output
lol.pop('hello')
1
361
instruction
Delete an element with key `key` dictionary `r`
0
362
output
del r[key]
1
362
instruction
solve for the least squares' solution of matrices `a` and `b`
0
363
output
np.linalg.solve(np.dot(a.T, a), np.dot(a.T, b))
1
363
instruction
split dictionary/list inside a pandas column 'b' into separate columns in dataframe `df`
0
364
output
pd.concat([df.drop('b', axis=1), pd.DataFrame(df['b'].tolist())], axis=1)
1
364
instruction
loop through 0 to 10 with step 2
0
365
output
for i in range(0, 10, 2): pass
1
365
instruction
loop through `mylist` with step 2
0
366
output
for i in mylist[::2]: pass
1
366
instruction
lowercase string values with key 'content' in a list of dictionaries `messages`
0
367
output
[{'content': x['content'].lower()} for x in messages]
1
367
instruction
convert a list `my_list` into string with values separated by spaces
0
368
output
""" """.join(my_list)
1
368
instruction
replace each occurrence of the pattern '(http://\\S+|\\S*[^\\w\\s]\\S*)' within `a` with ''
0
369
output
re.sub('(http://\\S+|\\S*[^\\w\\s]\\S*)', '', a)
1
369
instruction
check if string `str` is palindrome
0
370
output
str(n) == str(n)[::-1]
1
370
instruction
upload binary file `myfile.txt` with ftplib
0
371
output
ftp.storbinary('STOR myfile.txt', open('myfile.txt', 'rb'))
1
371
instruction
remove all characters from string `stri` upto character 'I'
0
372
output
re.sub('.*I', 'I', stri)
1
372
instruction
parse a comma-separated string number '1,000,000' into int
0
373
output
int('1,000,000'.replace(',', ''))
1
373
instruction
combine dataframe `df1` and dataframe `df2` by index number
0
374
output
pd.merge(df1, df2, left_index=True, right_index=True, how='outer')
1
374
instruction
null
0
375
output
pandas.concat([df1, df2], axis=1)
1
375
instruction
check if all boolean values in a python dictionary `dict` are true
0
376
output
all(dict.values())
1
376
instruction
use regex pattern '^12(?=.{4}$)' to remove digit 12 if followed by 4 other digits in column `c_contofficeID` of dataframe `df`
0
377
output
df.c_contofficeID.str.replace('^12(?=.{4}$)', '')
1
377
instruction
reverse a list `L`
0
378
output
L[::(-1)]
1
378
instruction
reverse a list `array`
0
379
output
reversed(array)
1
379
instruction
reverse a list `L`
0
380
output
L.reverse()
1
380
instruction
reverse a list `array`
0
381
output
list(reversed(array))
1
381
instruction
get first element of each tuple in list `A`
0
382
output
[tup[0] for tup in A]
1
382
instruction
replace character 'a' with character 'e' and character 's' with character '3' in file `contents`
0
383
output
newcontents = contents.replace('a', 'e').replace('s', '3')
1
383
instruction
serialise SqlAlchemy RowProxy object `row` to a json object
0
384
output
json.dumps([dict(list(row.items())) for row in rs])
1
384
instruction
get file '~/foo.ini'
0
385
output
config_file = os.path.expanduser('~/foo.ini')
1
385
instruction
get multiple parameters with same name from a url in pylons
0
386
output
request.params.getall('c')
1
386
instruction
Convert array `x` into a correlation matrix
0
387
output
np.corrcoef(x)
1
387
instruction
Find the greatest number in set `(1, 2, 3)`
0
388
output
print(max(1, 2, 3))
1
388
instruction
Retrieve parameter 'var_name' from a GET request.
0
389
output
self.request.get('var_name')
1
389
instruction
Add 100 to each element of column "x" in dataframe `a`
0
390
output
a['x'].apply(lambda x, y: x + y, args=(100,))
1
390
instruction
Django get first 10 records of model `User` ordered by criteria 'age' of model 'pet'
0
391
output
User.objects.order_by('-pet__age')[:10]
1
391
instruction
delay for "5" seconds
0
392
output
time.sleep(5)
1
392
instruction
make a 60 seconds time delay
0
393
output
time.sleep(60)
1
393
instruction
make a 0.1 seconds time delay
0
394
output
sleep(0.1)
1
394
instruction
make a 60 seconds time delay
0
395
output
time.sleep(60)
1
395
instruction
make a 0.1 seconds time delay
0
396
output
time.sleep(0.1)
1
396
instruction
From a list of strings `my_list`, remove the values that contains numbers.
0
397
output
[x for x in my_list if not any(c.isdigit() for c in x)]
1
397
instruction
get the middle two characters of a string 'state' in a pandas dataframe `df`
0
398
output
df['state'].apply(lambda x: x[len(x) / 2 - 1:len(x) / 2 + 1])
1
398
instruction
draw a grid line on every tick of plot `plt`
0
399
output
plt.grid(True)
1
399