yam-peleg commited on
Commit
3708947
·
1 Parent(s): 9593129

Upload 3 files

Browse files
.gitattributes CHANGED
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
 
 
53
  *.jpg filter=lfs diff=lfs merge=lfs -text
54
  *.jpeg filter=lfs diff=lfs merge=lfs -text
55
  *.webp filter=lfs diff=lfs merge=lfs -text
56
+ conala-mined.csv filter=lfs diff=lfs merge=lfs -text
conala-mined.csv ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bfa24a54578dc6581fed9d752e81ca152bf76e1985f6f0a47f6186f7c59e54d6
3
+ size 99485944
conala-paired-test.csv ADDED
@@ -0,0 +1,1058 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ message,message_type,message_id,conversation_id
2
+ send a signal `signal.SIGUSR1` to the current process,instruction,0,0
3
+ "```os.kill(os.getpid(), signal.SIGUSR1)```",output,1,0
4
+ decode a hex string '4a4b4c' to UTF-8.,instruction,0,1
5
+ ```bytes.fromhex('4a4b4c').decode('utf-8')```,output,1,1
6
+ check if all elements in list `myList` are identical,instruction,0,2
7
+ ```all(x == myList[0] for x in myList)```,output,1,2
8
+ "format number of spaces between strings `Python`, `:` and `Very Good` to be `20`",instruction,0,3
9
+ "```print('%*s : %*s' % (20, 'Python', 20, 'Very Good'))```",output,1,3
10
+ ,instruction,0,4
11
+ ```d.decode('cp1251').encode('utf8')```,output,1,4
12
+ get rid of None values in dictionary `kwargs`,instruction,0,5
13
+ "```res = {k: v for k, v in list(kwargs.items()) if v is not None}```",output,1,5
14
+ get rid of None values in dictionary `kwargs`,instruction,0,6
15
+ "```res = dict((k, v) for k, v in kwargs.items() if v is not None)```",output,1,6
16
+ capture final output of a chain of system commands `ps -ef | grep something | wc -l`,instruction,0,7
17
+ "```subprocess.check_output('ps -ef | grep something | wc -l', shell=True)```",output,1,7
18
+ "concatenate a list of strings `['a', 'b', 'c']`",instruction,0,8
19
+ "```"""""""""""".join(['a', 'b', 'c'])```",output,1,8
20
+ find intersection data between series `s1` and series `s2`,instruction,0,9
21
+ ```pd.Series(list(set(s1).intersection(set(s2))))```,output,1,9
22
+ sending http headers to `client`,instruction,0,10
23
+ ```client.send('HTTP/1.0 200 OK\r\n')```,output,1,10
24
+ Format a datetime string `when` to extract date only,instruction,0,11
25
+ "```then = datetime.datetime.strptime(when, '%Y-%m-%d').date()```",output,1,11
26
+ split a multi-line string `inputString` into separate strings,instruction,0,12
27
+ ```inputString.split('\n')```,output,1,12
28
+ Split a multi-line string ` a \n b \r\n c ` by new line character `\n`,instruction,0,13
29
+ ```' a \n b \r\n c '.split('\n')```,output,1,13
30
+ "concatenate elements of list `b` by a colon "":""",instruction,0,14
31
+ "```"""""":"""""".join(str(x) for x in b)```",output,1,14
32
+ get the first object from a queryset in django model `Entry`,instruction,0,15
33
+ ```Entry.objects.filter()[:1].get()```,output,1,15
34
+ Calculate sum over all rows of 2D numpy array,instruction,0,16
35
+ ```a.sum(axis=1)```,output,1,16
36
+ enable warnings using action 'always',instruction,0,17
37
+ ```warnings.simplefilter('always')```,output,1,17
38
+ concatenate items of list `l` with a space ' ',instruction,0,18
39
+ "```print(' '.join(map(str, l)))```",output,1,18
40
+ run script 'hello.py' with argument 'htmlfilename.htm' on terminal using python executable,instruction,0,19
41
+ "```subprocess.call(['python.exe', 'hello.py', 'htmlfilename.htm'])```",output,1,19
42
+ ,instruction,0,20
43
+ "```time.strptime('30/03/09 16:31:32.123', '%d/%m/%y %H:%M:%S.%f')```",output,1,20
44
+ convert a string `my_string` with dot and comma into a float number `my_float`,instruction,0,21
45
+ "```my_float = float(my_string.replace(',', ''))```",output,1,21
46
+ "convert a string `123,456.908` with dot and comma into a floating number",instruction,0,22
47
+ "```float('123,456.908'.replace(',', ''))```",output,1,22
48
+ set pythonpath in python script.,instruction,0,23
49
+ ```sys.path.append('/path/to/whatever')```,output,1,23
50
+ "split string 'Words, words, words.' using a regex '(\\W+)'",instruction,0,24
51
+ "```re.split('(\\W+)', 'Words, words, words.')```",output,1,24
52
+ open a file `Output.txt` in append mode,instruction,0,25
53
+ "```file = open('Output.txt', 'a')```",output,1,25
54
+ "download a file ""http://www.example.com/songs/mp3.mp3"" over HTTP and save to ""mp3.mp3""",instruction,0,26
55
+ "```urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')```",output,1,26
56
+ download a file `url` over HTTP and save to `file_name`,instruction,0,27
57
+ "```u = urllib.request.urlopen(url)
58
+ f = open(file_name, 'wb')
59
+ meta = u.info()
60
+ file_size = int(meta.getheaders('Content-Length')[0])
61
+ print(('Downloading: %s Bytes: %s' % (file_name, file_size)))
62
+ file_size_dl = 0
63
+ block_sz = 8192
64
+ while True:
65
+ buffer = u.read(block_sz)
66
+ if (not buffer):
67
+ break
68
+ file_size_dl += len(buffer)
69
+ f.write(buffer)
70
+ status = ('%10d [%3.2f%%]' % (file_size_dl, ((file_size_dl * 100.0) / file_size)))
71
+ status = (status + (chr(8) * (len(status) + 1)))
72
+ print(status, end=' ')
73
+ f.close()```",output,1,27
74
+ download a file 'http://www.example.com/' over HTTP,instruction,0,28
75
+ "```response = urllib.request.urlopen('http://www.example.com/')
76
+ html = response.read()```",output,1,28
77
+ download a file `url` over HTTP,instruction,0,29
78
+ ```r = requests.get(url)```,output,1,29
79
+ "download a file `url` over HTTP and save to ""10MB""",instruction,0,30
80
+ "```response = requests.get(url, stream=True)
81
+ with open('10MB', 'wb') as handle:
82
+ for data in tqdm(response.iter_content()):
83
+ handle.write(data)```",output,1,30
84
+ argparse add argument with flag '--version' and version action of '%(prog)s 2.0' to parser `parser`,instruction,0,31
85
+ "```parser.add_argument('--version', action='version', version='%(prog)s 2.0')```",output,1,31
86
+ remove key 'c' from dictionary `d`,instruction,0,32
87
+ ```{i: d[i] for i in d if i != 'c'}```,output,1,32
88
+ "Create new DataFrame object by merging columns ""key"" of dataframes `split_df` and `csv_df` and rename the columns from dataframes `split_df` and `csv_df` with suffix `_left` and `_right` respectively",instruction,0,33
89
+ "```pd.merge(split_df, csv_df, on=['key'], suffixes=('_left', '_right'))```",output,1,33
90
+ Split a string `s` by space with `4` splits,instruction,0,34
91
+ "```s.split(' ', 4)```",output,1,34
92
+ read keyboard-input,instruction,0,35
93
+ ```input('Enter your input:')```,output,1,35
94
+ enable debug mode on Flask application `app`,instruction,0,36
95
+ ```app.run(debug=True)```,output,1,36
96
+ python save list `mylist` to file object 'save.txt',instruction,0,37
97
+ "```pickle.dump(mylist, open('save.txt', 'wb'))```",output,1,37
98
+ Multiply a matrix `P` with a 3d tensor `T` in scipy,instruction,0,38
99
+ "```scipy.tensordot(P, T, axes=[1, 1]).swapaxes(0, 1)```",output,1,38
100
+ "Create 3d array of zeroes of size `(3,3,3)`",instruction,0,39
101
+ "```numpy.zeros((3, 3, 3))```",output,1,39
102
+ cut off the last word of a sentence `content`,instruction,0,40
103
+ "```"""""" """""".join(content.split(' ')[:-1])```",output,1,40
104
+ convert scalar `x` to array,instruction,0,41
105
+ "```x = np.asarray(x).reshape(1, -1)[(0), :]```",output,1,41
106
+ sum all elements of nested list `L`,instruction,0,42
107
+ "```sum(sum(i) if isinstance(i, list) else i for i in L)```",output,1,42
108
+ convert hex string '470FC614' to a float number,instruction,0,43
109
+ "```struct.unpack('!f', '470FC614'.decode('hex'))[0]```",output,1,43
110
+ Multiple each value by `2` for all keys in a dictionary `my_dict`,instruction,0,44
111
+ "```my_dict.update((x, y * 2) for x, y in list(my_dict.items()))```",output,1,44
112
+ running bash script 'sleep.sh',instruction,0,45
113
+ "```subprocess.call('sleep.sh', shell=True)```",output,1,45
114
+ "Join elements of list `l` with a comma `,`",instruction,0,46
115
+ "```"""""","""""".join(l)```",output,1,46
116
+ make a comma-separated string from a list `myList`,instruction,0,47
117
+ "```myList = ','.join(map(str, myList))```",output,1,47
118
+ reverse the list that contains 1 to 10,instruction,0,48
119
+ ```list(reversed(list(range(10))))```,output,1,48
120
+ "remove substring 'bag,' from a string 'lamp, bag, mirror'",instruction,0,49
121
+ "```print('lamp, bag, mirror'.replace('bag,', ''))```",output,1,49
122
+ "Reverse the order of words, delimited by `.`, in string `s`",instruction,0,50
123
+ "```""""""."""""".join(s.split('.')[::-1])```",output,1,50
124
+ convert epoch time represented as milliseconds `s` to string using format '%Y-%m-%d %H:%M:%S.%f',instruction,0,51
125
+ ```datetime.datetime.fromtimestamp(s).strftime('%Y-%m-%d %H:%M:%S.%f')```,output,1,51
126
+ parse milliseconds epoch time '1236472051807' to format '%Y-%m-%d %H:%M:%S',instruction,0,52
127
+ "```time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(1236472051807 / 1000.0))```",output,1,52
128
+ get the date 7 days before the current date,instruction,0,53
129
+ ```(datetime.datetime.now() - datetime.timedelta(days=7)).date()```,output,1,53
130
+ sum elements at index `column` of each list in list `data`,instruction,0,54
131
+ ```print(sum(row[column] for row in data))```,output,1,54
132
+ sum columns of a list `array`,instruction,0,55
133
+ ```[sum(row[i] for row in array) for i in range(len(array[0]))]```,output,1,55
134
+ encode binary string 'your string' to base64 code,instruction,0,56
135
+ "```base64.b64encode(bytes('your string', 'utf-8'))```",output,1,56
136
+ combine list of dictionaries `dicts` with the same keys in each list to a single dictionary,instruction,0,57
137
+ "```dict((k, [d[k] for d in dicts]) for k in dicts[0])```",output,1,57
138
+ Merge a nested dictionary `dicts` into a flat dictionary by concatenating nested values with the same key `k`,instruction,0,58
139
+ ```{k: [d[k] for d in dicts] for k in dicts[0]}```,output,1,58
140
+ ,instruction,0,59
141
+ ```request.args['myParam']```,output,1,59
142
+ identify duplicate values in list `mylist`,instruction,0,60
143
+ "```[k for k, v in list(Counter(mylist).items()) if v > 1]```",output,1,60
144
+ Insert directory 'apps' into directory `__file__`,instruction,0,61
145
+ "```sys.path.insert(1, os.path.join(os.path.dirname(__file__), 'apps'))```",output,1,61
146
+ modify sys.path for python module `subdir`,instruction,0,62
147
+ "```sys.path.append(os.path.join(os.path.dirname(__file__), 'subdir'))```",output,1,62
148
+ Insert a 'None' value into a SQLite3 table.,instruction,0,63
149
+ "```db.execute(""INSERT INTO present VALUES('test2', ?, 10)"", (None,))```",output,1,63
150
+ flatten list `list_of_menuitems`,instruction,0,64
151
+ ```[image for menuitem in list_of_menuitems for image in menuitem]```,output,1,64
152
+ append elements of a set `b` to a list `a`,instruction,0,65
153
+ ```a.extend(b)```,output,1,65
154
+ ,instruction,0,66
155
+ ```a.extend(list(b))```,output,1,66
156
+ write the data of dataframe `df` into text file `np.txt`,instruction,0,67
157
+ "```np.savetxt('c:\\data\\np.txt', df.values, fmt='%d')```",output,1,67
158
+ write content of DataFrame `df` into text file 'c:\\data\\pandas.txt',instruction,0,68
159
+ "```df.to_csv('c:\\data\\pandas.txt', header=None, index=None, sep=' ', mode='a')```",output,1,68
160
+ Split a string `x` by last occurrence of character `-`,instruction,0,69
161
+ ```print(x.rpartition('-')[0])```,output,1,69
162
+ get the last part of a string before the character '-',instruction,0,70
163
+ "```print(x.rsplit('-', 1)[0])```",output,1,70
164
+ upload file using FTP,instruction,0,71
165
+ "```ftp.storlines('STOR ' + filename, open(filename, 'r'))```",output,1,71
166
+ add one to the hidden web element with id 'XYZ' with selenium python script,instruction,0,72
167
+ "```browser.execute_script(""document.getElementById('XYZ').value+='1'"")```",output,1,72
168
+ "create array containing the maximum value of respective elements of array `[2, 3, 4]` and array `[1, 5, 2]`",instruction,0,73
169
+ "```np.maximum([2, 3, 4], [1, 5, 2])```",output,1,73
170
+ print a list `l` and move first 3 elements to the end of the list,instruction,0,74
171
+ ```print(l[3:] + l[:3])```,output,1,74
172
+ loop over files in directory '.',instruction,0,75
173
+ "```for fn in os.listdir('.'):
174
+ if os.path.isfile(fn):
175
+ pass```",output,1,75
176
+ loop over files in directory `source`,instruction,0,76
177
+ "```for (root, dirs, filenames) in os.walk(source):
178
+ for f in filenames:
179
+ pass```",output,1,76
180
+ create a random list of integers,instruction,0,77
181
+ ```[int(1000 * random.random()) for i in range(10000)]```,output,1,77
182
+ ,instruction,0,78
183
+ ```datetime.datetime.now().strftime('%H:%M:%S.%f')```,output,1,78
184
+ Google App Engine execute GQL query 'SELECT * FROM Schedule WHERE station = $1' with parameter `foo.key()`,instruction,0,79
185
+ "```db.GqlQuery('SELECT * FROM Schedule WHERE station = $1', foo.key())```",output,1,79
186
+ filter rows in pandas starting with alphabet 'f' using regular expression.,instruction,0,80
187
+ ```df.b.str.contains('^f')```,output,1,80
188
+ print a 2 dimensional list `tab` as a table with delimiters,instruction,0,81
189
+ ```print('\n'.join('\t'.join(str(col) for col in row) for row in tab))```,output,1,81
190
+ pandas: delete rows in dataframe `df` based on multiple columns values,instruction,0,82
191
+ "```df.set_index(list('BC')).drop(tuples, errors='ignore').reset_index()```",output,1,82
192
+ format the variables `self.goals` and `self.penalties` using string formatting,instruction,0,83
193
+ "```""""""({:d} goals, ${:d})"""""".format(self.goals, self.penalties)```",output,1,83
194
+ "format string ""({} goals, ${})"" with variables `goals` and `penalties`",instruction,0,84
195
+ "```""""""({} goals, ${})"""""".format(self.goals, self.penalties)```",output,1,84
196
+ "format string ""({0.goals} goals, ${0.penalties})""",instruction,0,85
197
+ "```""""""({0.goals} goals, ${0.penalties})"""""".format(self)```",output,1,85
198
+ convert list of lists `L` to list of integers,instruction,0,86
199
+ ```[int(''.join(str(d) for d in x)) for x in L]```,output,1,86
200
+ combine elements of each list in list `L` into digits of a single integer,instruction,0,87
201
+ ```[''.join(str(d) for d in x) for x in L]```,output,1,87
202
+ convert a list of lists `L` to list of integers,instruction,0,88
203
+ ```L = [int(''.join([str(y) for y in x])) for x in L]```,output,1,88
204
+ write the elements of list `lines` concatenated by special character '\n' to file `myfile`,instruction,0,89
205
+ ```myfile.write('\n'.join(lines))```,output,1,89
206
+ removing an element from a list based on a predicate 'X' or 'N',instruction,0,90
207
+ "```[x for x in ['AAT', 'XAC', 'ANT', 'TTA'] if 'X' not in x and 'N' not in x]```",output,1,90
208
+ Remove duplicate words from a string `text` using regex,instruction,0,91
209
+ "```text = re.sub('\\b(\\w+)( \\1\\b)+', '\\1', text)```",output,1,91
210
+ count non zero values in each column in pandas data frame,instruction,0,92
211
+ ```df.astype(bool).sum(axis=1)```,output,1,92
212
+ search for string that matches regular expression pattern '(?<!Distillr)\\\\AcroTray\\.exe' in string 'C:\\SomeDir\\AcroTray.exe',instruction,0,93
213
+ "```re.search('(?<!Distillr)\\\\AcroTray\\.exe', 'C:\\SomeDir\\AcroTray.exe')```",output,1,93
214
+ split string 'QH QD JC KD JS' into a list on white spaces,instruction,0,94
215
+ "```""""""QH QD JC KD JS"""""".split()```",output,1,94
216
+ search for occurrences of regex pattern '>.*<' in xml string `line`,instruction,0,95
217
+ "```print(re.search('>.*<', line).group(0))```",output,1,95
218
+ erase all the contents of a file `filename`,instruction,0,96
219
+ "```open(filename, 'w').close()```",output,1,96
220
+ convert a string into datetime using the format '%Y-%m-%d %H:%M:%S.%f',instruction,0,97
221
+ "```datetime.datetime.strptime(string_date, '%Y-%m-%d %H:%M:%S.%f')```",output,1,97
222
+ find the index of a list with the first element equal to '332' within the list of lists `thelist`,instruction,0,98
223
+ "```[index for index, item in enumerate(thelist) if item[0] == '332']```",output,1,98
224
+ lower a string `text` and remove non-alphanumeric characters aside from space,instruction,0,99
225
+ "```re.sub('[^\\sa-zA-Z0-9]', '', text).lower().strip()```",output,1,99
226
+ remove all non-alphanumeric characters except space from a string `text` and lower it,instruction,0,100
227
+ "```re.sub('(?!\\s)[\\W_]', '', text).lower().strip()```",output,1,100
228
+ subscript text 'H20' with '2' as subscripted in matplotlib labels for arrays 'x' and 'y'.,instruction,0,101
229
+ "```plt.plot(x, y, label='H\u2082O')```",output,1,101
230
+ subscript text 'H20' with '2' as subscripted in matplotlib labels for arrays 'x' and 'y'.,instruction,0,102
231
+ "```plt.plot(x, y, label='$H_2O$')```",output,1,102
232
+ loop over a list `mylist` if sublists length equals 3,instruction,0,103
233
+ ```[x for x in mylist if len(x) == 3]```,output,1,103
234
+ initialize a list `lst` of 100 objects Object(),instruction,0,104
235
+ ```lst = [Object() for _ in range(100)]```,output,1,104
236
+ create list `lst` containing 100 instances of object `Object`,instruction,0,105
237
+ ```lst = [Object() for i in range(100)]```,output,1,105
238
+ get the content of child tag with`href` attribute whose parent has css `someclass`,instruction,0,106
239
+ ```self.driver.find_element_by_css_selector('.someclass a').get_attribute('href')```,output,1,106
240
+ joining data from dataframe `df1` with data from dataframe `df2` based on matching values of column 'Date_Time' in both dataframes,instruction,0,107
241
+ "```df1.merge(df2, on='Date_Time')```",output,1,107
242
+ use `%s` operator to print variable values `str1` inside a string,instruction,0,108
243
+ "```'first string is: %s, second one is: %s' % (str1, 'geo.tif')```",output,1,108
244
+ ,instruction,0,109
245
+ ```[x.strip() for x in '2.MATCHES $$TEXT$$ STRING'.split('$$TEXT$$')]```,output,1,109
246
+ check if directory `directory ` exists and create it if necessary,instruction,0,110
247
+ "```if (not os.path.exists(directory)):
248
+ os.makedirs(directory)```",output,1,110
249
+ check if a directory `path` exists and create it if necessary,instruction,0,111
250
+ "```try:
251
+ os.makedirs(path)
252
+ except OSError:
253
+ if (not os.path.isdir(path)):
254
+ raise```",output,1,111
255
+ check if a directory `path` exists and create it if necessary,instruction,0,112
256
+ ```distutils.dir_util.mkpath(path)```,output,1,112
257
+ check if a directory `path` exists and create it if necessary,instruction,0,113
258
+ "```try:
259
+ os.makedirs(path)
260
+ except OSError as exception:
261
+ if (exception.errno != errno.EEXIST):
262
+ raise```",output,1,113
263
+ Replace a separate word 'H3' by 'H1' in a string 'text',instruction,0,114
264
+ "```re.sub('\\bH3\\b', 'H1', text)```",output,1,114
265
+ substitute ASCII letters in string 'aas30dsa20' with empty string '',instruction,0,115
266
+ "```re.sub('\\D', '', 'aas30dsa20')```",output,1,115
267
+ get digits only from a string `aas30dsa20` using lambda function,instruction,0,116
268
+ "```"""""""""""".join([x for x in 'aas30dsa20' if x.isdigit()])```",output,1,116
269
+ "access a tag called ""name"" in beautifulsoup `soup`",instruction,0,117
270
+ ```print(soup.find('name').string)```,output,1,117
271
+ get a dictionary `records` of key-value pairs in PyMongo cursor `cursor`,instruction,0,118
272
+ "```records = dict((record['_id'], record) for record in cursor)```",output,1,118
273
+ Create new matrix object by concatenating data from matrix A and matrix B,instruction,0,119
274
+ "```np.concatenate((A, B))```",output,1,119
275
+ concat two matrices `A` and `B` in numpy,instruction,0,120
276
+ "```np.vstack((A, B))```",output,1,120
277
+ Get the characters count in a file `filepath`,instruction,0,121
278
+ ```os.stat(filepath).st_size```,output,1,121
279
+ "count the occurrences of item ""a"" in list `l`",instruction,0,122
280
+ ```l.count('a')```,output,1,122
281
+ count the occurrences of items in list `l`,instruction,0,123
282
+ ```Counter(l)```,output,1,123
283
+ count the occurrences of items in list `l`,instruction,0,124
284
+ "```[[x, l.count(x)] for x in set(l)]```",output,1,124
285
+ count the occurrences of items in list `l`,instruction,0,125
286
+ "```dict(((x, l.count(x)) for x in set(l)))```",output,1,125
287
+ "count the occurrences of item ""b"" in list `l`",instruction,0,126
288
+ ```l.count('b')```,output,1,126
289
+ copy file `srcfile` to directory `dstdir`,instruction,0,127
290
+ "```shutil.copy(srcfile, dstdir)```",output,1,127
291
+ find the key associated with the largest value in dictionary `x` whilst key is non-zero value,instruction,0,128
292
+ "```max(k for k, v in x.items() if v != 0)```",output,1,128
293
+ get the largest key whose not associated with value of 0 in dictionary `x`,instruction,0,129
294
+ "```(k for k, v in x.items() if v != 0)```",output,1,129
295
+ get the largest key in a dictionary `x` with non-zero value,instruction,0,130
296
+ "```max(k for k, v in x.items() if v != 0)```",output,1,130
297
+ Put the curser at beginning of the file,instruction,0,131
298
+ ```file.seek(0)```,output,1,131
299
+ combine values from column 'b' and column 'a' of dataframe `df` into column 'c' of datafram `df`,instruction,0,132
300
+ "```df['c'] = np.where(df['a'].isnull, df['b'], df['a'])```",output,1,132
301
+ remove key 'ele' from dictionary `d`,instruction,0,133
302
+ ```del d['ele']```,output,1,133
303
+ Update datetime field in `MyModel` to be the existing `timestamp` plus 100 years,instruction,0,134
304
+ ```MyModel.objects.update(timestamp=F('timestamp') + timedelta(days=36524.25))```,output,1,134
305
+ merge list `['it']` and list `['was']` and list `['annoying']` into one list,instruction,0,135
306
+ ```['it'] + ['was'] + ['annoying']```,output,1,135
307
+ increment a value with leading zeroes in a number `x`,instruction,0,136
308
+ ```str(int(x) + 1).zfill(len(x))```,output,1,136
309
+ check if a pandas dataframe `df`'s index is sorted,instruction,0,137
310
+ ```all(df.index[:-1] <= df.index[1:])```,output,1,137
311
+ Convert tuple `t` to list,instruction,0,138
312
+ ```list(t)```,output,1,138
313
+ Convert list `t` to tuple,instruction,0,139
314
+ ```tuple(l)```,output,1,139
315
+ Convert tuple `level1` to list,instruction,0,140
316
+ "```level1 = map(list, level1)```",output,1,140
317
+ send the output of pprint object `dataobject` to file `logFile`,instruction,0,141
318
+ "```pprint.pprint(dataobject, logFile)```",output,1,141
319
+ get index of rows in column 'BoolCol',instruction,0,142
320
+ ```df.loc[df['BoolCol']]```,output,1,142
321
+ Create a list containing the indexes of rows where the value of column 'BoolCol' in dataframe `df` are equal to True,instruction,0,143
322
+ ```df.iloc[np.flatnonzero(df['BoolCol'])]```,output,1,143
323
+ get list of indexes of rows where column 'BoolCol' values match True,instruction,0,144
324
+ ```df[df['BoolCol'] == True].index.tolist()```,output,1,144
325
+ get index of rows in dataframe `df` which column 'BoolCol' matches value True,instruction,0,145
326
+ ```df[df['BoolCol']].index.tolist()```,output,1,145
327
+ change working directory to the directory `owd`,instruction,0,146
328
+ ```os.chdir(owd)```,output,1,146
329
+ insert data from a string `testfield` to sqlite db `c`,instruction,0,147
330
+ "```c.execute(""INSERT INTO test VALUES (?, 'bar')"", (testfield,))```",output,1,147
331
+ "decode string ""\\x89\\n"" into a normal string",instruction,0,148
332
+ "```""""""\\x89\\n"""""".decode('string_escape')```",output,1,148
333
+ convert a raw string `raw_string` into a normal string,instruction,0,149
334
+ ```raw_string.decode('string_escape')```,output,1,149
335
+ convert a raw string `raw_byte_string` into a normal string,instruction,0,150
336
+ ```raw_byte_string.decode('unicode_escape')```,output,1,150
337
+ split a string `s` with into all strings of repeated characters,instruction,0,151
338
+ "```[m.group(0) for m in re.finditer('(\\d)\\1*', s)]```",output,1,151
339
+ "scatter a plot with x, y position of `np.random.randn(100)` and face color equal to none",instruction,0,152
340
+ "```plt.scatter(np.random.randn(100), np.random.randn(100), facecolors='none')```",output,1,152
341
+ do a scatter plot with empty circles,instruction,0,153
342
+ "```plt.plot(np.random.randn(100), np.random.randn(100), 'o', mfc='none')```",output,1,153
343
+ remove a div with a id `main-content` using beautifulsoup,instruction,0,154
344
+ "```soup.find('div', id='main-content').decompose()```",output,1,154
345
+ filter rows containing key word `ball` in column `ids`,instruction,0,155
346
+ ```df[df['ids'].str.contains('ball')]```,output,1,155
347
+ convert index at level 0 into a column in dataframe `df`,instruction,0,156
348
+ "```df.reset_index(level=0, inplace=True)```",output,1,156
349
+ Add indexes in a data frame `df` to a column `index1`,instruction,0,157
350
+ ```df['index1'] = df.index```,output,1,157
351
+ convert pandas index in a dataframe to columns,instruction,0,158
352
+ "```df.reset_index(level=['tick', 'obs'])```",output,1,158
353
+ Get reverse of list items from list 'b' using extended slicing,instruction,0,159
354
+ ```[x[::-1] for x in b]```,output,1,159
355
+ join each element in array `a` with element at the same index in array `b` as a tuple,instruction,0,160
356
+ "```np.array([zip(x, y) for x, y in zip(a, b)])```",output,1,160
357
+ zip two 2-d arrays `a` and `b`,instruction,0,161
358
+ "```np.array(zip(a.ravel(), b.ravel()), dtype='i4,i4').reshape(a.shape)```",output,1,161
359
+ convert list `list_of_ints` into a comma separated string,instruction,0,162
360
+ "```"""""","""""".join([str(i) for i in list_of_ints])```",output,1,162
361
+ Send a post request with raw data `DATA` and basic authentication with `username` and `password`,instruction,0,163
362
+ "```requests.post(url, data=DATA, headers=HEADERS_DICT, auth=(username, password))```",output,1,163
363
+ "Find last occurrence of character '}' in string ""abcd}def}""",instruction,0,164
364
+ ```'abcd}def}'.rfind('}')```,output,1,164
365
+ "Iterate ove list `[1, 2, 3]` using list comprehension",instruction,0,165
366
+ "```print([item for item in [1, 2, 3]])```",output,1,165
367
+ extract all the values with keys 'x' and 'y' from a list of dictionaries `d` to list of tuples,instruction,0,166
368
+ "```[(x['x'], x['y']) for x in d]```",output,1,166
369
+ get the filename without the extension from file 'hemanth.txt',instruction,0,167
370
+ ```print(os.path.splitext(os.path.basename('hemanth.txt'))[0])```,output,1,167
371
+ create a dictionary by adding each two adjacent elements in tuple `x` as key/value pair to it,instruction,0,168
372
+ "```dict(x[i:i + 2] for i in range(0, len(x), 2))```",output,1,168
373
+ "create a list containing flattened list `[['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']]`",instruction,0,169
374
+ "```values = sum([['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']], [])```",output,1,169
375
+ select rows in a dataframe `df` column 'closing_price' between two values 99 and 101,instruction,0,170
376
+ ```df = df[(df['closing_price'] >= 99) & (df['closing_price'] <= 101)]```,output,1,170
377
+ replace all occurences of newlines `\n` with `<br>` in dataframe `df`,instruction,0,171
378
+ "```df.replace({'\n': '<br>'}, regex=True)```",output,1,171
379
+ replace all occurrences of a string `\n` by string `<br>` in a pandas data frame `df`,instruction,0,172
380
+ "```df.replace({'\n': '<br>'}, regex=True)```",output,1,172
381
+ create a list containing each two adjacent letters in string `word` as its elements,instruction,0,173
382
+ "```[(x + y) for x, y in zip(word, word[1:])]```",output,1,173
383
+ Get a list of pairs from a string `word` using lambda function,instruction,0,174
384
+ "```list(map(lambda x, y: x + y, word[:-1], word[1:]))```",output,1,174
385
+ extract a url from a string `myString`,instruction,0,175
386
+ "```print(re.findall('(https?://[^\\s]+)', myString))```",output,1,175
387
+ extract a url from a string `myString`,instruction,0,176
388
+ "```print(re.search('(?P<url>https?://[^\\s]+)', myString).group('url'))```",output,1,176
389
+ "remove all special characters, punctuation and spaces from a string `mystring` using regex",instruction,0,177
390
+ "```re.sub('[^A-Za-z0-9]+', '', mystring)```",output,1,177
391
+ create a DatetimeIndex containing 13 periods of the second friday of each month starting from date '2016-01-01',instruction,0,178
392
+ "```pd.date_range('2016-01-01', freq='WOM-2FRI', periods=13)```",output,1,178
393
+ Create multidimensional array `matrix` with 3 rows and 2 columns in python,instruction,0,179
394
+ "```matrix = [[a, b], [c, d], [e, f]]```",output,1,179
395
+ replace spaces with underscore,instruction,0,180
396
+ "```mystring.replace(' ', '_')```",output,1,180
397
+ get an absolute file path of file 'mydir/myfile.txt',instruction,0,181
398
+ ```os.path.abspath('mydir/myfile.txt')```,output,1,181
399
+ split string `my_string` on white spaces,instruction,0,182
400
+ "```"""""" """""".join(my_string.split())```",output,1,182
401
+ get filename without extension from file `filename`,instruction,0,183
402
+ ```os.path.splitext(filename)[0]```,output,1,183
403
+ get a list containing the sum of each element `i` in list `l` plus the previous elements,instruction,0,184
404
+ "```[sum(l[:i]) for i, _ in enumerate(l)]```",output,1,184
405
+ split a string `Docs/src/Scripts/temp` by `/` keeping `/` in the result,instruction,0,185
406
+ "```""""""Docs/src/Scripts/temp"""""".replace('/', '/\x00/').split('\x00')```",output,1,185
407
+ shuffle columns of an numpy array 'r',instruction,0,186
408
+ ```np.random.shuffle(np.transpose(r))```,output,1,186
409
+ copy all values in a column 'B' to a new column 'D' in a pandas data frame 'df',instruction,0,187
410
+ ```df['D'] = df['B']```,output,1,187
411
+ find a value within nested json 'data' where the key inside another key 'B' is unknown.,instruction,0,188
412
+ ```list(data['A']['B'].values())[0]['maindata'][0]['Info']```,output,1,188
413
+ check characters of string `string` are true predication of function `predicate`,instruction,0,189
414
+ ```all(predicate(x) for x in string)```,output,1,189
415
+ determine number of files on a drive with python,instruction,0,190
416
+ ```os.statvfs('/').f_files - os.statvfs('/').f_ffree```,output,1,190
417
+ ,instruction,0,191
418
+ ```cursor.fetchone()[0]```,output,1,191
419
+ convert string `user_input` into a list of integers `user_list`,instruction,0,192
420
+ "```user_list = [int(number) for number in user_input.split(',')]```",output,1,192
421
+ Get a list of integers by splitting a string `user` with comma,instruction,0,193
422
+ "```[int(s) for s in user.split(',')]```",output,1,193
423
+ ,instruction,0,194
424
+ "```sorted(list, key=lambda x: (x[0], -x[1]))```",output,1,194
425
+ "sort a list of objects `ut`, based on a function `cmpfun` in descending order",instruction,0,195
426
+ "```ut.sort(key=cmpfun, reverse=True)```",output,1,195
427
+ reverse list `ut` based on the `count` attribute of each object,instruction,0,196
428
+ "```ut.sort(key=lambda x: x.count, reverse=True)```",output,1,196
429
+ sort a list of objects `ut` in reverse order by their `count` property,instruction,0,197
430
+ "```ut.sort(key=lambda x: x.count, reverse=True)```",output,1,197
431
+ click a href button 'Send' with selenium,instruction,0,198
432
+ ```driver.find_element_by_partial_link_text('Send').click()```,output,1,198
433
+ click a href button having text `Send InMail` with selenium,instruction,0,199
434
+ ```driver.findElement(By.linkText('Send InMail')).click()```,output,1,199
435
+ click a href button with text 'Send InMail' with selenium,instruction,0,200
436
+ ```driver.find_element_by_link_text('Send InMail').click()```,output,1,200
437
+ cast an int `i` to a string and concat to string 'ME',instruction,0,201
438
+ ```'ME' + str(i)```,output,1,201
439
+ ,instruction,0,202
440
+ "```df.sort_values(['System_num', 'Dis'])```",output,1,202
441
+ prepend the line '#test firstline\n' to the contents of file 'infile' and save as the file 'outfile',instruction,0,203
442
+ "```open('outfile', 'w').write('#test firstline\n' + open('infile').read())```",output,1,203
443
+ sort a list `l` by length of value in tuple,instruction,0,204
444
+ "```l.sort(key=lambda t: len(t[1]), reverse=True)```",output,1,204
445
+ split string `s` by words that ends with 'd',instruction,0,205
446
+ "```re.findall('\\b(\\w+)d\\b', s)```",output,1,205
447
+ return `True` if string `foobarrrr` contains regex `ba[rzd]`,instruction,0,206
448
+ "```bool(re.search('ba[rzd]', 'foobarrrr'))```",output,1,206
449
+ Removing duplicates in list `t`,instruction,0,207
450
+ ```list(set(t))```,output,1,207
451
+ Removing duplicates in list `source_list`,instruction,0,208
452
+ ```list(set(source_list))```,output,1,208
453
+ Removing duplicates in list `abracadabra`,instruction,0,209
454
+ ```list(OrderedDict.fromkeys('abracadabra'))```,output,1,209
455
+ Convert array `a` into a list,instruction,0,210
456
+ ```numpy.array(a).reshape(-1).tolist()```,output,1,210
457
+ Convert the first row of numpy matrix `a` to a list,instruction,0,211
458
+ ```numpy.array(a)[0].tolist()```,output,1,211
459
+ "In `soup`, get the content of the sibling of the `td` tag with text content `Address:`",instruction,0,212
460
+ ```print(soup.find(text='Address:').findNext('td').contents[0])```,output,1,212
461
+ convert elements of each tuple in list `l` into a string separated by character `@`,instruction,0,213
462
+ "```"""""" """""".join([('%d@%d' % t) for t in l])```",output,1,213
463
+ convert each tuple in list `l` to a string with '@' separating the tuples' elements,instruction,0,214
464
+ "```"""""" """""".join([('%d@%d' % (t[0], t[1])) for t in l])```",output,1,214
465
+ get the html from the current web page of a Selenium driver,instruction,0,215
466
+ ```driver.execute_script('return document.documentElement.outerHTML;')```,output,1,215
467
+ Get all matches with regex pattern `\\d+[xX]` in list of string `teststr`,instruction,0,216
468
+ "```[i for i in teststr if re.search('\\d+[xX]', i)]```",output,1,216
469
+ "select values from column 'A' for which corresponding values in column 'B' will be greater than 50, and in column 'C' - equal 900 in dataframe `df`",instruction,0,217
470
+ ```df['A'][(df['B'] > 50) & (df['C'] == 900)]```,output,1,217
471
+ Sort dictionary `o` in ascending order based on its keys and items,instruction,0,218
472
+ ```sorted(o.items())```,output,1,218
473
+ get sorted list of keys of dict `d`,instruction,0,219
474
+ ```sorted(d)```,output,1,219
475
+ ,instruction,0,220
476
+ ```sorted(d.items())```,output,1,220
477
+ "convert string ""1"" into integer",instruction,0,221
478
+ ```int('1')```,output,1,221
479
+ function to convert strings into integers,instruction,0,222
480
+ ```int()```,output,1,222
481
+ convert items in `T1` to integers,instruction,0,223
482
+ "```T2 = [map(int, x) for x in T1]```",output,1,223
483
+ call a shell script `./test.sh` using subprocess,instruction,0,224
484
+ ```subprocess.call(['./test.sh'])```,output,1,224
485
+ call a shell script `notepad` using subprocess,instruction,0,225
486
+ ```subprocess.call(['notepad'])```,output,1,225
487
+ combine lists `l1` and `l2` by alternating their elements,instruction,0,226
488
+ "```[val for pair in zip(l1, l2) for val in pair]```",output,1,226
489
+ encode string 'data to be encoded',instruction,0,227
490
+ ```encoded = base64.b64encode('data to be encoded')```,output,1,227
491
+ encode a string `data to be encoded` to `ascii` encoding,instruction,0,228
492
+ ```encoded = 'data to be encoded'.encode('ascii')```,output,1,228
493
+ parse tab-delimited CSV file 'text.txt' into a list,instruction,0,229
494
+ "```lol = list(csv.reader(open('text.txt', 'rb'), delimiter='\t'))```",output,1,229
495
+ Get attribute `my_str` of object `my_object`,instruction,0,230
496
+ "```getattr(my_object, my_str)```",output,1,230
497
+ group a list of dicts `LD` into one dict by key,instruction,0,231
498
+ "```print(dict(zip(LD[0], zip(*[list(d.values()) for d in LD]))))```",output,1,231
499
+ ,instruction,0,232
500
+ ```sum([pair[0] for pair in list_of_pairs])```,output,1,232
501
+ "convert unicode string u""{'code1':1,'code2':1}"" into dictionary",instruction,0,233
502
+ "```d = ast.literal_eval(""{'code1':1,'code2':1}"")```",output,1,233
503
+ find all words in a string `mystring` that start with the `$` sign,instruction,0,234
504
+ ```[word for word in mystring.split() if word.startswith('$')]```,output,1,234
505
+ remove any url within string `text`,instruction,0,235
506
+ "```text = re.sub('^https?:\\/\\/.*[\\r\\n]*', '', text, flags=re.MULTILINE)```",output,1,235
507
+ "replace all elements in array `A` that are not present in array `[1, 3, 4]` with zeros",instruction,0,236
508
+ "```np.where(np.in1d(A, [1, 3, 4]).reshape(A.shape), A, 0)```",output,1,236
509
+ calculate mean across dimension in a 2d array `a`,instruction,0,237
510
+ "```np.mean(a, axis=1)```",output,1,237
511
+ running r script '/pathto/MyrScript.r' from python,instruction,0,238
512
+ "```subprocess.call(['/usr/bin/Rscript', '--vanilla', '/pathto/MyrScript.r'])```",output,1,238
513
+ run r script '/usr/bin/Rscript --vanilla /pathto/MyrScript.r',instruction,0,239
514
+ "```subprocess.call('/usr/bin/Rscript --vanilla /pathto/MyrScript.r', shell=True)```",output,1,239
515
+ add a header to a csv file,instruction,0,240
516
+ ```writer.writeheader()```,output,1,240
517
+ replacing nan in the dataframe `df` with row average,instruction,0,241
518
+ "```df.fillna(df.mean(axis=1), axis=1)```",output,1,241
519
+ Convert unix timestamp '1347517370' to formatted string '%Y-%m-%d %H:%M:%S',instruction,0,242
520
+ "```time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370))```",output,1,242
521
+ Call a base class's class method `do` from derived class `Derived`,instruction,0,243
522
+ "```super(Derived, cls).do(a)```",output,1,243
523
+ "selecting rows in Numpy ndarray 'a', where the value in the first column is 0 and value in the second column is 1",instruction,0,244
524
+ "```a[np.where((a[:, (0)] == 0) * (a[:, (1)] == 1))]```",output,1,244
525
+ separate words delimited by one or more spaces into a list,instruction,0,245
526
+ "```re.split(' +', 'hello world sample text')```",output,1,245
527
+ length of longest element in list `words`,instruction,0,246
528
+ "```len(max(words, key=len))```",output,1,246
529
+ get the value associated with unicode key 'from_user' of first dictionary in list `result`,instruction,0,247
530
+ ```result[0]['from_user']```,output,1,247
531
+ Retrieve each line from a file 'File.txt' as a list,instruction,0,248
532
+ ```[line.split() for line in open('File.txt')]```,output,1,248
533
+ swap keys with values in a dictionary `a`,instruction,0,249
534
+ "```res = dict((v, k) for k, v in a.items())```",output,1,249
535
+ Open a file `path/to/FILE_NAME.ext` in write mode,instruction,0,250
536
+ "```new_file = open('path/to/FILE_NAME.ext', 'w')```",output,1,250
537
+ ,instruction,0,251
538
+ "```df.groupby(['col1', 'col2'])['col3'].nunique().reset_index()```",output,1,251
539
+ Check if any key in the dictionary `dict1` starts with the string `EMP$$`,instruction,0,252
540
+ ```any(key.startswith('EMP$$') for key in dict1)```,output,1,252
541
+ create list of values from dictionary `dict1` that have a key that starts with 'EMP$$',instruction,0,253
542
+ "```[value for key, value in list(dict1.items()) if key.startswith('EMP$$')]```",output,1,253
543
+ convert a pandas series `sf` into a pandas dataframe `df` with columns `email` and `list`,instruction,0,254
544
+ "```pd.DataFrame({'email': sf.index, 'list': sf.values})```",output,1,254
545
+ print elements of list `list` seperated by tabs `\t`,instruction,0,255
546
+ "```print('\t'.join(map(str, list)))```",output,1,255
547
+ print unicode string '\xd0\xbf\xd1\x80\xd0\xb8' with utf-8,instruction,0,256
548
+ ```print('\xd0\xbf\xd1\x80\xd0\xb8'.encode('raw_unicode_escape'))```,output,1,256
549
+ Encode a latin character in string `Sopet\xc3\xb3n` properly,instruction,0,257
550
+ ```'Sopet\xc3\xb3n'.encode('latin-1').decode('utf-8')```,output,1,257
551
+ "resized image `image` to width, height of `(x, y)` with filter of `ANTIALIAS`",instruction,0,258
552
+ "```image = image.resize((x, y), Image.ANTIALIAS)```",output,1,258
553
+ "regex, find ""n""s only in the middle of string `s`",instruction,0,259
554
+ "```re.findall('n(?<=[^n]n)n+(?=[^n])(?i)', s)```",output,1,259
555
+ display the float `1/3*100` as a percentage,instruction,0,260
556
+ ```print('{0:.0f}%'.format(1.0 / 3 * 100))```,output,1,260
557
+ sort a list of dictionary `mylist` by the key `title`,instruction,0,261
558
+ ```mylist.sort(key=lambda x: x['title'])```,output,1,261
559
+ sort a list `l` of dicts by dict value 'title',instruction,0,262
560
+ ```l.sort(key=lambda x: x['title'])```,output,1,262
561
+ "sort a list of dictionaries by the value of keys 'title', 'title_url', 'id' in ascending order.",instruction,0,263
562
+ "```l.sort(key=lambda x: (x['title'], x['title_url'], x['id']))```",output,1,263
563
+ find 10 largest differences between each respective elements of list `l1` and list `l2`,instruction,0,264
564
+ "```heapq.nlargest(10, range(len(l1)), key=lambda i: abs(l1[i] - l2[i]))```",output,1,264
565
+ BeautifulSoup find all 'span' elements in HTML string `soup` with class of 'starGryB sp',instruction,0,265
566
+ "```soup.find_all('span', {'class': 'starGryB sp'})```",output,1,265
567
+ write records in dataframe `df` to table 'test' in schema 'a_schema',instruction,0,266
568
+ "```df.to_sql('test', engine, schema='a_schema')```",output,1,266
569
+ Extract brackets from string `s`,instruction,0,267
570
+ "```brackets = re.sub('[^(){}[\\]]', '', s)```",output,1,267
571
+ remove duplicate elements from list 'L',instruction,0,268
572
+ "```list(dict((x[0], x) for x in L).values())```",output,1,268
573
+ read a file `file` without newlines,instruction,0,269
574
+ ```[line.rstrip('\n') for line in file]```,output,1,269
575
+ get the position of item 1 in `testlist`,instruction,0,270
576
+ "```[i for (i, x) in enumerate(testlist) if (x == 1)]```",output,1,270
577
+ get the position of item 1 in `testlist`,instruction,0,271
578
+ "```[i for (i, x) in enumerate(testlist) if (x == 1)]```",output,1,271
579
+ get the position of item 1 in `testlist`,instruction,0,272
580
+ "```for i in [i for (i, x) in enumerate(testlist) if (x == 1)]:
581
+ pass```",output,1,272
582
+ get the position of item 1 in `testlist`,instruction,0,273
583
+ "```for i in (i for (i, x) in enumerate(testlist) if (x == 1)):
584
+ pass```",output,1,273
585
+ get the position of item 1 in `testlist`,instruction,0,274
586
+ "```gen = (i for (i, x) in enumerate(testlist) if (x == 1))
587
+ for i in gen:
588
+ pass```",output,1,274
589
+ get the position of item `element` in list `testlist`,instruction,0,275
590
+ ```print(testlist.index(element))```,output,1,275
591
+ get the position of item `element` in list `testlist`,instruction,0,276
592
+ "```try:
593
+ print(testlist.index(element))
594
+ except ValueError:
595
+ pass```",output,1,276
596
+ find the first element of the tuple with the maximum second element in a list of tuples `lis`,instruction,0,277
597
+ "```max(lis, key=lambda item: item[1])[0]```",output,1,277
598
+ get the item at index 0 from the tuple that has maximum value at index 1 in list `lis`,instruction,0,278
599
+ "```max(lis, key=itemgetter(1))[0]```",output,1,278
600
+ Make a delay of 1 second,instruction,0,279
601
+ ```time.sleep(1)```,output,1,279
602
+ convert list of tuples `L` to a string,instruction,0,280
603
+ "```"""""", """""".join('(' + ', '.join(i) + ')' for i in L)```",output,1,280
604
+ Django set default value of field `b` equal to '0000000',instruction,0,281
605
+ "```b = models.CharField(max_length=7, default='0000000', editable=False)```",output,1,281
606
+ Sort lis `list5` in ascending order based on the degrees value of its elements,instruction,0,282
607
+ "```sorted(list5, lambda x: (degree(x), x))```",output,1,282
608
+ ,instruction,0,283
609
+ "```sorted(list5, key=lambda vertex: (degree(vertex), vertex))```",output,1,283
610
+ convert a list into a generator object,instruction,0,284
611
+ "```(n for n in [1, 2, 3, 5])```",output,1,284
612
+ remove elements from list `oldlist` that have an index number mentioned in list `removelist`,instruction,0,285
613
+ "```newlist = [v for i, v in enumerate(oldlist) if i not in removelist]```",output,1,285
614
+ Open a file `yourfile.txt` in write mode,instruction,0,286
615
+ "```f = open('yourfile.txt', 'w')```",output,1,286
616
+ get attribute 'attr' from object `obj`,instruction,0,287
617
+ "```getattr(obj, 'attr')```",output,1,287
618
+ "convert tuple of tuples `(('aa',), ('bb',), ('cc',))` to tuple",instruction,0,288
619
+ "```from functools import reduce
620
+ reduce(lambda a, b: a + b, (('aa',), ('bb',), ('cc',)))```",output,1,288
621
+ "convert tuple of tuples `(('aa',), ('bb',), ('cc',))` to list in one line",instruction,0,289
622
+ "```map(lambda a: a[0], (('aa',), ('bb',), ('cc',)))```",output,1,289
623
+ ,instruction,0,290
624
+ "```df['range'].replace(',', '-', inplace=True)```",output,1,290
625
+ "unzip the list `[('a', 1), ('b', 2), ('c', 3), ('d', 4)]`",instruction,0,291
626
+ "```zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)])```",output,1,291
627
+ "unzip the list `[('a', 1), ('b', 2), ('c', 3), ('d', 4)]`",instruction,0,292
628
+ "```zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)])```",output,1,292
629
+ unzip list `original`,instruction,0,293
630
+ "```result = ([a for (a, b) in original], [b for (a, b) in original])```",output,1,293
631
+ unzip list `original` and return a generator,instruction,0,294
632
+ "```result = ((a for (a, b) in original), (b for (a, b) in original))```",output,1,294
633
+ "unzip list `[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', )]`",instruction,0,295
634
+ "```zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e',)])```",output,1,295
635
+ "unzip list `[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', )]` and fill empty results with None",instruction,0,296
636
+ "```map(None, *[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e',)])```",output,1,296
637
+ encode `Decimal('3.9')` to a JSON string,instruction,0,297
638
+ ```json.dumps(Decimal('3.9'))```,output,1,297
639
+ "Add key ""mynewkey"" to dictionary `d` with value ""mynewvalue""",instruction,0,298
640
+ ```d['mynewkey'] = 'mynewvalue'```,output,1,298
641
+ Add key 'a' to dictionary `data` with value 1,instruction,0,299
642
+ "```data.update({'a': 1, })```",output,1,299
643
+ Add key 'a' to dictionary `data` with value 1,instruction,0,300
644
+ ```data.update(dict(a=1))```,output,1,300
645
+ Add key 'a' to dictionary `data` with value 1,instruction,0,301
646
+ ```data.update(a=1)```,output,1,301
647
+ find maximal value in matrix `matrix`,instruction,0,302
648
+ ```max([max(i) for i in matrix])```,output,1,302
649
+ Round number `answer` to 2 precision after the decimal point,instruction,0,303
650
+ "```answer = str(round(answer, 2))```",output,1,303
651
+ extract ip address from an html string,instruction,0,304
652
+ "```ip = re.findall('[0-9]+(?:\\.[0-9]+){3}', s)```",output,1,304
653
+ filter dataframe `df` by values in column `A` that appear more than once,instruction,0,305
654
+ ```df.groupby('A').filter(lambda x: len(x) > 1)```,output,1,305
655
+ append each line in file `myfile` into a list,instruction,0,306
656
+ ```[x for x in myfile.splitlines() if x != '']```,output,1,306
657
+ Get a list of integers `lst` from a file `filename.txt`,instruction,0,307
658
+ "```lst = map(int, open('filename.txt').readlines())```",output,1,307
659
+ add color bar with image `mappable` to plot `plt`,instruction,0,308
660
+ "```plt.colorbar(mappable=mappable, cax=ax3)```",output,1,308
661
+ count most frequent 100 words in column 'text' of dataframe `df`,instruction,0,309
662
+ ```Counter(' '.join(df['text']).split()).most_common(100)```,output,1,309
663
+ ,instruction,0,310
664
+ "```re.findall('(.+?):(.+?)\\b ?', text)```",output,1,310
665
+ "generate all 2-element subsets of tuple `(1, 2, 3)`",instruction,0,311
666
+ "```list(itertools.combinations((1, 2, 3), 2))```",output,1,311
667
+ get a value of datetime.today() in the UTC time zone,instruction,0,312
668
+ ```datetime.now(pytz.utc)```,output,1,312
669
+ Get a new list `list2`by removing empty list from a list of lists `list1`,instruction,0,313
670
+ ```list2 = [x for x in list1 if x != []]```,output,1,313
671
+ Create `list2` to contain the lists from list `list1` excluding the empty lists from `list1`,instruction,0,314
672
+ ```list2 = [x for x in list1 if x]```,output,1,314
673
+ Django response with JSON `data`,instruction,0,315
674
+ "```return HttpResponse(data, mimetype='application/json')```",output,1,315
675
+ get all text that is not enclosed within square brackets in string `example_str`,instruction,0,316
676
+ "```re.findall('(.*?)\\[.*?\\]', example_str)```",output,1,316
677
+ Use a regex to get all text in a string `example_str` that is not surrounded by square brackets,instruction,0,317
678
+ "```re.findall('(.*?)(?:\\[.*?\\]|$)', example_str)```",output,1,317
679
+ "get whatever is between parentheses as a single match, and any char outside as an individual match in string '(zyx)bc'",instruction,0,318
680
+ "```re.findall('\\(.+?\\)|\\w', '(zyx)bc')```",output,1,318
681
+ match regex '\\((.*?)\\)|(\\w)' with string '(zyx)bc',instruction,0,319
682
+ "```re.findall('\\((.*?)\\)|(\\w)', '(zyx)bc')```",output,1,319
683
+ match multiple regex patterns with the alternation operator `|` in a string `(zyx)bc`,instruction,0,320
684
+ "```re.findall('\\(.*?\\)|\\w', '(zyx)bc')```",output,1,320
685
+ formate each string cin list `elements` into pattern '%{0}%',instruction,0,321
686
+ ```elements = ['%{0}%'.format(element) for element in elements]```,output,1,321
687
+ Open a background process 'background-process' with arguments 'arguments',instruction,0,322
688
+ "```subprocess.Popen(['background-process', 'arguments'])```",output,1,322
689
+ get list of values from dictionary 'mydict' w.r.t. list of keys 'mykeys',instruction,0,323
690
+ ```[mydict[x] for x in mykeys]```,output,1,323
691
+ "convert list `[('Name', 'Joe'), ('Age', 22)]` into a dictionary",instruction,0,324
692
+ "```dict([('Name', 'Joe'), ('Age', 22)])```",output,1,324
693
+ average each two columns of array `data`,instruction,0,325
694
+ "```data.reshape(-1, j).mean(axis=1).reshape(data.shape[0], -1)```",output,1,325
695
+ double backslash escape all double quotes in string `s`,instruction,0,326
696
+ "```print(s.encode('unicode-escape').replace('""', '\\""'))```",output,1,326
697
+ split a string into a list of words and whitespace,instruction,0,327
698
+ "```re.split('(\\W+)', s)```",output,1,327
699
+ ,instruction,0,328
700
+ "```df.plot(kind='barh', stacked=True)```",output,1,328
701
+ reverse the keys and values in a dictionary `myDictionary`,instruction,0,329
702
+ ```{i[1]: i[0] for i in list(myDictionary.items())}```,output,1,329
703
+ finding the index of elements containing substring 'how' and 'what' in a list of strings 'myList'.,instruction,0,330
704
+ "```[i for i, j in enumerate(myList) if 'how' in j.lower() or 'what' in j.lower()]```",output,1,330
705
+ check if object `obj` is a string,instruction,0,331
706
+ "```isinstance(obj, str)```",output,1,331
707
+ check if object `o` is a string,instruction,0,332
708
+ "```isinstance(o, str)```",output,1,332
709
+ check if object `o` is a string,instruction,0,333
710
+ ```(type(o) is str)```,output,1,333
711
+ check if object `o` is a string,instruction,0,334
712
+ "```isinstance(o, str)```",output,1,334
713
+ check if `obj_to_test` is a string,instruction,0,335
714
+ "```isinstance(obj_to_test, str)```",output,1,335
715
+ append list `list1` to `list2`,instruction,0,336
716
+ ```list2.extend(list1)```,output,1,336
717
+ append list `mylog` to `list1`,instruction,0,337
718
+ ```list1.extend(mylog)```,output,1,337
719
+ append list `a` to `c`,instruction,0,338
720
+ ```c.extend(a)```,output,1,338
721
+ append items in list `mylog` to `list1`,instruction,0,339
722
+ "```for line in mylog:
723
+ list1.append(line)```",output,1,339
724
+ append a tuple of elements from list `a` with indexes '[0][0] [0][2]' to list `b`,instruction,0,340
725
+ "```b.append((a[0][0], a[0][2]))```",output,1,340
726
+ Initialize `SECRET_KEY` in flask config with `Your_secret_string `,instruction,0,341
727
+ ```app.config['SECRET_KEY'] = 'Your_secret_string'```,output,1,341
728
+ unpack a series of tuples in pandas into a DataFrame with column names 'out-1' and 'out-2',instruction,0,342
729
+ "```pd.DataFrame(out.tolist(), columns=['out-1', 'out-2'], index=out.index)```",output,1,342
730
+ find the index of an element 'MSFT' in a list `stocks_list`,instruction,0,343
731
+ ```[x for x in range(len(stocks_list)) if stocks_list[x] == 'MSFT']```,output,1,343
732
+ rotate the xtick labels of matplotlib plot `ax` by `45` degrees to make long labels readable,instruction,0,344
733
+ "```ax.set_xticklabels(labels, rotation=45)```",output,1,344
734
+ remove symbols from a string `s`,instruction,0,345
735
+ "```re.sub('[^\\w]', ' ', s)```",output,1,345
736
+ Get the current directory of a script,instruction,0,346
737
+ ```os.path.basename(os.path.dirname(os.path.realpath(__file__)))```,output,1,346
738
+ Find octal characters matches from a string `str` using regex,instruction,0,347
739
+ "```print(re.findall(""'\\\\[0-7]{1,3}'"", str))```",output,1,347
740
+ split string `input` based on occurrences of regex pattern '[ ](?=[A-Z]+\\b)',instruction,0,348
741
+ "```re.split('[ ](?=[A-Z]+\\b)', input)```",output,1,348
742
+ Split string `input` at every space followed by an upper-case letter,instruction,0,349
743
+ "```re.split('[ ](?=[A-Z])', input)```",output,1,349
744
+ send multipart encoded file `files` to url `url` with headers `headers` and metadata `data`,instruction,0,350
745
+ "```r = requests.post(url, files=files, headers=headers, data=data)```",output,1,350
746
+ write bytes `bytes_` to a file `filename` in python 3,instruction,0,351
747
+ "```open('filename', 'wb').write(bytes_)```",output,1,351
748
+ get a list from a list `lst` with values mapped into a dictionary `dct`,instruction,0,352
749
+ ```[dct[k] for k in lst]```,output,1,352
750
+ find duplicate names in column 'name' of the dataframe `x`,instruction,0,353
751
+ ```x.set_index('name').index.get_duplicates()```,output,1,353
752
+ truncate float 1.923328437452 to 3 decimal places,instruction,0,354
753
+ "```round(1.923328437452, 3)```",output,1,354
754
+ sort list `li` in descending order based on the date value in second element of each list in list `li`,instruction,0,355
755
+ "```sorted(li, key=lambda x: datetime.strptime(x[1], '%d/%m/%Y'), reverse=True)```",output,1,355
756
+ place the radial ticks in plot `ax` at 135 degrees,instruction,0,356
757
+ ```ax.set_rlabel_position(135)```,output,1,356
758
+ check if path `my_path` is an absolute path,instruction,0,357
759
+ ```os.path.isabs(my_path)```,output,1,357
760
+ get number of keys in dictionary `yourdict`,instruction,0,358
761
+ ```len(list(yourdict.keys()))```,output,1,358
762
+ count the number of keys in dictionary `yourdictfile`,instruction,0,359
763
+ ```len(set(open(yourdictfile).read().split()))```,output,1,359
764
+ pandas dataframe get first row of each group by 'id',instruction,0,360
765
+ ```df.groupby('id').first()```,output,1,360
766
+ split a list in first column into multiple columns keeping other columns as well in pandas data frame,instruction,0,361
767
+ "```pd.concat([df[0].apply(pd.Series), df[1]], axis=1)```",output,1,361
768
+ "extract attributes 'src=""js/([^""]*\\bjquery\\b[^""]*)""' from string `data`",instruction,0,362
769
+ "```re.findall('src=""js/([^""]*\\bjquery\\b[^""]*)""', data)```",output,1,362
770
+ "Sum integers contained in strings in list `['', '3.4', '', '', '1.0']`",instruction,0,363
771
+ "```sum(int(float(item)) for item in [_f for _f in ['', '3.4', '', '', '1.0'] if _f])```",output,1,363
772
+ Call a subprocess with arguments `c:\\Program Files\\VMware\\VMware Server\\vmware-cmd.bat` that may contain spaces,instruction,0,364
773
+ ```subprocess.Popen(['c:\\Program Files\\VMware\\VMware Server\\vmware-cmd.bat'])```,output,1,364
774
+ reverse a priority queue `q` in python without using classes,instruction,0,365
775
+ "```q.put((-n, n))```",output,1,365
776
+ make a barplot of data in column `group` of dataframe `df` colour-coded according to list `color`,instruction,0,366
777
+ "```df['group'].plot(kind='bar', color=['r', 'g', 'b', 'r', 'g', 'b', 'r'])```",output,1,366
778
+ find all matches of regex pattern '([a-fA-F\\d]{32})' in string `data`,instruction,0,367
779
+ "```re.findall('([a-fA-F\\d]{32})', data)```",output,1,367
780
+ Get the length of list `my_list`,instruction,0,368
781
+ ```len(my_list)```,output,1,368
782
+ Getting the length of array `l`,instruction,0,369
783
+ ```len(l)```,output,1,369
784
+ Getting the length of array `s`,instruction,0,370
785
+ ```len(s)```,output,1,370
786
+ Getting the length of `my_tuple`,instruction,0,371
787
+ ```len(my_tuple)```,output,1,371
788
+ Getting the length of `my_string`,instruction,0,372
789
+ ```len(my_string)```,output,1,372
790
+ "remove escape character from string ""\\a""",instruction,0,373
791
+ "```""""""\\a"""""".decode('string_escape')```",output,1,373
792
+ replace each 'a' with 'b' and each 'b' with 'a' in the string 'obama' in a single pass.,instruction,0,374
793
+ "```""""""obama"""""".replace('a', '%temp%').replace('b', 'a').replace('%temp%', 'b')```",output,1,374
794
+ remove directory tree '/folder_name',instruction,0,375
795
+ ```shutil.rmtree('/folder_name')```,output,1,375
796
+ create a new column `weekday` in pandas data frame `data` based on the values in column `my_dt`,instruction,0,376
797
+ ```data['weekday'] = data['my_dt'].apply(lambda x: x.weekday())```,output,1,376
798
+ reverse sort Counter `x` by values,instruction,0,377
799
+ "```sorted(x, key=x.get, reverse=True)```",output,1,377
800
+ reverse sort counter `x` by value,instruction,0,378
801
+ "```sorted(list(x.items()), key=lambda pair: pair[1], reverse=True)```",output,1,378
802
+ append a numpy array 'b' to a numpy array 'a',instruction,0,379
803
+ "```np.vstack((a, b))```",output,1,379
804
+ numpy concatenate two arrays `a` and `b` along the first axis,instruction,0,380
805
+ "```print(concatenate((a, b), axis=0))```",output,1,380
806
+ numpy concatenate two arrays `a` and `b` along the second axis,instruction,0,381
807
+ "```print(concatenate((a, b), axis=1))```",output,1,381
808
+ numpy concatenate two arrays `a` and `b` along the first axis,instruction,0,382
809
+ "```c = np.r_[(a[None, :], b[None, :])]```",output,1,382
810
+ numpy concatenate two arrays `a` and `b` along the first axis,instruction,0,383
811
+ "```np.array((a, b))```",output,1,383
812
+ fetch address information for host 'google.com' ion port 80,instruction,0,384
813
+ "```print(socket.getaddrinfo('google.com', 80))```",output,1,384
814
+ add a column 'day' with value 'sat' to dataframe `df`,instruction,0,385
815
+ "```df.xs('sat', level='day', drop_level=False)```",output,1,385
816
+ return a 401 unauthorized in django,instruction,0,386
817
+ "```return HttpResponse('Unauthorized', status=401)```",output,1,386
818
+ Flask set folder 'wherever' as the default template folder,instruction,0,387
819
+ "```Flask(__name__, template_folder='wherever')```",output,1,387
820
+ How do I INSERT INTO t1 (SELECT * FROM t2) in SQLAlchemy?,instruction,0,388
821
+ ```session.execute('INSERT INTO t1 (SELECT * FROM t2)')```,output,1,388
822
+ sort a list of lists 'c2' such that third row comes first,instruction,0,389
823
+ ```c2.sort(key=lambda row: row[2])```,output,1,389
824
+ ,instruction,0,390
825
+ "```c2.sort(key=lambda row: (row[2], row[1], row[0]))```",output,1,390
826
+ ,instruction,0,391
827
+ "```c2.sort(key=lambda row: (row[2], row[1]))```",output,1,391
828
+ set font `Arial` to display non-ascii characters in matplotlib,instruction,0,392
829
+ "```matplotlib.rc('font', **{'sans-serif': 'Arial', 'family': 'sans-serif'})```",output,1,392
830
+ Convert DateTime column 'date' of pandas dataframe 'df' to ordinal,instruction,0,393
831
+ ```df['date'].apply(lambda x: x.toordinal())```,output,1,393
832
+ get html source of Selenium WebElement `element`,instruction,0,394
833
+ ```element.get_attribute('innerHTML')```,output,1,394
834
+ Get the integer location of a key `bob` in a pandas data frame,instruction,0,395
835
+ ```df.index.get_loc('bob')```,output,1,395
836
+ open a 'gnome' terminal from python script and run 'sudo apt-get update' command.,instruction,0,396
837
+ "```os.system('gnome-terminal -e \'bash -c ""sudo apt-get update; exec bash""\'')```",output,1,396
838
+ add an item with key 'third_key' and value 1 to an dictionary `my_dict`,instruction,0,397
839
+ ```my_dict.update({'third_key': 1})```,output,1,397
840
+ declare an array,instruction,0,398
841
+ ```my_list = []```,output,1,398
842
+ Insert item `12` to a list `my_list`,instruction,0,399
843
+ ```my_list.append(12)```,output,1,399
844
+ add an entry 'wuggah' at the beginning of list `myList`,instruction,0,400
845
+ "```myList.insert(0, 'wuggah')```",output,1,400
846
+ convert a hex-string representation to actual bytes,instruction,0,401
847
+ "```""""""\\xF3\\xBE\\x80\\x80"""""".replace('\\x', '').decode('hex')```",output,1,401
848
+ select the last column of dataframe `df`,instruction,0,402
849
+ ```df[df.columns[-1]]```,output,1,402
850
+ get the first value from dataframe `df` where column 'Letters' is equal to 'C',instruction,0,403
851
+ "```df.loc[df['Letters'] == 'C', 'Letters'].values[0]```",output,1,403
852
+ "converting two lists `[1, 2, 3]` and `[4, 5, 6]` into a matrix",instruction,0,404
853
+ "```np.column_stack(([1, 2, 3], [4, 5, 6]))```",output,1,404
854
+ get the type of `i`,instruction,0,405
855
+ ```type(i)```,output,1,405
856
+ determine the type of variable `v`,instruction,0,406
857
+ ```type(v)```,output,1,406
858
+ determine the type of variable `v`,instruction,0,407
859
+ ```type(v)```,output,1,407
860
+ determine the type of variable `v`,instruction,0,408
861
+ ```type(v)```,output,1,408
862
+ determine the type of variable `v`,instruction,0,409
863
+ ```type(v)```,output,1,409
864
+ get the type of variable `variable_name`,instruction,0,410
865
+ ```print(type(variable_name))```,output,1,410
866
+ get the 5th item of a generator,instruction,0,411
867
+ "```next(itertools.islice(range(10), 5, 5 + 1))```",output,1,411
868
+ Print a string `word` with string format,instruction,0,412
869
+ "```print('""{}""'.format(word))```",output,1,412
870
+ join a list of strings `list` using a space ' ',instruction,0,413
871
+ "```"""""" """""".join(list)```",output,1,413
872
+ create list `y` containing two empty lists,instruction,0,414
873
+ ```y = [[] for n in range(2)]```,output,1,414
874
+ read a file 'C:/name/MyDocuments/numbers' into a list `data`,instruction,0,415
875
+ "```data = [line.strip() for line in open('C:/name/MyDocuments/numbers', 'r')]```",output,1,415
876
+ delete all occurrences of character 'i' in string 'it is icy',instruction,0,416
877
+ "```"""""""""""".join([char for char in 'it is icy' if char != 'i'])```",output,1,416
878
+ delete all instances of a character 'i' in a string 'it is icy',instruction,0,417
879
+ "```re.sub('i', '', 'it is icy')```",output,1,417
880
+ "delete all characters ""i"" in string ""it is icy""",instruction,0,418
881
+ "```""""""it is icy"""""".replace('i', '')```",output,1,418
882
+ ,instruction,0,419
883
+ "```"""""""""""".join([char for char in 'it is icy' if char != 'i'])```",output,1,419
884
+ "Drop rows of pandas dataframe `df` having NaN in column at index ""1""",instruction,0,420
885
+ ```df.dropna(subset=[1])```,output,1,420
886
+ "get elements from list `myList`, that have a field `n` value 30",instruction,0,421
887
+ ```[x for x in myList if x.n == 30]```,output,1,421
888
+ converting list of strings `intstringlist` to list of integer `nums`,instruction,0,422
889
+ ```nums = [int(x) for x in intstringlist]```,output,1,422
890
+ convert list of string numbers into list of integers,instruction,0,423
891
+ "```map(int, eval(input('Enter the unfriendly numbers: ')))```",output,1,423
892
+ "print ""."" without newline",instruction,0,424
893
+ ```sys.stdout.write('.')```,output,1,424
894
+ round off the float that is the product of `2.52 * 100` and convert it to an int,instruction,0,425
895
+ ```int(round(2.51 * 100))```,output,1,425
896
+ "Find all files in directory ""/mydir"" with extension "".txt""",instruction,0,426
897
+ "```os.chdir('/mydir')
898
+ for file in glob.glob('*.txt'):
899
+ pass```",output,1,426
900
+ "Find all files in directory ""/mydir"" with extension "".txt""",instruction,0,427
901
+ "```for file in os.listdir('/mydir'):
902
+ if file.endswith('.txt'):
903
+ pass```",output,1,427
904
+ "Find all files in directory ""/mydir"" with extension "".txt""",instruction,0,428
905
+ "```for (root, dirs, files) in os.walk('/mydir'):
906
+ for file in files:
907
+ if file.endswith('.txt'):
908
+ pass```",output,1,428
909
+ plot dataframe `df` without a legend,instruction,0,429
910
+ ```df.plot(legend=False)```,output,1,429
911
+ "loop through the IP address range ""192.168.x.x""",instruction,0,430
912
+ "```for i in range(256):
913
+ for j in range(256):
914
+ ip = ('192.168.%d.%d' % (i, j))
915
+ print(ip)```",output,1,430
916
+ "loop through the IP address range ""192.168.x.x""",instruction,0,431
917
+ "```for (i, j) in product(list(range(256)), list(range(256))):
918
+ pass```",output,1,431
919
+ "loop through the IP address range ""192.168.x.x""",instruction,0,432
920
+ "```generator = iter_iprange('192.168.1.1', '192.168.255.255', step=1)```",output,1,432
921
+ Sum the corresponding decimal values for binary values of each boolean element in list `x`,instruction,0,433
922
+ "```sum(1 << i for i, b in enumerate(x) if b)```",output,1,433
923
+ "write multiple strings `line1`, `line2` and `line3` in one line in a file `target`",instruction,0,434
924
+ "```target.write('%r\n%r\n%r\n' % (line1, line2, line3))```",output,1,434
925
+ Convert list of lists `data` into a flat list,instruction,0,435
926
+ "```[y for x in data for y in (x if isinstance(x, list) else [x])]```",output,1,435
927
+ Print new line character as `\n` in a string `foo\nbar`,instruction,0,436
928
+ ```print('foo\nbar'.encode('string_escape'))```,output,1,436
929
+ "remove last comma character ',' in string `s`",instruction,0,437
930
+ "```"""""""""""".join(s.rsplit(',', 1))```",output,1,437
931
+ calculate the mean of each element in array `x` with the element previous to it,instruction,0,438
932
+ ```(x[1:] + x[:-1]) / 2```,output,1,438
933
+ get an array of the mean of each two consecutive values in numpy array `x`,instruction,0,439
934
+ ```x[:-1] + (x[1:] - x[:-1]) / 2```,output,1,439
935
+ load data containing `utf-8` from file `new.txt` into numpy array `arr`,instruction,0,440
936
+ "```arr = numpy.fromiter(codecs.open('new.txt', encoding='utf-8'), dtype='<U2')```",output,1,440
937
+ reverse sort list of dicts `l` by value for key `time`,instruction,0,441
938
+ "```l = sorted(l, key=itemgetter('time'), reverse=True)```",output,1,441
939
+ Sort a list of dictionary `l` based on key `time` in descending order,instruction,0,442
940
+ "```l = sorted(l, key=lambda a: a['time'], reverse=True)```",output,1,442
941
+ get rows of dataframe `df` that match regex '(Hel|Just)',instruction,0,443
942
+ ```df.loc[df[0].str.contains('(Hel|Just)')]```,output,1,443
943
+ "find the string in `your_string` between two special characters ""["" and ""]""",instruction,0,444
944
+ "```re.search('\\[(.*)\\]', your_string).group(1)```",output,1,444
945
+ ,instruction,0,445
946
+ "```[d.strftime('%Y%m%d') for d in pandas.date_range('20130226', '20130302')]```",output,1,445
947
+ count number of times string 'brown' occurred in string 'The big brown fox is brown',instruction,0,446
948
+ "```""""""The big brown fox is brown"""""".count('brown')```",output,1,446
949
+ decode json string `request.body` to python dict,instruction,0,447
950
+ ```json.loads(request.body)```,output,1,447
951
+ download the file from url `url` and save it under file `file_name`,instruction,0,448
952
+ "```urllib.request.urlretrieve(url, file_name)```",output,1,448
953
+ split string `text` by space,instruction,0,449
954
+ ```text.split()```,output,1,449
955
+ "split string `text` by "",""",instruction,0,450
956
+ "```text.split(',')```",output,1,450
957
+ Split string `line` into a list by whitespace,instruction,0,451
958
+ ```line.split()```,output,1,451
959
+ replace dot characters '.' associated with ascii letters in list `s` with space ' ',instruction,0,452
960
+ "```[re.sub('(?<!\\d)\\.(?!\\d)', ' ', i) for i in s]```",output,1,452
961
+ sort list `list_of_strings` based on second index of each string `s`,instruction,0,453
962
+ "```sorted(list_of_strings, key=lambda s: s.split(',')[1])```",output,1,453
963
+ call multiple bash function ‘vasp’ and ‘tee tee_output’ using ‘|’,instruction,0,454
964
+ "```subprocess.check_call('vasp | tee tee_output', shell=True)```",output,1,454
965
+ eliminate all strings from list `lst`,instruction,0,455
966
+ "```[element for element in lst if isinstance(element, int)]```",output,1,455
967
+ get all the elements except strings from the list 'lst'.,instruction,0,456
968
+ "```[element for element in lst if not isinstance(element, str)]```",output,1,456
969
+ Sort a list of dictionaries `list_to_be_sorted` by the value of the dictionary key `name`,instruction,0,457
970
+ "```newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])```",output,1,457
971
+ sort a list of dictionaries `l` by values in key `name` in descending order,instruction,0,458
972
+ "```newlist = sorted(l, key=itemgetter('name'), reverse=True)```",output,1,458
973
+ ,instruction,0,459
974
+ ```list_of_dicts.sort(key=operator.itemgetter('name'))```,output,1,459
975
+ ,instruction,0,460
976
+ ```list_of_dicts.sort(key=operator.itemgetter('age'))```,output,1,460
977
+ ,instruction,0,461
978
+ "```df.groupby('prots').sum().sort('scores', ascending=False)```",output,1,461
979
+ "join together with "","" elements inside a list indexed with 'category' within a dictionary `trans`",instruction,0,462
980
+ "```"""""","""""".join(trans['category'])```",output,1,462
981
+ "concatenate array of strings `['A', 'B', 'C', 'D']` into a string",instruction,0,463
982
+ "```"""""""""""".join(['A', 'B', 'C', 'D'])```",output,1,463
983
+ get json data from restful service 'url',instruction,0,464
984
+ ```json.load(urllib.request.urlopen('url'))```,output,1,464
985
+ Remove all strings from a list a strings `sents` where the values starts with `@$\t` or `#`,instruction,0,465
986
+ ```[x for x in sents if not x.startswith('@$\t') and not x.startswith('#')]```,output,1,465
987
+ django filter by hour,instruction,0,466
988
+ ```Entry.objects.filter(pub_date__contains='08:00')```,output,1,466
989
+ sort a list of dictionary `list` first by key `points` and then by `time`,instruction,0,467
990
+ "```list.sort(key=lambda item: (item['points'], item['time']))```",output,1,467
991
+ "convert datetime object `(1970, 1, 1)` to seconds",instruction,0,468
992
+ "```(t - datetime.datetime(1970, 1, 1)).total_seconds()```",output,1,468
993
+ insert `_suff` before the file extension in `long.file.name.jpg` or replace `_a` with `suff` if it precedes the extension.,instruction,0,469
994
+ "```re.sub('(\\_a)?\\.([^\\.]*)$', '_suff.\\2', 'long.file.name.jpg')```",output,1,469
995
+ reload a module `module`,instruction,0,470
996
+ "```import imp
997
+ imp.reload(module)```",output,1,470
998
+ Convert integer `number` into an unassigned integer,instruction,0,471
999
+ "```struct.unpack('H', struct.pack('h', number))```",output,1,471
1000
+ convert int values in list `numlist` to float,instruction,0,472
1001
+ ```numlist = [float(x) for x in numlist]```,output,1,472
1002
+ "write dataframe `df`, excluding index, to a csv file",instruction,0,473
1003
+ "```df.to_csv(filename, index=False)```",output,1,473
1004
+ convert a urllib unquoted string `unescaped` to a json data `json_data`,instruction,0,474
1005
+ ```json_data = json.loads(unescaped)```,output,1,474
1006
+ Create a list containing all ascii characters as its elements,instruction,0,475
1007
+ ```[chr(i) for i in range(127)]```,output,1,475
1008
+ write `newFileBytes` to a binary file `newFile`,instruction,0,476
1009
+ "```newFile.write(struct.pack('5B', *newFileBytes))```",output,1,476
1010
+ python regex - check for a capital letter with a following lowercase in string `string`,instruction,0,477
1011
+ "```re.sub('^[A-Z0-9]*(?![a-z])', '', string)```",output,1,477
1012
+ get the last key of dictionary `dict`,instruction,0,478
1013
+ ```list(dict.keys())[-1]```,output,1,478
1014
+ "write line ""hi there"" to file `f`",instruction,0,479
1015
+ "```print('hi there', file=f)```",output,1,479
1016
+ "write line ""hi there"" to file `myfile`",instruction,0,480
1017
+ "```f = open('myfile', 'w')
1018
+ f.write('hi there\n')
1019
+ f.close()```",output,1,480
1020
+ "write line ""Hello"" to file `somefile.txt`",instruction,0,481
1021
+ "```with open('somefile.txt', 'a') as the_file:
1022
+ the_file.write('Hello\n')```",output,1,481
1023
+ convert unicode string `s` to ascii,instruction,0,482
1024
+ ```s.encode('iso-8859-15')```,output,1,482
1025
+ Django get maximum value associated with field 'added' in model `AuthorizedEmail`,instruction,0,483
1026
+ ```AuthorizedEmail.objects.filter(group=group).order_by('-added')[0]```,output,1,483
1027
+ Find all numbers and dots from a string `text` using regex,instruction,0,484
1028
+ "```re.findall('Test([0-9.]*[0-9]+)', text)```",output,1,484
1029
+ python regex to find all numbers and dots from 'text',instruction,0,485
1030
+ "```re.findall('Test([\\d.]*\\d+)', text)```",output,1,485
1031
+ execute script 'script.ps1' using 'powershell.exe' shell,instruction,0,486
1032
+ "```os.system('powershell.exe', 'script.ps1')```",output,1,486
1033
+ Sort a list of tuples `b` by third item in the tuple,instruction,0,487
1034
+ ```b.sort(key=lambda x: x[1][2])```,output,1,487
1035
+ get a list of all keys in Cassandra database `cf` with pycassa,instruction,0,488
1036
+ ```list(cf.get_range().get_keys())```,output,1,488
1037
+ create a datetime with the current date & time,instruction,0,489
1038
+ ```datetime.datetime.now()```,output,1,489
1039
+ get the index of an integer `1` from a list `lst` if the list also contains boolean items,instruction,0,490
1040
+ "```next(i for i, x in enumerate(lst) if not isinstance(x, bool) and x == 1)```",output,1,490
1041
+ subtract 13 from every number in a list `a`,instruction,0,491
1042
+ ```a[:] = [(x - 13) for x in a]```,output,1,491
1043
+ "choose a random file from the directory contents of the C drive, `C:\\`",instruction,0,492
1044
+ ```random.choice(os.listdir('C:\\'))```,output,1,492
1045
+ get the highest element in absolute value in a numpy matrix `x`,instruction,0,493
1046
+ "```max(x.min(), x.max(), key=abs)```",output,1,493
1047
+ Get all urls within text `s`,instruction,0,494
1048
+ "```re.findall('""(http.*?)""', s, re.MULTILINE | re.DOTALL)```",output,1,494
1049
+ match urls whose domain doesn't start with `t` from string `document` using regex,instruction,0,495
1050
+ "```re.findall('http://[^t][^s""]+\\.html', document)```",output,1,495
1051
+ split a string `mystring` considering the spaces ' ',instruction,0,496
1052
+ "```mystring.replace(' ', '! !').split('!')```",output,1,496
1053
+ open file `path` with mode 'r',instruction,0,497
1054
+ "```open(path, 'r')```",output,1,497
1055
+ sum elements at the same index in list `data`,instruction,0,498
1056
+ ```[[sum(item) for item in zip(*items)] for items in zip(*data)]```,output,1,498
1057
+ add a new axis to array `a`,instruction,0,499
1058
+ "```a[:, (np.newaxis)]```",output,1,499
conala-paired-train.csv ADDED
The diff for this file is too large to render. See raw diff