message_type
stringclasses
2 values
message
stringlengths
2
232
message_id
int64
0
1
conversation_id
int64
0
2.38k
instruction
get modification time of file `path`
0
50
output
os.path.getmtime(path)
1
50
instruction
get modified time of file `file`
0
51
output
print(('last modified: %s' % time.ctime(os.path.getmtime(file))))
1
51
instruction
get the creation time of file `file`
0
52
output
print(('created: %s' % time.ctime(os.path.getctime(file))))
1
52
instruction
get the creation time of file `path_to_file`
0
53
output
return os.path.getctime(path_to_file)
1
53
instruction
execute os command ''TASKKILL /F /IM firefox.exe''
0
54
output
os.system('TASKKILL /F /IM firefox.exe')
1
54
instruction
split string `string` on whitespaces using a generator
0
55
output
return (x.group(0) for x in re.finditer("[A-Za-z']+", string))
1
55
instruction
Unpack each value in list `x` to its placeholder '%' in string '%.2f'
0
56
output
""", """.join(['%.2f'] * len(x))
1
56
instruction
match regex pattern '(\\d+(\\.\\d+)?)' with string '3434.35353'
0
57
output
print(re.match('(\\d+(\\.\\d+)?)', '3434.35353').group(1))
1
57
instruction
replace parentheses and all data within it with empty string '' in column 'name' of dataframe `df`
0
58
output
df['name'].str.replace('\\(.*\\)', '')
1
58
instruction
create a list `result` containing elements form list `list_a` if first element of list `list_a` is in list `list_b`
0
59
output
result = [x for x in list_a if x[0] in list_b]
1
59
instruction
generate all possible string permutations of each two elements in list `['hel', 'lo', 'bye']`
0
60
output
print([''.join(a) for a in combinations(['hel', 'lo', 'bye'], 2)])
1
60
instruction
get a list of items form nested list `li` where third element of each item contains string 'ar'
0
61
output
[x for x in li if 'ar' in x[2]]
1
61
instruction
Sort lists in the list `unsorted_list` by the element at index 3 of each list
0
62
output
unsorted_list.sort(key=lambda x: x[3])
1
62
instruction
Log message 'test' on the root logger.
0
63
output
logging.info('test')
1
63
instruction
Return a subplot axes positioned by the grid definition `1,1,1` using matpotlib
0
64
output
fig.add_subplot(1, 1, 1)
1
64
instruction
Sort dictionary `x` by value in ascending order
0
65
output
sorted(list(x.items()), key=operator.itemgetter(1))
1
65
instruction
Sort dictionary `dict1` by value in ascending order
0
66
output
sorted(dict1, key=dict1.get)
1
66
instruction
Sort dictionary `d` by value in descending order
0
67
output
sorted(d, key=d.get, reverse=True)
1
67
instruction
Sort dictionary `d` by value in ascending order
0
68
output
sorted(list(d.items()), key=(lambda x: x[1]))
1
68
instruction
elementwise product of 3d arrays `A` and `B`
0
69
output
np.einsum('ijk,ikl->ijl', A, B)
1
69
instruction
Print a string `card` with string formatting
0
70
output
print('I have: {0.price}'.format(card))
1
70
instruction
Write a comment `# Data for Class A\n` to a file object `f`
0
71
output
f.write('# Data for Class A\n')
1
71
instruction
move the last item in list `a` to the beginning
0
72
output
a = a[-1:] + a[:-1]
1
72
instruction
Parse DateTime object `datetimevariable` using format '%Y-%m-%d'
0
73
output
datetimevariable.strftime('%Y-%m-%d')
1
73
instruction
Normalize line ends in a string 'mixed'
0
74
output
mixed.replace('\r\n', '\n').replace('\r', '\n')
1
74
instruction
find the real user home directory using python
0
75
output
os.path.expanduser('~user')
1
75
instruction
index a list `L` with another list `Idx`
0
76
output
T = [L[i] for i in Idx]
1
76
instruction
get a list of words `words` of a file 'myfile'
0
77
output
words = open('myfile').read().split()
1
77
instruction
Get a list of lists with summing the values of the second element from each list of lists `data`
0
78
output
[[sum([x[1] for x in i])] for i in data]
1
78
instruction
summing the second item in a list of lists of lists
0
79
output
[sum([x[1] for x in i]) for i in data]
1
79
instruction
sort objects in `Articles` in descending order of counts of `likes`
0
80
output
Article.objects.annotate(like_count=Count('likes')).order_by('-like_count')
1
80
instruction
return a DateTime object with the current UTC date
0
81
output
today = datetime.datetime.utcnow().date()
1
81
instruction
create a list containing the multiplication of each elements at the same index of list `lista` and list `listb`
0
82
output
[(a * b) for a, b in zip(lista, listb)]
1
82
instruction
fetch smilies matching regex pattern '(?::|;|=)(?:-)?(?:\\)|\\(|D|P)' in string `s`
0
83
output
re.findall('(?::|;|=)(?:-)?(?:\\)|\\(|D|P)', s)
1
83
instruction
match the pattern '[:;][)(](?![)(])' to the string `str`
0
84
output
re.match('[:;][)(](?![)(])', str)
1
84
instruction
convert a list of objects `list_name` to json string `json_string`
0
85
output
json_string = json.dumps([ob.__dict__ for ob in list_name])
1
85
instruction
create a list `listofzeros` of `n` zeros
0
86
output
listofzeros = [0] * n
1
86
instruction
decode the string 'stringnamehere' to UTF-8
0
87
output
stringnamehere.decode('utf-8', 'ignore')
1
87
instruction
Match regex pattern '((?:A|B|C)D)' on string 'BDE'
0
88
output
re.findall('((?:A|B|C)D)', 'BDE')
1
88
instruction
Create a key `key` if it does not exist in dict `dic` and append element `value` to value.
0
89
output
dic.setdefault(key, []).append(value)
1
89
instruction
Get the value of the minimum element in the second column of array `a`
0
90
output
a[np.argmin(a[:, (1)])]
1
90
instruction
extend dictionary `a` with key/value pairs of dictionary `b`
0
91
output
a.update(b)
1
91
instruction
removing key values pairs with key 'mykey1' from a list of dictionaries `mylist`
0
92
output
[{k: v for k, v in d.items() if k != 'mykey1'} for d in mylist]
1
92
instruction
null
0
93
output
[dict((k, v) for k, v in d.items() if k != 'mykey1') for d in mylist]
1
93
instruction
create 3 by 3 matrix of random numbers
0
94
output
numpy.random.random((3, 3))
1
94
instruction
make new column 'C' in panda dataframe by adding values from other columns 'A' and 'B'
0
95
output
df['C'] = df['A'] + df['B']
1
95
instruction
create a list of values from the dictionary `programs` that have a key with a case insensitive match to 'new york'
0
96
output
[value for key, value in list(programs.items()) if 'new york' in key.lower()]
1
96
instruction
append a path `/path/to/main_folder` in system path
0
97
output
sys.path.append('/path/to/main_folder')
1
97
instruction
get all digits in a string `s` after a '[' character
0
98
output
re.findall('\\d+(?=[^[]+$)', s)
1
98
instruction
python pickle/unpickle a list to/from a file 'afile'
0
99
output
pickle.load(open('afile', 'rb'))
1
99