message_type
stringclasses
2 values
message
stringlengths
2
232
message_id
int64
0
1
conversation_id
int64
0
2.38k
instruction
convert `a` to string
0
500
output
str(a)
1
500
instruction
sort list of lists `L` by the second item in each list
0
501
output
L.sort(key=operator.itemgetter(1))
1
501
instruction
Print variable `count` and variable `conv` with space string ' ' in between
0
502
output
print(str(count) + ' ' + str(conv))
1
502
instruction
change NaN values in dataframe `df` using preceding values in the frame
0
503
output
df.fillna(method='ffill', inplace=True)
1
503
instruction
change the state of the Tkinter `Text` widget to read only i.e. `disabled`
0
504
output
text.config(state=DISABLED)
1
504
instruction
python sum of ascii values of all characters in a string `string`
0
505
output
sum(map(ord, string))
1
505
instruction
apply itertools.product to elements of a list of lists `arrays`
0
506
output
list(itertools.product(*arrays))
1
506
instruction
print number `value` as thousands separators
0
507
output
'{:,}'.format(value)
1
507
instruction
print number 1255000 as thousands separators
0
508
output
locale.setlocale(locale.LC_ALL, 'en_US') locale.format('%d', 1255000, grouping=True)
1
508
instruction
get rows of dataframe `df` where column `Col1` has values `['men', 'rocks', 'mountains']`
0
509
output
df[df.Col1.isin(['men', 'rocks', 'mountains'])]
1
509
instruction
get the value at index 1 for each tuple in the list of tuples `L`
0
510
output
[x[1] for x in L]
1
510
instruction
split unicode string "раз два три" into words
0
511
output
'\u0440\u0430\u0437 \u0434\u0432\u0430 \u0442\u0440\u0438'.split()
1
511
instruction
sort query set by number of characters in a field `length` in django model `MyModel`
0
512
output
MyModel.objects.extra(select={'length': 'Length(name)'}).order_by('length')
1
512
instruction
get a dictionary in list `dicts` which key 'ratio' is closer to a global value 1.77672955975
0
513
output
min(dicts, key=lambda x: (abs(1.77672955975 - x['ratio']), -x['pixels']))
1
513
instruction
get the non-masked values of array `m`
0
514
output
m[~m.mask]
1
514
instruction
Find all words containing letters between A and Z in string `formula`
0
515
output
re.findall('\\b[A-Z]', formula)
1
515
instruction
create a list `matrix` containing 5 lists, each of 5 items all set to 0
0
516
output
matrix = [([0] * 5) for i in range(5)]
1
516
instruction
creating a numpy array of 3d coordinates from three 1d arrays `x_p`, `y_p` and `z_p`
0
517
output
np.vstack(np.meshgrid(x_p, y_p, z_p)).reshape(3, -1).T
1
517
instruction
find the minimum value in a numpy array `arr` excluding 0
0
518
output
arr[arr != 0].min()
1
518
instruction
get the text of multiple elements found by xpath "//*[@type='submit']/@value"
0
519
output
browser.find_elements_by_xpath("//*[@type='submit']/@value").text
1
519
instruction
find all the values in attribute `value` for the tags whose `type` attribute is `submit` in selenium
0
520
output
browser.find_elements_by_xpath("//*[@type='submit']").get_attribute('value')
1
520
instruction
parse a YAML file "example.yaml"
0
521
output
with open('example.yaml', 'r') as stream: try: print((yaml.load(stream))) except yaml.YAMLError as exc: print(exc)
1
521
instruction
parse a YAML file "example.yaml"
0
522
output
with open('example.yaml') as stream: try: print((yaml.load(stream))) except yaml.YAMLError as exc: print(exc)
1
522
instruction
Sort the values of the dataframe `df` and align the columns accordingly based on the obtained indices after np.argsort.
0
523
output
pd.DataFrame(df.columns[np.argsort(df.values)], df.index, np.unique(df.values))
1
523
instruction
Getting today's date in YYYY-MM-DD
0
524
output
datetime.datetime.today().strftime('%Y-%m-%d')
1
524
instruction
urlencode a querystring 'string_of_characters_like_these:$#@=?%^Q^$' in python 2
0
525
output
urllib.parse.quote_plus('string_of_characters_like_these:$#@=?%^Q^$')
1
525
instruction
sort a dictionary `d` by length of its values and print as string
0
526
output
print(' '.join(sorted(d, key=lambda k: len(d[k]), reverse=True)))
1
526
instruction
convert tuple elements in list `[(1,2),(3,4),(5,6),]` into lists
0
527
output
map(list, zip(*[(1, 2), (3, 4), (5, 6)]))
1
527
instruction
null
0
528
output
map(list, zip(*[(1, 2), (3, 4), (5, 6)]))
1
528
instruction
null
0
529
output
zip(*[(1, 2), (3, 4), (5, 6)])
1
529
instruction
create a list of tuples which contains number 9 and the number before it, for each occurrence of 9 in the list 'myList'
0
530
output
[(x, y) for x, y in zip(myList, myList[1:]) if y == 9]
1
530
instruction
navigate to webpage given by url `http://www.python.org` using Selenium
0
531
output
driver.get('http://www.google.com.br')
1
531
instruction
reverse a UTF-8 string 'a'
0
532
output
b = a.decode('utf8')[::-1].encode('utf8')
1
532
instruction
extract date from a string 'monkey 2010-07-32 love banana'
0
533
output
dparser.parse('monkey 2010-07-32 love banana', fuzzy=True)
1
533
instruction
extract date from a string 'monkey 20/01/1980 love banana'
0
534
output
dparser.parse('monkey 20/01/1980 love banana', fuzzy=True)
1
534
instruction
extract date from a string `monkey 10/01/1980 love banana`
0
535
output
dparser.parse('monkey 10/01/1980 love banana', fuzzy=True)
1
535
instruction
Convert a list `['A:1', 'B:2', 'C:3', 'D:4']` to dictionary
0
536
output
dict(map(lambda s: s.split(':'), ['A:1', 'B:2', 'C:3', 'D:4']))
1
536
instruction
check if string `the_string` contains any upper or lower-case ASCII letters
0
537
output
re.search('[a-zA-Z]', the_string)
1
537
instruction
convert a pandas `df1` groupby object to dataframe
0
538
output
DataFrame({'count': df1.groupby(['Name', 'City']).size()}).reset_index()
1
538
instruction
remove all non-numeric characters from string `sdkjh987978asd098as0980a98sd `
0
539
output
re.sub('[^0-9]', '', 'sdkjh987978asd098as0980a98sd')
1
539
instruction
get items from list `a` that don't appear in list `b`
0
540
output
[y for y in a if y not in b]
1
540
instruction
extract the first four rows of the column `ID` from a pandas dataframe `df`
0
541
output
df.groupby('ID').head(4)
1
541
instruction
Unzip a list of tuples `l` into a list of lists
0
542
output
zip(*l)
1
542
instruction
combine two lists `[1, 2, 3, 4]` and `['a', 'b', 'c', 'd']` into a dictionary
0
543
output
dict(zip([1, 2, 3, 4], ['a', 'b', 'c', 'd']))
1
543
instruction
combine two lists `[1, 2, 3, 4]` and `['a', 'b', 'c', 'd']` into a dictionary
0
544
output
dict(zip([1, 2, 3, 4], ['a', 'b', 'c', 'd']))
1
544
instruction
retrieve the path from a Flask request
0
545
output
request.url
1
545
instruction
replace carriage return in string `somestring` with empty string ''
0
546
output
somestring.replace('\\r', '')
1
546
instruction
serialize dictionary `d` as a JSON formatted string with each key formatted to pattern '%d,%d'
0
547
output
simplejson.dumps(dict([('%d,%d' % k, v) for k, v in list(d.items())]))
1
547
instruction
parse string "Jun 1 2005 1:33PM" into datetime by format "%b %d %Y %I:%M%p"
0
548
output
datetime.strptime('Jun 1 2005 1:33PM', '%b %d %Y %I:%M%p')
1
548
instruction
parse string "Aug 28 1999 12:00AM" into datetime
0
549
output
parser.parse('Aug 28 1999 12:00AM')
1
549