message_type
stringclasses
2 values
message
stringlengths
2
232
message_id
int64
0
1
conversation_id
int64
0
2.38k
instruction
Draw node labels `labels` on networkx graph `G ` at position `pos`
0
250
output
networkx.draw_networkx_labels(G, pos, labels)
1
250
instruction
make a row-by-row copy `y` of array `x`
0
251
output
y = [row[:] for row in x]
1
251
instruction
Create 2D numpy array from the data provided in 'somefile.csv' with each row in the file having same number of values
0
252
output
X = numpy.loadtxt('somefile.csv', delimiter=',')
1
252
instruction
get a list of items from the list `some_list` that contain string 'abc'
0
253
output
matching = [s for s in some_list if 'abc' in s]
1
253
instruction
export a pandas data frame `df` to a file `mydf.tsv` and retain the indices
0
254
output
df.to_csv('mydf.tsv', sep='\t')
1
254
instruction
null
0
255
output
random.sample(list(range(100)), 10)
1
255
instruction
split a string `s` on last delimiter
0
256
output
s.rsplit(',', 1)
1
256
instruction
Check if all elements in list `lst` are tupples of long and int
0
257
output
all(isinstance(x, int) for x in lst)
1
257
instruction
check if all elements in a list 'lst' are the same type 'int'
0
258
output
all(isinstance(x, int) for x in lst)
1
258
instruction
strip a string `line` of all carriage returns and newlines
0
259
output
line.strip()
1
259
instruction
scroll to the bottom of a web page using selenium webdriver
0
260
output
driver.execute_script('window.scrollTo(0, Y)')
1
260
instruction
scroll a to the bottom of a web page using selenium webdriver
0
261
output
driver.execute_script('window.scrollTo(0, document.body.scrollHeight);')
1
261
instruction
convert Date object `dateobject` into a DateTime object
0
262
output
datetime.datetime.combine(dateobject, datetime.time())
1
262
instruction
check if any item from list `b` is in list `a`
0
263
output
print(any(x in a for x in b))
1
263
instruction
save a numpy array `image_array` as an image 'outfile.jpg'
0
264
output
scipy.misc.imsave('outfile.jpg', image_array)
1
264
instruction
Remove anything in parenthesis from string `item` with a regex
0
265
output
item = re.sub(' ?\\([^)]+\\)', '', item)
1
265
instruction
Remove word characters in parenthesis from string `item` with a regex
0
266
output
item = re.sub(' ?\\(\\w+\\)', '', item)
1
266
instruction
Remove all data inside parenthesis in string `item`
0
267
output
item = re.sub(' \\(\\w+\\)', '', item)
1
267
instruction
check if any elements in one list `list1` are in another list `list2`
0
268
output
len(set(list1).intersection(list2)) > 0
1
268
instruction
convert hex string `s` to decimal
0
269
output
i = int(s, 16)
1
269
instruction
convert hex string "0xff" to decimal
0
270
output
int('0xff', 16)
1
270
instruction
convert hex string "FFFF" to decimal
0
271
output
int('FFFF', 16)
1
271
instruction
convert hex string '0xdeadbeef' to decimal
0
272
output
ast.literal_eval('0xdeadbeef')
1
272
instruction
convert hex string 'deadbeef' to decimal
0
273
output
int('deadbeef', 16)
1
273
instruction
take screenshot 'screen.png' on mac os x
0
274
output
os.system('screencapture screen.png')
1
274
instruction
Set a window size to `1400, 1000` using selenium webdriver
0
275
output
driver.set_window_size(1400, 1000)
1
275
instruction
replace non-ascii chars from a unicode string u'm\xfasica'
0
276
output
unicodedata.normalize('NFKD', 'm\xfasica').encode('ascii', 'ignore')
1
276
instruction
concatenate dataframe `df1` with `df2` whilst removing duplicates
0
277
output
pandas.concat([df1, df2]).drop_duplicates().reset_index(drop=True)
1
277
instruction
Construct an array with data type float32 `a` from data in binary file 'filename'
0
278
output
a = numpy.fromfile('filename', dtype=numpy.float32)
1
278
instruction
execute a mv command `mv /home/somedir/subdir/* somedir/` in subprocess
0
279
output
subprocess.call('mv /home/somedir/subdir/* somedir/', shell=True)
1
279
instruction
null
0
280
output
subprocess.call('mv /home/somedir/subdir/* somedir/', shell=True)
1
280
instruction
print a character that has unicode value `\u25b2`
0
281
output
print('\u25b2'.encode('utf-8'))
1
281
instruction
compare contents at filehandles `file1` and `file2` using difflib
0
282
output
difflib.SequenceMatcher(None, file1.read(), file2.read())
1
282
instruction
Create a dictionary from string `e` separated by `-` and `,`
0
283
output
dict((k, int(v)) for k, v in (e.split(' - ') for e in s.split(',')))
1
283
instruction
check if all elements in a tuple `(1, 6)` are in another `(1, 2, 3, 4, 5)`
0
284
output
all(i in (1, 2, 3, 4, 5) for i in (1, 6))
1
284
instruction
extract unique dates from time series 'Date' in dataframe `df`
0
285
output
df['Date'].map(lambda t: t.date()).unique()
1
285
instruction
right align string `mystring` with a width of 7
0
286
output
"""{:>7s}""".format(mystring)
1
286
instruction
read an excel file 'ComponentReport-DJI.xls'
0
287
output
open('ComponentReport-DJI.xls', 'rb').read(200)
1
287
instruction
sort dataframe `df` based on column 'b' in ascending and column 'c' in descending
0
288
output
df.sort_values(['b', 'c'], ascending=[True, False], inplace=True)
1
288
instruction
sort dataframe `df` based on column 'a' in ascending and column 'b' in descending
0
289
output
df.sort_values(['a', 'b'], ascending=[True, False])
1
289
instruction
sort a pandas data frame with column `a` in ascending and `b` in descending order
0
290
output
df1.sort(['a', 'b'], ascending=[True, False], inplace=True)
1
290
instruction
sort a pandas data frame by column `a` in ascending, and by column `b` in descending order
0
291
output
df.sort(['a', 'b'], ascending=[True, False])
1
291
instruction
django redirect to view 'Home.views.index'
0
292
output
redirect('Home.views.index')
1
292
instruction
remove all values within one list `[2, 3, 7]` from another list `a`
0
293
output
[x for x in a if x not in [2, 3, 7]]
1
293
instruction
remove the punctuation '!', '.', ':' from a string `asking`
0
294
output
out = ''.join(c for c in asking if c not in ('!', '.', ':'))
1
294
instruction
BeautifulSoup get value associated with attribute 'content' where attribute 'name' is equal to 'City' in tag 'meta' in HTML parsed string `soup`
0
295
output
soup.find('meta', {'name': 'City'})['content']
1
295
instruction
unquote a urlencoded unicode string '%0a'
0
296
output
urllib.parse.unquote('%0a')
1
296
instruction
decode url `url` from UTF-16 code to UTF-8 code
0
297
output
urllib.parse.unquote(url).decode('utf8')
1
297
instruction
empty a list `lst`
0
298
output
del lst[:]
1
298
instruction
empty a list `lst`
0
299
output
del lst1[:]
1
299