message_type
stringclasses
2 values
message
stringlengths
2
232
message_id
int64
0
1
conversation_id
int64
0
2.38k
instruction
get digits in string `my_string`
0
700
output
"""""".join(c for c in my_string if c.isdigit())
1
700
instruction
split string `str1` on one or more spaces with a regular expression
0
701
output
re.split(' +', str1)
1
701
instruction
null
0
702
output
re.findall('\\S+', str1)
1
702
instruction
Evaluate a nested dictionary `myobject.id.number` to get `number` if `myobject` is present with getattr
0
703
output
getattr(getattr(myobject, 'id', None), 'number', None)
1
703
instruction
convert generator object to a dictionary
0
704
output
{i: (i * 2) for i in range(10)}
1
704
instruction
convert generator object to a dictionary
0
705
output
dict((i, i * 2) for i in range(10))
1
705
instruction
Matplotlib clear the current axes.
0
706
output
plt.cla()
1
706
instruction
split string `s` into float values and write sum to `total`
0
707
output
total = sum(float(item) for item in s.split(','))
1
707
instruction
Convert ascii value 'P' to binary
0
708
output
bin(ord('P'))
1
708
instruction
print a string after a specific substring ', ' in string `my_string `
0
709
output
print(my_string.split(', ', 1)[1])
1
709
instruction
get value of key `post code` associated with first index of key `places` of dictionary `data`
0
710
output
print(data['places'][0]['post code'])
1
710
instruction
remove colon character surrounded by vowels letters in string `word`
0
711
output
word = re.sub('([aeiou]):(([aeiou][^aeiou]*){3})$', '\\1\\2', word)
1
711
instruction
extract data field 'bar' from json object
0
712
output
json.loads('{"foo": 42, "bar": "baz"}')['bar']
1
712
instruction
Convert JSON array `array` to Python object
0
713
output
data = json.loads(array)
1
713
instruction
Convert JSON array `array` to Python object
0
714
output
data = json.loads(array)
1
714
instruction
pars a string 'http://example.org/#comments' to extract hashtags into an array
0
715
output
re.findall('#(\\w+)', 'http://example.org/#comments')
1
715
instruction
do a boolean check if a string `lestring` contains any of the items in list `lelist`
0
716
output
any(e in lestring for e in lelist)
1
716
instruction
null
0
717
output
df.plot(x='col_name_1', y='col_name_2', style='o')
1
717
instruction
Parsing HTML string `html` using BeautifulSoup
0
718
output
parsed_html = BeautifulSoup(html) print(parsed_html.body.find('div', attrs={'class': 'container', }).text)
1
718
instruction
Parsing webpage 'http://www.google.com/' using BeautifulSoup
0
719
output
page = urllib.request.urlopen('http://www.google.com/') soup = BeautifulSoup(page)
1
719
instruction
change figure size to 3 by 4 in matplotlib
0
720
output
plt.figure(figsize=(3, 4))
1
720
instruction
Strip punctuation from string `s`
0
721
output
s.translate(None, string.punctuation)
1
721
instruction
django urlsafe base64 decode string `uenc` with decryption
0
722
output
base64.urlsafe_b64decode(uenc.encode('ascii'))
1
722
instruction
get the number of all keys in the nested dictionary `dict_list`
0
723
output
len(dict_test) + sum(len(v) for v in dict_test.values())
1
723
instruction
return the conversion of decimal `d` to hex without the '0x' prefix
0
724
output
hex(d).split('x')[1]
1
724
instruction
create a list containing digits of number 123 as its elements
0
725
output
list(str(123))
1
725
instruction
converting integer `num` to list
0
726
output
[int(x) for x in str(num)]
1
726
instruction
select a first form with no name in mechanize
0
727
output
br.select_form(nr=0)
1
727
instruction
Open file 'sample.json' in read mode with encoding of 'utf-8-sig'
0
728
output
json.load(codecs.open('sample.json', 'r', 'utf-8-sig'))
1
728
instruction
load json file 'sample.json' with utf-8 bom header
0
729
output
json.loads(open('sample.json').read().decode('utf-8-sig'))
1
729
instruction
setup a smtp mail server to `smtp.gmail.com` with port `587`
0
730
output
server = smtplib.SMTP('smtp.gmail.com', 587)
1
730
instruction
revers correlating bits of integer `n`
0
731
output
int('{:08b}'.format(n)[::-1], 2)
1
731
instruction
add column `d` to index of dataframe `df`
0
732
output
df.set_index(['d'], append=True)
1
732
instruction
Iterating over a dictionary `d` using for loops
0
733
output
for (key, value) in d.items(): pass
1
733
instruction
Iterating over a dictionary `d` using for loops
0
734
output
for (key, value) in list(d.items()): pass
1
734
instruction
Iterating key and items over dictionary `d`
0
735
output
for (letter, number) in list(d.items()): pass
1
735
instruction
Iterating key and items over dictionary `d`
0
736
output
for (k, v) in list(d.items()): pass
1
736
instruction
get keys and items of dictionary `d`
0
737
output
list(d.items())
1
737
instruction
get keys and items of dictionary `d` as a list
0
738
output
list(d.items())
1
738
instruction
Iterating key and items over dictionary `d`
0
739
output
for (k, v) in list(d.items()): pass
1
739
instruction
Iterating key and items over dictionary `d`
0
740
output
for (letter, number) in list(d.items()): pass
1
740
instruction
Iterating key and items over dictionary `d`
0
741
output
for (letter, number) in list(d.items()): pass
1
741
instruction
query all data from table `Task` where the value of column `time_spent` is bigger than 3 hours
0
742
output
session.query(Task).filter(Task.time_spent > timedelta(hours=3)).all()
1
742
instruction
compile Visual Studio project `project.sln` from the command line through python
0
743
output
os.system('msbuild project.sln /p:Configuration=Debug')
1
743
instruction
get max key in dictionary `MyCount`
0
744
output
max(list(MyCount.keys()), key=int)
1
744
instruction
execute command 'source .bashrc; shopt -s expand_aliases; nuke -x scriptPath' from python script
0
745
output
os.system('source .bashrc; shopt -s expand_aliases; nuke -x scriptPath')
1
745
instruction
get a name of function `my_function` as a string
0
746
output
my_function.__name__
1
746
instruction
null
0
747
output
my_function.__name__
1
747
instruction
check if all values in the columns of a numpy matrix `a` are same
0
748
output
np.all(a == a[(0), :], axis=0)
1
748
instruction
sort list `a` in ascending order based on the addition of the second and third elements of each tuple in it
0
749
output
sorted(a, key=lambda x: (sum(x[1:3]), x[0]))
1
749