conala_standardized / conala-paired-test.csv
yam-peleg's picture
Upload 3 files
3708947
Raw
History Blame Contribute Delete
69.8 kB
message,message_type,message_id,conversation_id
send a signal `signal.SIGUSR1` to the current process,instruction,0,0
"```os.kill(os.getpid(), signal.SIGUSR1)```",output,1,0
decode a hex string '4a4b4c' to UTF-8.,instruction,0,1
```bytes.fromhex('4a4b4c').decode('utf-8')```,output,1,1
check if all elements in list `myList` are identical,instruction,0,2
```all(x == myList[0] for x in myList)```,output,1,2
"format number of spaces between strings `Python`, `:` and `Very Good` to be `20`",instruction,0,3
"```print('%*s : %*s' % (20, 'Python', 20, 'Very Good'))```",output,1,3
,instruction,0,4
```d.decode('cp1251').encode('utf8')```,output,1,4
get rid of None values in dictionary `kwargs`,instruction,0,5
"```res = {k: v for k, v in list(kwargs.items()) if v is not None}```",output,1,5
get rid of None values in dictionary `kwargs`,instruction,0,6
"```res = dict((k, v) for k, v in kwargs.items() if v is not None)```",output,1,6
capture final output of a chain of system commands `ps -ef | grep something | wc -l`,instruction,0,7
"```subprocess.check_output('ps -ef | grep something | wc -l', shell=True)```",output,1,7
"concatenate a list of strings `['a', 'b', 'c']`",instruction,0,8
"```"""""""""""".join(['a', 'b', 'c'])```",output,1,8
find intersection data between series `s1` and series `s2`,instruction,0,9
```pd.Series(list(set(s1).intersection(set(s2))))```,output,1,9
sending http headers to `client`,instruction,0,10
```client.send('HTTP/1.0 200 OK\r\n')```,output,1,10
Format a datetime string `when` to extract date only,instruction,0,11
"```then = datetime.datetime.strptime(when, '%Y-%m-%d').date()```",output,1,11
split a multi-line string `inputString` into separate strings,instruction,0,12
```inputString.split('\n')```,output,1,12
Split a multi-line string ` a \n b \r\n c ` by new line character `\n`,instruction,0,13
```' a \n b \r\n c '.split('\n')```,output,1,13
"concatenate elements of list `b` by a colon "":""",instruction,0,14
"```"""""":"""""".join(str(x) for x in b)```",output,1,14
get the first object from a queryset in django model `Entry`,instruction,0,15
```Entry.objects.filter()[:1].get()```,output,1,15
Calculate sum over all rows of 2D numpy array,instruction,0,16
```a.sum(axis=1)```,output,1,16
enable warnings using action 'always',instruction,0,17
```warnings.simplefilter('always')```,output,1,17
concatenate items of list `l` with a space ' ',instruction,0,18
"```print(' '.join(map(str, l)))```",output,1,18
run script 'hello.py' with argument 'htmlfilename.htm' on terminal using python executable,instruction,0,19
"```subprocess.call(['python.exe', 'hello.py', 'htmlfilename.htm'])```",output,1,19
,instruction,0,20
"```time.strptime('30/03/09 16:31:32.123', '%d/%m/%y %H:%M:%S.%f')```",output,1,20
convert a string `my_string` with dot and comma into a float number `my_float`,instruction,0,21
"```my_float = float(my_string.replace(',', ''))```",output,1,21
"convert a string `123,456.908` with dot and comma into a floating number",instruction,0,22
"```float('123,456.908'.replace(',', ''))```",output,1,22
set pythonpath in python script.,instruction,0,23
```sys.path.append('/path/to/whatever')```,output,1,23
"split string 'Words, words, words.' using a regex '(\\W+)'",instruction,0,24
"```re.split('(\\W+)', 'Words, words, words.')```",output,1,24
open a file `Output.txt` in append mode,instruction,0,25
"```file = open('Output.txt', 'a')```",output,1,25
"download a file ""http://www.example.com/songs/mp3.mp3"" over HTTP and save to ""mp3.mp3""",instruction,0,26
"```urllib.request.urlretrieve('http://www.example.com/songs/mp3.mp3', 'mp3.mp3')```",output,1,26
download a file `url` over HTTP and save to `file_name`,instruction,0,27
"```u = urllib.request.urlopen(url)
f = open(file_name, 'wb')
meta = u.info()
file_size = int(meta.getheaders('Content-Length')[0])
print(('Downloading: %s Bytes: %s' % (file_name, file_size)))
file_size_dl = 0
block_sz = 8192
while True:
buffer = u.read(block_sz)
if (not buffer):
break
file_size_dl += len(buffer)
f.write(buffer)
status = ('%10d [%3.2f%%]' % (file_size_dl, ((file_size_dl * 100.0) / file_size)))
status = (status + (chr(8) * (len(status) + 1)))
print(status, end=' ')
f.close()```",output,1,27
download a file 'http://www.example.com/' over HTTP,instruction,0,28
"```response = urllib.request.urlopen('http://www.example.com/')
html = response.read()```",output,1,28
download a file `url` over HTTP,instruction,0,29
```r = requests.get(url)```,output,1,29
"download a file `url` over HTTP and save to ""10MB""",instruction,0,30
"```response = requests.get(url, stream=True)
with open('10MB', 'wb') as handle:
for data in tqdm(response.iter_content()):
handle.write(data)```",output,1,30
argparse add argument with flag '--version' and version action of '%(prog)s 2.0' to parser `parser`,instruction,0,31
"```parser.add_argument('--version', action='version', version='%(prog)s 2.0')```",output,1,31
remove key 'c' from dictionary `d`,instruction,0,32
```{i: d[i] for i in d if i != 'c'}```,output,1,32
"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
"```pd.merge(split_df, csv_df, on=['key'], suffixes=('_left', '_right'))```",output,1,33
Split a string `s` by space with `4` splits,instruction,0,34
"```s.split(' ', 4)```",output,1,34
read keyboard-input,instruction,0,35
```input('Enter your input:')```,output,1,35
enable debug mode on Flask application `app`,instruction,0,36
```app.run(debug=True)```,output,1,36
python save list `mylist` to file object 'save.txt',instruction,0,37
"```pickle.dump(mylist, open('save.txt', 'wb'))```",output,1,37
Multiply a matrix `P` with a 3d tensor `T` in scipy,instruction,0,38
"```scipy.tensordot(P, T, axes=[1, 1]).swapaxes(0, 1)```",output,1,38
"Create 3d array of zeroes of size `(3,3,3)`",instruction,0,39
"```numpy.zeros((3, 3, 3))```",output,1,39
cut off the last word of a sentence `content`,instruction,0,40
"```"""""" """""".join(content.split(' ')[:-1])```",output,1,40
convert scalar `x` to array,instruction,0,41
"```x = np.asarray(x).reshape(1, -1)[(0), :]```",output,1,41
sum all elements of nested list `L`,instruction,0,42
"```sum(sum(i) if isinstance(i, list) else i for i in L)```",output,1,42
convert hex string '470FC614' to a float number,instruction,0,43
"```struct.unpack('!f', '470FC614'.decode('hex'))[0]```",output,1,43
Multiple each value by `2` for all keys in a dictionary `my_dict`,instruction,0,44
"```my_dict.update((x, y * 2) for x, y in list(my_dict.items()))```",output,1,44
running bash script 'sleep.sh',instruction,0,45
"```subprocess.call('sleep.sh', shell=True)```",output,1,45
"Join elements of list `l` with a comma `,`",instruction,0,46
"```"""""","""""".join(l)```",output,1,46
make a comma-separated string from a list `myList`,instruction,0,47
"```myList = ','.join(map(str, myList))```",output,1,47
reverse the list that contains 1 to 10,instruction,0,48
```list(reversed(list(range(10))))```,output,1,48
"remove substring 'bag,' from a string 'lamp, bag, mirror'",instruction,0,49
"```print('lamp, bag, mirror'.replace('bag,', ''))```",output,1,49
"Reverse the order of words, delimited by `.`, in string `s`",instruction,0,50
"```""""""."""""".join(s.split('.')[::-1])```",output,1,50
convert epoch time represented as milliseconds `s` to string using format '%Y-%m-%d %H:%M:%S.%f',instruction,0,51
```datetime.datetime.fromtimestamp(s).strftime('%Y-%m-%d %H:%M:%S.%f')```,output,1,51
parse milliseconds epoch time '1236472051807' to format '%Y-%m-%d %H:%M:%S',instruction,0,52
"```time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(1236472051807 / 1000.0))```",output,1,52
get the date 7 days before the current date,instruction,0,53
```(datetime.datetime.now() - datetime.timedelta(days=7)).date()```,output,1,53
sum elements at index `column` of each list in list `data`,instruction,0,54
```print(sum(row[column] for row in data))```,output,1,54
sum columns of a list `array`,instruction,0,55
```[sum(row[i] for row in array) for i in range(len(array[0]))]```,output,1,55
encode binary string 'your string' to base64 code,instruction,0,56
"```base64.b64encode(bytes('your string', 'utf-8'))```",output,1,56
combine list of dictionaries `dicts` with the same keys in each list to a single dictionary,instruction,0,57
"```dict((k, [d[k] for d in dicts]) for k in dicts[0])```",output,1,57
Merge a nested dictionary `dicts` into a flat dictionary by concatenating nested values with the same key `k`,instruction,0,58
```{k: [d[k] for d in dicts] for k in dicts[0]}```,output,1,58
,instruction,0,59
```request.args['myParam']```,output,1,59
identify duplicate values in list `mylist`,instruction,0,60
"```[k for k, v in list(Counter(mylist).items()) if v > 1]```",output,1,60
Insert directory 'apps' into directory `__file__`,instruction,0,61
"```sys.path.insert(1, os.path.join(os.path.dirname(__file__), 'apps'))```",output,1,61
modify sys.path for python module `subdir`,instruction,0,62
"```sys.path.append(os.path.join(os.path.dirname(__file__), 'subdir'))```",output,1,62
Insert a 'None' value into a SQLite3 table.,instruction,0,63
"```db.execute(""INSERT INTO present VALUES('test2', ?, 10)"", (None,))```",output,1,63
flatten list `list_of_menuitems`,instruction,0,64
```[image for menuitem in list_of_menuitems for image in menuitem]```,output,1,64
append elements of a set `b` to a list `a`,instruction,0,65
```a.extend(b)```,output,1,65
,instruction,0,66
```a.extend(list(b))```,output,1,66
write the data of dataframe `df` into text file `np.txt`,instruction,0,67
"```np.savetxt('c:\\data\\np.txt', df.values, fmt='%d')```",output,1,67
write content of DataFrame `df` into text file 'c:\\data\\pandas.txt',instruction,0,68
"```df.to_csv('c:\\data\\pandas.txt', header=None, index=None, sep=' ', mode='a')```",output,1,68
Split a string `x` by last occurrence of character `-`,instruction,0,69
```print(x.rpartition('-')[0])```,output,1,69
get the last part of a string before the character '-',instruction,0,70
"```print(x.rsplit('-', 1)[0])```",output,1,70
upload file using FTP,instruction,0,71
"```ftp.storlines('STOR ' + filename, open(filename, 'r'))```",output,1,71
add one to the hidden web element with id 'XYZ' with selenium python script,instruction,0,72
"```browser.execute_script(""document.getElementById('XYZ').value+='1'"")```",output,1,72
"create array containing the maximum value of respective elements of array `[2, 3, 4]` and array `[1, 5, 2]`",instruction,0,73
"```np.maximum([2, 3, 4], [1, 5, 2])```",output,1,73
print a list `l` and move first 3 elements to the end of the list,instruction,0,74
```print(l[3:] + l[:3])```,output,1,74
loop over files in directory '.',instruction,0,75
"```for fn in os.listdir('.'):
if os.path.isfile(fn):
pass```",output,1,75
loop over files in directory `source`,instruction,0,76
"```for (root, dirs, filenames) in os.walk(source):
for f in filenames:
pass```",output,1,76
create a random list of integers,instruction,0,77
```[int(1000 * random.random()) for i in range(10000)]```,output,1,77
,instruction,0,78
```datetime.datetime.now().strftime('%H:%M:%S.%f')```,output,1,78
Google App Engine execute GQL query 'SELECT * FROM Schedule WHERE station = $1' with parameter `foo.key()`,instruction,0,79
"```db.GqlQuery('SELECT * FROM Schedule WHERE station = $1', foo.key())```",output,1,79
filter rows in pandas starting with alphabet 'f' using regular expression.,instruction,0,80
```df.b.str.contains('^f')```,output,1,80
print a 2 dimensional list `tab` as a table with delimiters,instruction,0,81
```print('\n'.join('\t'.join(str(col) for col in row) for row in tab))```,output,1,81
pandas: delete rows in dataframe `df` based on multiple columns values,instruction,0,82
"```df.set_index(list('BC')).drop(tuples, errors='ignore').reset_index()```",output,1,82
format the variables `self.goals` and `self.penalties` using string formatting,instruction,0,83
"```""""""({:d} goals, ${:d})"""""".format(self.goals, self.penalties)```",output,1,83
"format string ""({} goals, ${})"" with variables `goals` and `penalties`",instruction,0,84
"```""""""({} goals, ${})"""""".format(self.goals, self.penalties)```",output,1,84
"format string ""({0.goals} goals, ${0.penalties})""",instruction,0,85
"```""""""({0.goals} goals, ${0.penalties})"""""".format(self)```",output,1,85
convert list of lists `L` to list of integers,instruction,0,86
```[int(''.join(str(d) for d in x)) for x in L]```,output,1,86
combine elements of each list in list `L` into digits of a single integer,instruction,0,87
```[''.join(str(d) for d in x) for x in L]```,output,1,87
convert a list of lists `L` to list of integers,instruction,0,88
```L = [int(''.join([str(y) for y in x])) for x in L]```,output,1,88
write the elements of list `lines` concatenated by special character '\n' to file `myfile`,instruction,0,89
```myfile.write('\n'.join(lines))```,output,1,89
removing an element from a list based on a predicate 'X' or 'N',instruction,0,90
"```[x for x in ['AAT', 'XAC', 'ANT', 'TTA'] if 'X' not in x and 'N' not in x]```",output,1,90
Remove duplicate words from a string `text` using regex,instruction,0,91
"```text = re.sub('\\b(\\w+)( \\1\\b)+', '\\1', text)```",output,1,91
count non zero values in each column in pandas data frame,instruction,0,92
```df.astype(bool).sum(axis=1)```,output,1,92
search for string that matches regular expression pattern '(?<!Distillr)\\\\AcroTray\\.exe' in string 'C:\\SomeDir\\AcroTray.exe',instruction,0,93
"```re.search('(?<!Distillr)\\\\AcroTray\\.exe', 'C:\\SomeDir\\AcroTray.exe')```",output,1,93
split string 'QH QD JC KD JS' into a list on white spaces,instruction,0,94
"```""""""QH QD JC KD JS"""""".split()```",output,1,94
search for occurrences of regex pattern '>.*<' in xml string `line`,instruction,0,95
"```print(re.search('>.*<', line).group(0))```",output,1,95
erase all the contents of a file `filename`,instruction,0,96
"```open(filename, 'w').close()```",output,1,96
convert a string into datetime using the format '%Y-%m-%d %H:%M:%S.%f',instruction,0,97
"```datetime.datetime.strptime(string_date, '%Y-%m-%d %H:%M:%S.%f')```",output,1,97
find the index of a list with the first element equal to '332' within the list of lists `thelist`,instruction,0,98
"```[index for index, item in enumerate(thelist) if item[0] == '332']```",output,1,98
lower a string `text` and remove non-alphanumeric characters aside from space,instruction,0,99
"```re.sub('[^\\sa-zA-Z0-9]', '', text).lower().strip()```",output,1,99
remove all non-alphanumeric characters except space from a string `text` and lower it,instruction,0,100
"```re.sub('(?!\\s)[\\W_]', '', text).lower().strip()```",output,1,100
subscript text 'H20' with '2' as subscripted in matplotlib labels for arrays 'x' and 'y'.,instruction,0,101
"```plt.plot(x, y, label='H\u2082O')```",output,1,101
subscript text 'H20' with '2' as subscripted in matplotlib labels for arrays 'x' and 'y'.,instruction,0,102
"```plt.plot(x, y, label='$H_2O$')```",output,1,102
loop over a list `mylist` if sublists length equals 3,instruction,0,103
```[x for x in mylist if len(x) == 3]```,output,1,103
initialize a list `lst` of 100 objects Object(),instruction,0,104
```lst = [Object() for _ in range(100)]```,output,1,104
create list `lst` containing 100 instances of object `Object`,instruction,0,105
```lst = [Object() for i in range(100)]```,output,1,105
get the content of child tag with`href` attribute whose parent has css `someclass`,instruction,0,106
```self.driver.find_element_by_css_selector('.someclass a').get_attribute('href')```,output,1,106
joining data from dataframe `df1` with data from dataframe `df2` based on matching values of column 'Date_Time' in both dataframes,instruction,0,107
"```df1.merge(df2, on='Date_Time')```",output,1,107
use `%s` operator to print variable values `str1` inside a string,instruction,0,108
"```'first string is: %s, second one is: %s' % (str1, 'geo.tif')```",output,1,108
,instruction,0,109
```[x.strip() for x in '2.MATCHES $$TEXT$$ STRING'.split('$$TEXT$$')]```,output,1,109
check if directory `directory ` exists and create it if necessary,instruction,0,110
"```if (not os.path.exists(directory)):
os.makedirs(directory)```",output,1,110
check if a directory `path` exists and create it if necessary,instruction,0,111
"```try:
os.makedirs(path)
except OSError:
if (not os.path.isdir(path)):
raise```",output,1,111
check if a directory `path` exists and create it if necessary,instruction,0,112
```distutils.dir_util.mkpath(path)```,output,1,112
check if a directory `path` exists and create it if necessary,instruction,0,113
"```try:
os.makedirs(path)
except OSError as exception:
if (exception.errno != errno.EEXIST):
raise```",output,1,113
Replace a separate word 'H3' by 'H1' in a string 'text',instruction,0,114
"```re.sub('\\bH3\\b', 'H1', text)```",output,1,114
substitute ASCII letters in string 'aas30dsa20' with empty string '',instruction,0,115
"```re.sub('\\D', '', 'aas30dsa20')```",output,1,115
get digits only from a string `aas30dsa20` using lambda function,instruction,0,116
"```"""""""""""".join([x for x in 'aas30dsa20' if x.isdigit()])```",output,1,116
"access a tag called ""name"" in beautifulsoup `soup`",instruction,0,117
```print(soup.find('name').string)```,output,1,117
get a dictionary `records` of key-value pairs in PyMongo cursor `cursor`,instruction,0,118
"```records = dict((record['_id'], record) for record in cursor)```",output,1,118
Create new matrix object by concatenating data from matrix A and matrix B,instruction,0,119
"```np.concatenate((A, B))```",output,1,119
concat two matrices `A` and `B` in numpy,instruction,0,120
"```np.vstack((A, B))```",output,1,120
Get the characters count in a file `filepath`,instruction,0,121
```os.stat(filepath).st_size```,output,1,121
"count the occurrences of item ""a"" in list `l`",instruction,0,122
```l.count('a')```,output,1,122
count the occurrences of items in list `l`,instruction,0,123
```Counter(l)```,output,1,123
count the occurrences of items in list `l`,instruction,0,124
"```[[x, l.count(x)] for x in set(l)]```",output,1,124
count the occurrences of items in list `l`,instruction,0,125
"```dict(((x, l.count(x)) for x in set(l)))```",output,1,125
"count the occurrences of item ""b"" in list `l`",instruction,0,126
```l.count('b')```,output,1,126
copy file `srcfile` to directory `dstdir`,instruction,0,127
"```shutil.copy(srcfile, dstdir)```",output,1,127
find the key associated with the largest value in dictionary `x` whilst key is non-zero value,instruction,0,128
"```max(k for k, v in x.items() if v != 0)```",output,1,128
get the largest key whose not associated with value of 0 in dictionary `x`,instruction,0,129
"```(k for k, v in x.items() if v != 0)```",output,1,129
get the largest key in a dictionary `x` with non-zero value,instruction,0,130
"```max(k for k, v in x.items() if v != 0)```",output,1,130
Put the curser at beginning of the file,instruction,0,131
```file.seek(0)```,output,1,131
combine values from column 'b' and column 'a' of dataframe `df` into column 'c' of datafram `df`,instruction,0,132
"```df['c'] = np.where(df['a'].isnull, df['b'], df['a'])```",output,1,132
remove key 'ele' from dictionary `d`,instruction,0,133
```del d['ele']```,output,1,133
Update datetime field in `MyModel` to be the existing `timestamp` plus 100 years,instruction,0,134
```MyModel.objects.update(timestamp=F('timestamp') + timedelta(days=36524.25))```,output,1,134
merge list `['it']` and list `['was']` and list `['annoying']` into one list,instruction,0,135
```['it'] + ['was'] + ['annoying']```,output,1,135
increment a value with leading zeroes in a number `x`,instruction,0,136
```str(int(x) + 1).zfill(len(x))```,output,1,136
check if a pandas dataframe `df`'s index is sorted,instruction,0,137
```all(df.index[:-1] <= df.index[1:])```,output,1,137
Convert tuple `t` to list,instruction,0,138
```list(t)```,output,1,138
Convert list `t` to tuple,instruction,0,139
```tuple(l)```,output,1,139
Convert tuple `level1` to list,instruction,0,140
"```level1 = map(list, level1)```",output,1,140
send the output of pprint object `dataobject` to file `logFile`,instruction,0,141
"```pprint.pprint(dataobject, logFile)```",output,1,141
get index of rows in column 'BoolCol',instruction,0,142
```df.loc[df['BoolCol']]```,output,1,142
Create a list containing the indexes of rows where the value of column 'BoolCol' in dataframe `df` are equal to True,instruction,0,143
```df.iloc[np.flatnonzero(df['BoolCol'])]```,output,1,143
get list of indexes of rows where column 'BoolCol' values match True,instruction,0,144
```df[df['BoolCol'] == True].index.tolist()```,output,1,144
get index of rows in dataframe `df` which column 'BoolCol' matches value True,instruction,0,145
```df[df['BoolCol']].index.tolist()```,output,1,145
change working directory to the directory `owd`,instruction,0,146
```os.chdir(owd)```,output,1,146
insert data from a string `testfield` to sqlite db `c`,instruction,0,147
"```c.execute(""INSERT INTO test VALUES (?, 'bar')"", (testfield,))```",output,1,147
"decode string ""\\x89\\n"" into a normal string",instruction,0,148
"```""""""\\x89\\n"""""".decode('string_escape')```",output,1,148
convert a raw string `raw_string` into a normal string,instruction,0,149
```raw_string.decode('string_escape')```,output,1,149
convert a raw string `raw_byte_string` into a normal string,instruction,0,150
```raw_byte_string.decode('unicode_escape')```,output,1,150
split a string `s` with into all strings of repeated characters,instruction,0,151
"```[m.group(0) for m in re.finditer('(\\d)\\1*', s)]```",output,1,151
"scatter a plot with x, y position of `np.random.randn(100)` and face color equal to none",instruction,0,152
"```plt.scatter(np.random.randn(100), np.random.randn(100), facecolors='none')```",output,1,152
do a scatter plot with empty circles,instruction,0,153
"```plt.plot(np.random.randn(100), np.random.randn(100), 'o', mfc='none')```",output,1,153
remove a div with a id `main-content` using beautifulsoup,instruction,0,154
"```soup.find('div', id='main-content').decompose()```",output,1,154
filter rows containing key word `ball` in column `ids`,instruction,0,155
```df[df['ids'].str.contains('ball')]```,output,1,155
convert index at level 0 into a column in dataframe `df`,instruction,0,156
"```df.reset_index(level=0, inplace=True)```",output,1,156
Add indexes in a data frame `df` to a column `index1`,instruction,0,157
```df['index1'] = df.index```,output,1,157
convert pandas index in a dataframe to columns,instruction,0,158
"```df.reset_index(level=['tick', 'obs'])```",output,1,158
Get reverse of list items from list 'b' using extended slicing,instruction,0,159
```[x[::-1] for x in b]```,output,1,159
join each element in array `a` with element at the same index in array `b` as a tuple,instruction,0,160
"```np.array([zip(x, y) for x, y in zip(a, b)])```",output,1,160
zip two 2-d arrays `a` and `b`,instruction,0,161
"```np.array(zip(a.ravel(), b.ravel()), dtype='i4,i4').reshape(a.shape)```",output,1,161
convert list `list_of_ints` into a comma separated string,instruction,0,162
"```"""""","""""".join([str(i) for i in list_of_ints])```",output,1,162
Send a post request with raw data `DATA` and basic authentication with `username` and `password`,instruction,0,163
"```requests.post(url, data=DATA, headers=HEADERS_DICT, auth=(username, password))```",output,1,163
"Find last occurrence of character '}' in string ""abcd}def}""",instruction,0,164
```'abcd}def}'.rfind('}')```,output,1,164
"Iterate ove list `[1, 2, 3]` using list comprehension",instruction,0,165
"```print([item for item in [1, 2, 3]])```",output,1,165
extract all the values with keys 'x' and 'y' from a list of dictionaries `d` to list of tuples,instruction,0,166
"```[(x['x'], x['y']) for x in d]```",output,1,166
get the filename without the extension from file 'hemanth.txt',instruction,0,167
```print(os.path.splitext(os.path.basename('hemanth.txt'))[0])```,output,1,167
create a dictionary by adding each two adjacent elements in tuple `x` as key/value pair to it,instruction,0,168
"```dict(x[i:i + 2] for i in range(0, len(x), 2))```",output,1,168
"create a list containing flattened list `[['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']]`",instruction,0,169
"```values = sum([['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']], [])```",output,1,169
select rows in a dataframe `df` column 'closing_price' between two values 99 and 101,instruction,0,170
```df = df[(df['closing_price'] >= 99) & (df['closing_price'] <= 101)]```,output,1,170
replace all occurences of newlines `\n` with `<br>` in dataframe `df`,instruction,0,171
"```df.replace({'\n': '<br>'}, regex=True)```",output,1,171
replace all occurrences of a string `\n` by string `<br>` in a pandas data frame `df`,instruction,0,172
"```df.replace({'\n': '<br>'}, regex=True)```",output,1,172
create a list containing each two adjacent letters in string `word` as its elements,instruction,0,173
"```[(x + y) for x, y in zip(word, word[1:])]```",output,1,173
Get a list of pairs from a string `word` using lambda function,instruction,0,174
"```list(map(lambda x, y: x + y, word[:-1], word[1:]))```",output,1,174
extract a url from a string `myString`,instruction,0,175
"```print(re.findall('(https?://[^\\s]+)', myString))```",output,1,175
extract a url from a string `myString`,instruction,0,176
"```print(re.search('(?P<url>https?://[^\\s]+)', myString).group('url'))```",output,1,176
"remove all special characters, punctuation and spaces from a string `mystring` using regex",instruction,0,177
"```re.sub('[^A-Za-z0-9]+', '', mystring)```",output,1,177
create a DatetimeIndex containing 13 periods of the second friday of each month starting from date '2016-01-01',instruction,0,178
"```pd.date_range('2016-01-01', freq='WOM-2FRI', periods=13)```",output,1,178
Create multidimensional array `matrix` with 3 rows and 2 columns in python,instruction,0,179
"```matrix = [[a, b], [c, d], [e, f]]```",output,1,179
replace spaces with underscore,instruction,0,180
"```mystring.replace(' ', '_')```",output,1,180
get an absolute file path of file 'mydir/myfile.txt',instruction,0,181
```os.path.abspath('mydir/myfile.txt')```,output,1,181
split string `my_string` on white spaces,instruction,0,182
"```"""""" """""".join(my_string.split())```",output,1,182
get filename without extension from file `filename`,instruction,0,183
```os.path.splitext(filename)[0]```,output,1,183
get a list containing the sum of each element `i` in list `l` plus the previous elements,instruction,0,184
"```[sum(l[:i]) for i, _ in enumerate(l)]```",output,1,184
split a string `Docs/src/Scripts/temp` by `/` keeping `/` in the result,instruction,0,185
"```""""""Docs/src/Scripts/temp"""""".replace('/', '/\x00/').split('\x00')```",output,1,185
shuffle columns of an numpy array 'r',instruction,0,186
```np.random.shuffle(np.transpose(r))```,output,1,186
copy all values in a column 'B' to a new column 'D' in a pandas data frame 'df',instruction,0,187
```df['D'] = df['B']```,output,1,187
find a value within nested json 'data' where the key inside another key 'B' is unknown.,instruction,0,188
```list(data['A']['B'].values())[0]['maindata'][0]['Info']```,output,1,188
check characters of string `string` are true predication of function `predicate`,instruction,0,189
```all(predicate(x) for x in string)```,output,1,189
determine number of files on a drive with python,instruction,0,190
```os.statvfs('/').f_files - os.statvfs('/').f_ffree```,output,1,190
,instruction,0,191
```cursor.fetchone()[0]```,output,1,191
convert string `user_input` into a list of integers `user_list`,instruction,0,192
"```user_list = [int(number) for number in user_input.split(',')]```",output,1,192
Get a list of integers by splitting a string `user` with comma,instruction,0,193
"```[int(s) for s in user.split(',')]```",output,1,193
,instruction,0,194
"```sorted(list, key=lambda x: (x[0], -x[1]))```",output,1,194
"sort a list of objects `ut`, based on a function `cmpfun` in descending order",instruction,0,195
"```ut.sort(key=cmpfun, reverse=True)```",output,1,195
reverse list `ut` based on the `count` attribute of each object,instruction,0,196
"```ut.sort(key=lambda x: x.count, reverse=True)```",output,1,196
sort a list of objects `ut` in reverse order by their `count` property,instruction,0,197
"```ut.sort(key=lambda x: x.count, reverse=True)```",output,1,197
click a href button 'Send' with selenium,instruction,0,198
```driver.find_element_by_partial_link_text('Send').click()```,output,1,198
click a href button having text `Send InMail` with selenium,instruction,0,199
```driver.findElement(By.linkText('Send InMail')).click()```,output,1,199
click a href button with text 'Send InMail' with selenium,instruction,0,200
```driver.find_element_by_link_text('Send InMail').click()```,output,1,200
cast an int `i` to a string and concat to string 'ME',instruction,0,201
```'ME' + str(i)```,output,1,201
,instruction,0,202
"```df.sort_values(['System_num', 'Dis'])```",output,1,202
prepend the line '#test firstline\n' to the contents of file 'infile' and save as the file 'outfile',instruction,0,203
"```open('outfile', 'w').write('#test firstline\n' + open('infile').read())```",output,1,203
sort a list `l` by length of value in tuple,instruction,0,204
"```l.sort(key=lambda t: len(t[1]), reverse=True)```",output,1,204
split string `s` by words that ends with 'd',instruction,0,205
"```re.findall('\\b(\\w+)d\\b', s)```",output,1,205
return `True` if string `foobarrrr` contains regex `ba[rzd]`,instruction,0,206
"```bool(re.search('ba[rzd]', 'foobarrrr'))```",output,1,206
Removing duplicates in list `t`,instruction,0,207
```list(set(t))```,output,1,207
Removing duplicates in list `source_list`,instruction,0,208
```list(set(source_list))```,output,1,208
Removing duplicates in list `abracadabra`,instruction,0,209
```list(OrderedDict.fromkeys('abracadabra'))```,output,1,209
Convert array `a` into a list,instruction,0,210
```numpy.array(a).reshape(-1).tolist()```,output,1,210
Convert the first row of numpy matrix `a` to a list,instruction,0,211
```numpy.array(a)[0].tolist()```,output,1,211
"In `soup`, get the content of the sibling of the `td` tag with text content `Address:`",instruction,0,212
```print(soup.find(text='Address:').findNext('td').contents[0])```,output,1,212
convert elements of each tuple in list `l` into a string separated by character `@`,instruction,0,213
"```"""""" """""".join([('%d@%d' % t) for t in l])```",output,1,213
convert each tuple in list `l` to a string with '@' separating the tuples' elements,instruction,0,214
"```"""""" """""".join([('%d@%d' % (t[0], t[1])) for t in l])```",output,1,214
get the html from the current web page of a Selenium driver,instruction,0,215
```driver.execute_script('return document.documentElement.outerHTML;')```,output,1,215
Get all matches with regex pattern `\\d+[xX]` in list of string `teststr`,instruction,0,216
"```[i for i in teststr if re.search('\\d+[xX]', i)]```",output,1,216
"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
```df['A'][(df['B'] > 50) & (df['C'] == 900)]```,output,1,217
Sort dictionary `o` in ascending order based on its keys and items,instruction,0,218
```sorted(o.items())```,output,1,218
get sorted list of keys of dict `d`,instruction,0,219
```sorted(d)```,output,1,219
,instruction,0,220
```sorted(d.items())```,output,1,220
"convert string ""1"" into integer",instruction,0,221
```int('1')```,output,1,221
function to convert strings into integers,instruction,0,222
```int()```,output,1,222
convert items in `T1` to integers,instruction,0,223
"```T2 = [map(int, x) for x in T1]```",output,1,223
call a shell script `./test.sh` using subprocess,instruction,0,224
```subprocess.call(['./test.sh'])```,output,1,224
call a shell script `notepad` using subprocess,instruction,0,225
```subprocess.call(['notepad'])```,output,1,225
combine lists `l1` and `l2` by alternating their elements,instruction,0,226
"```[val for pair in zip(l1, l2) for val in pair]```",output,1,226
encode string 'data to be encoded',instruction,0,227
```encoded = base64.b64encode('data to be encoded')```,output,1,227
encode a string `data to be encoded` to `ascii` encoding,instruction,0,228
```encoded = 'data to be encoded'.encode('ascii')```,output,1,228
parse tab-delimited CSV file 'text.txt' into a list,instruction,0,229
"```lol = list(csv.reader(open('text.txt', 'rb'), delimiter='\t'))```",output,1,229
Get attribute `my_str` of object `my_object`,instruction,0,230
"```getattr(my_object, my_str)```",output,1,230
group a list of dicts `LD` into one dict by key,instruction,0,231
"```print(dict(zip(LD[0], zip(*[list(d.values()) for d in LD]))))```",output,1,231
,instruction,0,232
```sum([pair[0] for pair in list_of_pairs])```,output,1,232
"convert unicode string u""{'code1':1,'code2':1}"" into dictionary",instruction,0,233
"```d = ast.literal_eval(""{'code1':1,'code2':1}"")```",output,1,233
find all words in a string `mystring` that start with the `$` sign,instruction,0,234
```[word for word in mystring.split() if word.startswith('$')]```,output,1,234
remove any url within string `text`,instruction,0,235
"```text = re.sub('^https?:\\/\\/.*[\\r\\n]*', '', text, flags=re.MULTILINE)```",output,1,235
"replace all elements in array `A` that are not present in array `[1, 3, 4]` with zeros",instruction,0,236
"```np.where(np.in1d(A, [1, 3, 4]).reshape(A.shape), A, 0)```",output,1,236
calculate mean across dimension in a 2d array `a`,instruction,0,237
"```np.mean(a, axis=1)```",output,1,237
running r script '/pathto/MyrScript.r' from python,instruction,0,238
"```subprocess.call(['/usr/bin/Rscript', '--vanilla', '/pathto/MyrScript.r'])```",output,1,238
run r script '/usr/bin/Rscript --vanilla /pathto/MyrScript.r',instruction,0,239
"```subprocess.call('/usr/bin/Rscript --vanilla /pathto/MyrScript.r', shell=True)```",output,1,239
add a header to a csv file,instruction,0,240
```writer.writeheader()```,output,1,240
replacing nan in the dataframe `df` with row average,instruction,0,241
"```df.fillna(df.mean(axis=1), axis=1)```",output,1,241
Convert unix timestamp '1347517370' to formatted string '%Y-%m-%d %H:%M:%S',instruction,0,242
"```time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(1347517370))```",output,1,242
Call a base class's class method `do` from derived class `Derived`,instruction,0,243
"```super(Derived, cls).do(a)```",output,1,243
"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
"```a[np.where((a[:, (0)] == 0) * (a[:, (1)] == 1))]```",output,1,244
separate words delimited by one or more spaces into a list,instruction,0,245
"```re.split(' +', 'hello world sample text')```",output,1,245
length of longest element in list `words`,instruction,0,246
"```len(max(words, key=len))```",output,1,246
get the value associated with unicode key 'from_user' of first dictionary in list `result`,instruction,0,247
```result[0]['from_user']```,output,1,247
Retrieve each line from a file 'File.txt' as a list,instruction,0,248
```[line.split() for line in open('File.txt')]```,output,1,248
swap keys with values in a dictionary `a`,instruction,0,249
"```res = dict((v, k) for k, v in a.items())```",output,1,249
Open a file `path/to/FILE_NAME.ext` in write mode,instruction,0,250
"```new_file = open('path/to/FILE_NAME.ext', 'w')```",output,1,250
,instruction,0,251
"```df.groupby(['col1', 'col2'])['col3'].nunique().reset_index()```",output,1,251
Check if any key in the dictionary `dict1` starts with the string `EMP$$`,instruction,0,252
```any(key.startswith('EMP$$') for key in dict1)```,output,1,252
create list of values from dictionary `dict1` that have a key that starts with 'EMP$$',instruction,0,253
"```[value for key, value in list(dict1.items()) if key.startswith('EMP$$')]```",output,1,253
convert a pandas series `sf` into a pandas dataframe `df` with columns `email` and `list`,instruction,0,254
"```pd.DataFrame({'email': sf.index, 'list': sf.values})```",output,1,254
print elements of list `list` seperated by tabs `\t`,instruction,0,255
"```print('\t'.join(map(str, list)))```",output,1,255
print unicode string '\xd0\xbf\xd1\x80\xd0\xb8' with utf-8,instruction,0,256
```print('\xd0\xbf\xd1\x80\xd0\xb8'.encode('raw_unicode_escape'))```,output,1,256
Encode a latin character in string `Sopet\xc3\xb3n` properly,instruction,0,257
```'Sopet\xc3\xb3n'.encode('latin-1').decode('utf-8')```,output,1,257
"resized image `image` to width, height of `(x, y)` with filter of `ANTIALIAS`",instruction,0,258
"```image = image.resize((x, y), Image.ANTIALIAS)```",output,1,258
"regex, find ""n""s only in the middle of string `s`",instruction,0,259
"```re.findall('n(?<=[^n]n)n+(?=[^n])(?i)', s)```",output,1,259
display the float `1/3*100` as a percentage,instruction,0,260
```print('{0:.0f}%'.format(1.0 / 3 * 100))```,output,1,260
sort a list of dictionary `mylist` by the key `title`,instruction,0,261
```mylist.sort(key=lambda x: x['title'])```,output,1,261
sort a list `l` of dicts by dict value 'title',instruction,0,262
```l.sort(key=lambda x: x['title'])```,output,1,262
"sort a list of dictionaries by the value of keys 'title', 'title_url', 'id' in ascending order.",instruction,0,263
"```l.sort(key=lambda x: (x['title'], x['title_url'], x['id']))```",output,1,263
find 10 largest differences between each respective elements of list `l1` and list `l2`,instruction,0,264
"```heapq.nlargest(10, range(len(l1)), key=lambda i: abs(l1[i] - l2[i]))```",output,1,264
BeautifulSoup find all 'span' elements in HTML string `soup` with class of 'starGryB sp',instruction,0,265
"```soup.find_all('span', {'class': 'starGryB sp'})```",output,1,265
write records in dataframe `df` to table 'test' in schema 'a_schema',instruction,0,266
"```df.to_sql('test', engine, schema='a_schema')```",output,1,266
Extract brackets from string `s`,instruction,0,267
"```brackets = re.sub('[^(){}[\\]]', '', s)```",output,1,267
remove duplicate elements from list 'L',instruction,0,268
"```list(dict((x[0], x) for x in L).values())```",output,1,268
read a file `file` without newlines,instruction,0,269
```[line.rstrip('\n') for line in file]```,output,1,269
get the position of item 1 in `testlist`,instruction,0,270
"```[i for (i, x) in enumerate(testlist) if (x == 1)]```",output,1,270
get the position of item 1 in `testlist`,instruction,0,271
"```[i for (i, x) in enumerate(testlist) if (x == 1)]```",output,1,271
get the position of item 1 in `testlist`,instruction,0,272
"```for i in [i for (i, x) in enumerate(testlist) if (x == 1)]:
pass```",output,1,272
get the position of item 1 in `testlist`,instruction,0,273
"```for i in (i for (i, x) in enumerate(testlist) if (x == 1)):
pass```",output,1,273
get the position of item 1 in `testlist`,instruction,0,274
"```gen = (i for (i, x) in enumerate(testlist) if (x == 1))
for i in gen:
pass```",output,1,274
get the position of item `element` in list `testlist`,instruction,0,275
```print(testlist.index(element))```,output,1,275
get the position of item `element` in list `testlist`,instruction,0,276
"```try:
print(testlist.index(element))
except ValueError:
pass```",output,1,276
find the first element of the tuple with the maximum second element in a list of tuples `lis`,instruction,0,277
"```max(lis, key=lambda item: item[1])[0]```",output,1,277
get the item at index 0 from the tuple that has maximum value at index 1 in list `lis`,instruction,0,278
"```max(lis, key=itemgetter(1))[0]```",output,1,278
Make a delay of 1 second,instruction,0,279
```time.sleep(1)```,output,1,279
convert list of tuples `L` to a string,instruction,0,280
"```"""""", """""".join('(' + ', '.join(i) + ')' for i in L)```",output,1,280
Django set default value of field `b` equal to '0000000',instruction,0,281
"```b = models.CharField(max_length=7, default='0000000', editable=False)```",output,1,281
Sort lis `list5` in ascending order based on the degrees value of its elements,instruction,0,282
"```sorted(list5, lambda x: (degree(x), x))```",output,1,282
,instruction,0,283
"```sorted(list5, key=lambda vertex: (degree(vertex), vertex))```",output,1,283
convert a list into a generator object,instruction,0,284
"```(n for n in [1, 2, 3, 5])```",output,1,284
remove elements from list `oldlist` that have an index number mentioned in list `removelist`,instruction,0,285
"```newlist = [v for i, v in enumerate(oldlist) if i not in removelist]```",output,1,285
Open a file `yourfile.txt` in write mode,instruction,0,286
"```f = open('yourfile.txt', 'w')```",output,1,286
get attribute 'attr' from object `obj`,instruction,0,287
"```getattr(obj, 'attr')```",output,1,287
"convert tuple of tuples `(('aa',), ('bb',), ('cc',))` to tuple",instruction,0,288
"```from functools import reduce
reduce(lambda a, b: a + b, (('aa',), ('bb',), ('cc',)))```",output,1,288
"convert tuple of tuples `(('aa',), ('bb',), ('cc',))` to list in one line",instruction,0,289
"```map(lambda a: a[0], (('aa',), ('bb',), ('cc',)))```",output,1,289
,instruction,0,290
"```df['range'].replace(',', '-', inplace=True)```",output,1,290
"unzip the list `[('a', 1), ('b', 2), ('c', 3), ('d', 4)]`",instruction,0,291
"```zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)])```",output,1,291
"unzip the list `[('a', 1), ('b', 2), ('c', 3), ('d', 4)]`",instruction,0,292
"```zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4)])```",output,1,292
unzip list `original`,instruction,0,293
"```result = ([a for (a, b) in original], [b for (a, b) in original])```",output,1,293
unzip list `original` and return a generator,instruction,0,294
"```result = ((a for (a, b) in original), (b for (a, b) in original))```",output,1,294
"unzip list `[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', )]`",instruction,0,295
"```zip(*[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e',)])```",output,1,295
"unzip list `[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e', )]` and fill empty results with None",instruction,0,296
"```map(None, *[('a', 1), ('b', 2), ('c', 3), ('d', 4), ('e',)])```",output,1,296
encode `Decimal('3.9')` to a JSON string,instruction,0,297
```json.dumps(Decimal('3.9'))```,output,1,297
"Add key ""mynewkey"" to dictionary `d` with value ""mynewvalue""",instruction,0,298
```d['mynewkey'] = 'mynewvalue'```,output,1,298
Add key 'a' to dictionary `data` with value 1,instruction,0,299
"```data.update({'a': 1, })```",output,1,299
Add key 'a' to dictionary `data` with value 1,instruction,0,300
```data.update(dict(a=1))```,output,1,300
Add key 'a' to dictionary `data` with value 1,instruction,0,301
```data.update(a=1)```,output,1,301
find maximal value in matrix `matrix`,instruction,0,302
```max([max(i) for i in matrix])```,output,1,302
Round number `answer` to 2 precision after the decimal point,instruction,0,303
"```answer = str(round(answer, 2))```",output,1,303
extract ip address from an html string,instruction,0,304
"```ip = re.findall('[0-9]+(?:\\.[0-9]+){3}', s)```",output,1,304
filter dataframe `df` by values in column `A` that appear more than once,instruction,0,305
```df.groupby('A').filter(lambda x: len(x) > 1)```,output,1,305
append each line in file `myfile` into a list,instruction,0,306
```[x for x in myfile.splitlines() if x != '']```,output,1,306
Get a list of integers `lst` from a file `filename.txt`,instruction,0,307
"```lst = map(int, open('filename.txt').readlines())```",output,1,307
add color bar with image `mappable` to plot `plt`,instruction,0,308
"```plt.colorbar(mappable=mappable, cax=ax3)```",output,1,308
count most frequent 100 words in column 'text' of dataframe `df`,instruction,0,309
```Counter(' '.join(df['text']).split()).most_common(100)```,output,1,309
,instruction,0,310
"```re.findall('(.+?):(.+?)\\b ?', text)```",output,1,310
"generate all 2-element subsets of tuple `(1, 2, 3)`",instruction,0,311
"```list(itertools.combinations((1, 2, 3), 2))```",output,1,311
get a value of datetime.today() in the UTC time zone,instruction,0,312
```datetime.now(pytz.utc)```,output,1,312
Get a new list `list2`by removing empty list from a list of lists `list1`,instruction,0,313
```list2 = [x for x in list1 if x != []]```,output,1,313
Create `list2` to contain the lists from list `list1` excluding the empty lists from `list1`,instruction,0,314
```list2 = [x for x in list1 if x]```,output,1,314
Django response with JSON `data`,instruction,0,315
"```return HttpResponse(data, mimetype='application/json')```",output,1,315
get all text that is not enclosed within square brackets in string `example_str`,instruction,0,316
"```re.findall('(.*?)\\[.*?\\]', example_str)```",output,1,316
Use a regex to get all text in a string `example_str` that is not surrounded by square brackets,instruction,0,317
"```re.findall('(.*?)(?:\\[.*?\\]|$)', example_str)```",output,1,317
"get whatever is between parentheses as a single match, and any char outside as an individual match in string '(zyx)bc'",instruction,0,318
"```re.findall('\\(.+?\\)|\\w', '(zyx)bc')```",output,1,318
match regex '\\((.*?)\\)|(\\w)' with string '(zyx)bc',instruction,0,319
"```re.findall('\\((.*?)\\)|(\\w)', '(zyx)bc')```",output,1,319
match multiple regex patterns with the alternation operator `|` in a string `(zyx)bc`,instruction,0,320
"```re.findall('\\(.*?\\)|\\w', '(zyx)bc')```",output,1,320
formate each string cin list `elements` into pattern '%{0}%',instruction,0,321
```elements = ['%{0}%'.format(element) for element in elements]```,output,1,321
Open a background process 'background-process' with arguments 'arguments',instruction,0,322
"```subprocess.Popen(['background-process', 'arguments'])```",output,1,322
get list of values from dictionary 'mydict' w.r.t. list of keys 'mykeys',instruction,0,323
```[mydict[x] for x in mykeys]```,output,1,323
"convert list `[('Name', 'Joe'), ('Age', 22)]` into a dictionary",instruction,0,324
"```dict([('Name', 'Joe'), ('Age', 22)])```",output,1,324
average each two columns of array `data`,instruction,0,325
"```data.reshape(-1, j).mean(axis=1).reshape(data.shape[0], -1)```",output,1,325
double backslash escape all double quotes in string `s`,instruction,0,326
"```print(s.encode('unicode-escape').replace('""', '\\""'))```",output,1,326
split a string into a list of words and whitespace,instruction,0,327
"```re.split('(\\W+)', s)```",output,1,327
,instruction,0,328
"```df.plot(kind='barh', stacked=True)```",output,1,328
reverse the keys and values in a dictionary `myDictionary`,instruction,0,329
```{i[1]: i[0] for i in list(myDictionary.items())}```,output,1,329
finding the index of elements containing substring 'how' and 'what' in a list of strings 'myList'.,instruction,0,330
"```[i for i, j in enumerate(myList) if 'how' in j.lower() or 'what' in j.lower()]```",output,1,330
check if object `obj` is a string,instruction,0,331
"```isinstance(obj, str)```",output,1,331
check if object `o` is a string,instruction,0,332
"```isinstance(o, str)```",output,1,332
check if object `o` is a string,instruction,0,333
```(type(o) is str)```,output,1,333
check if object `o` is a string,instruction,0,334
"```isinstance(o, str)```",output,1,334
check if `obj_to_test` is a string,instruction,0,335
"```isinstance(obj_to_test, str)```",output,1,335
append list `list1` to `list2`,instruction,0,336
```list2.extend(list1)```,output,1,336
append list `mylog` to `list1`,instruction,0,337
```list1.extend(mylog)```,output,1,337
append list `a` to `c`,instruction,0,338
```c.extend(a)```,output,1,338
append items in list `mylog` to `list1`,instruction,0,339
"```for line in mylog:
list1.append(line)```",output,1,339
append a tuple of elements from list `a` with indexes '[0][0] [0][2]' to list `b`,instruction,0,340
"```b.append((a[0][0], a[0][2]))```",output,1,340
Initialize `SECRET_KEY` in flask config with `Your_secret_string `,instruction,0,341
```app.config['SECRET_KEY'] = 'Your_secret_string'```,output,1,341
unpack a series of tuples in pandas into a DataFrame with column names 'out-1' and 'out-2',instruction,0,342
"```pd.DataFrame(out.tolist(), columns=['out-1', 'out-2'], index=out.index)```",output,1,342
find the index of an element 'MSFT' in a list `stocks_list`,instruction,0,343
```[x for x in range(len(stocks_list)) if stocks_list[x] == 'MSFT']```,output,1,343
rotate the xtick labels of matplotlib plot `ax` by `45` degrees to make long labels readable,instruction,0,344
"```ax.set_xticklabels(labels, rotation=45)```",output,1,344
remove symbols from a string `s`,instruction,0,345
"```re.sub('[^\\w]', ' ', s)```",output,1,345
Get the current directory of a script,instruction,0,346
```os.path.basename(os.path.dirname(os.path.realpath(__file__)))```,output,1,346
Find octal characters matches from a string `str` using regex,instruction,0,347
"```print(re.findall(""'\\\\[0-7]{1,3}'"", str))```",output,1,347
split string `input` based on occurrences of regex pattern '[ ](?=[A-Z]+\\b)',instruction,0,348
"```re.split('[ ](?=[A-Z]+\\b)', input)```",output,1,348
Split string `input` at every space followed by an upper-case letter,instruction,0,349
"```re.split('[ ](?=[A-Z])', input)```",output,1,349
send multipart encoded file `files` to url `url` with headers `headers` and metadata `data`,instruction,0,350
"```r = requests.post(url, files=files, headers=headers, data=data)```",output,1,350
write bytes `bytes_` to a file `filename` in python 3,instruction,0,351
"```open('filename', 'wb').write(bytes_)```",output,1,351
get a list from a list `lst` with values mapped into a dictionary `dct`,instruction,0,352
```[dct[k] for k in lst]```,output,1,352
find duplicate names in column 'name' of the dataframe `x`,instruction,0,353
```x.set_index('name').index.get_duplicates()```,output,1,353
truncate float 1.923328437452 to 3 decimal places,instruction,0,354
"```round(1.923328437452, 3)```",output,1,354
sort list `li` in descending order based on the date value in second element of each list in list `li`,instruction,0,355
"```sorted(li, key=lambda x: datetime.strptime(x[1], '%d/%m/%Y'), reverse=True)```",output,1,355
place the radial ticks in plot `ax` at 135 degrees,instruction,0,356
```ax.set_rlabel_position(135)```,output,1,356
check if path `my_path` is an absolute path,instruction,0,357
```os.path.isabs(my_path)```,output,1,357
get number of keys in dictionary `yourdict`,instruction,0,358
```len(list(yourdict.keys()))```,output,1,358
count the number of keys in dictionary `yourdictfile`,instruction,0,359
```len(set(open(yourdictfile).read().split()))```,output,1,359
pandas dataframe get first row of each group by 'id',instruction,0,360
```df.groupby('id').first()```,output,1,360
split a list in first column into multiple columns keeping other columns as well in pandas data frame,instruction,0,361
"```pd.concat([df[0].apply(pd.Series), df[1]], axis=1)```",output,1,361
"extract attributes 'src=""js/([^""]*\\bjquery\\b[^""]*)""' from string `data`",instruction,0,362
"```re.findall('src=""js/([^""]*\\bjquery\\b[^""]*)""', data)```",output,1,362
"Sum integers contained in strings in list `['', '3.4', '', '', '1.0']`",instruction,0,363
"```sum(int(float(item)) for item in [_f for _f in ['', '3.4', '', '', '1.0'] if _f])```",output,1,363
Call a subprocess with arguments `c:\\Program Files\\VMware\\VMware Server\\vmware-cmd.bat` that may contain spaces,instruction,0,364
```subprocess.Popen(['c:\\Program Files\\VMware\\VMware Server\\vmware-cmd.bat'])```,output,1,364
reverse a priority queue `q` in python without using classes,instruction,0,365
"```q.put((-n, n))```",output,1,365
make a barplot of data in column `group` of dataframe `df` colour-coded according to list `color`,instruction,0,366
"```df['group'].plot(kind='bar', color=['r', 'g', 'b', 'r', 'g', 'b', 'r'])```",output,1,366
find all matches of regex pattern '([a-fA-F\\d]{32})' in string `data`,instruction,0,367
"```re.findall('([a-fA-F\\d]{32})', data)```",output,1,367
Get the length of list `my_list`,instruction,0,368
```len(my_list)```,output,1,368
Getting the length of array `l`,instruction,0,369
```len(l)```,output,1,369
Getting the length of array `s`,instruction,0,370
```len(s)```,output,1,370
Getting the length of `my_tuple`,instruction,0,371
```len(my_tuple)```,output,1,371
Getting the length of `my_string`,instruction,0,372
```len(my_string)```,output,1,372
"remove escape character from string ""\\a""",instruction,0,373
"```""""""\\a"""""".decode('string_escape')```",output,1,373
replace each 'a' with 'b' and each 'b' with 'a' in the string 'obama' in a single pass.,instruction,0,374
"```""""""obama"""""".replace('a', '%temp%').replace('b', 'a').replace('%temp%', 'b')```",output,1,374
remove directory tree '/folder_name',instruction,0,375
```shutil.rmtree('/folder_name')```,output,1,375
create a new column `weekday` in pandas data frame `data` based on the values in column `my_dt`,instruction,0,376
```data['weekday'] = data['my_dt'].apply(lambda x: x.weekday())```,output,1,376
reverse sort Counter `x` by values,instruction,0,377
"```sorted(x, key=x.get, reverse=True)```",output,1,377
reverse sort counter `x` by value,instruction,0,378
"```sorted(list(x.items()), key=lambda pair: pair[1], reverse=True)```",output,1,378
append a numpy array 'b' to a numpy array 'a',instruction,0,379
"```np.vstack((a, b))```",output,1,379
numpy concatenate two arrays `a` and `b` along the first axis,instruction,0,380
"```print(concatenate((a, b), axis=0))```",output,1,380
numpy concatenate two arrays `a` and `b` along the second axis,instruction,0,381
"```print(concatenate((a, b), axis=1))```",output,1,381
numpy concatenate two arrays `a` and `b` along the first axis,instruction,0,382
"```c = np.r_[(a[None, :], b[None, :])]```",output,1,382
numpy concatenate two arrays `a` and `b` along the first axis,instruction,0,383
"```np.array((a, b))```",output,1,383
fetch address information for host 'google.com' ion port 80,instruction,0,384
"```print(socket.getaddrinfo('google.com', 80))```",output,1,384
add a column 'day' with value 'sat' to dataframe `df`,instruction,0,385
"```df.xs('sat', level='day', drop_level=False)```",output,1,385
return a 401 unauthorized in django,instruction,0,386
"```return HttpResponse('Unauthorized', status=401)```",output,1,386
Flask set folder 'wherever' as the default template folder,instruction,0,387
"```Flask(__name__, template_folder='wherever')```",output,1,387
How do I INSERT INTO t1 (SELECT * FROM t2) in SQLAlchemy?,instruction,0,388
```session.execute('INSERT INTO t1 (SELECT * FROM t2)')```,output,1,388
sort a list of lists 'c2' such that third row comes first,instruction,0,389
```c2.sort(key=lambda row: row[2])```,output,1,389
,instruction,0,390
"```c2.sort(key=lambda row: (row[2], row[1], row[0]))```",output,1,390
,instruction,0,391
"```c2.sort(key=lambda row: (row[2], row[1]))```",output,1,391
set font `Arial` to display non-ascii characters in matplotlib,instruction,0,392
"```matplotlib.rc('font', **{'sans-serif': 'Arial', 'family': 'sans-serif'})```",output,1,392
Convert DateTime column 'date' of pandas dataframe 'df' to ordinal,instruction,0,393
```df['date'].apply(lambda x: x.toordinal())```,output,1,393
get html source of Selenium WebElement `element`,instruction,0,394
```element.get_attribute('innerHTML')```,output,1,394
Get the integer location of a key `bob` in a pandas data frame,instruction,0,395
```df.index.get_loc('bob')```,output,1,395
open a 'gnome' terminal from python script and run 'sudo apt-get update' command.,instruction,0,396
"```os.system('gnome-terminal -e \'bash -c ""sudo apt-get update; exec bash""\'')```",output,1,396
add an item with key 'third_key' and value 1 to an dictionary `my_dict`,instruction,0,397
```my_dict.update({'third_key': 1})```,output,1,397
declare an array,instruction,0,398
```my_list = []```,output,1,398
Insert item `12` to a list `my_list`,instruction,0,399
```my_list.append(12)```,output,1,399
add an entry 'wuggah' at the beginning of list `myList`,instruction,0,400
"```myList.insert(0, 'wuggah')```",output,1,400
convert a hex-string representation to actual bytes,instruction,0,401
"```""""""\\xF3\\xBE\\x80\\x80"""""".replace('\\x', '').decode('hex')```",output,1,401
select the last column of dataframe `df`,instruction,0,402
```df[df.columns[-1]]```,output,1,402
get the first value from dataframe `df` where column 'Letters' is equal to 'C',instruction,0,403
"```df.loc[df['Letters'] == 'C', 'Letters'].values[0]```",output,1,403
"converting two lists `[1, 2, 3]` and `[4, 5, 6]` into a matrix",instruction,0,404
"```np.column_stack(([1, 2, 3], [4, 5, 6]))```",output,1,404
get the type of `i`,instruction,0,405
```type(i)```,output,1,405
determine the type of variable `v`,instruction,0,406
```type(v)```,output,1,406
determine the type of variable `v`,instruction,0,407
```type(v)```,output,1,407
determine the type of variable `v`,instruction,0,408
```type(v)```,output,1,408
determine the type of variable `v`,instruction,0,409
```type(v)```,output,1,409
get the type of variable `variable_name`,instruction,0,410
```print(type(variable_name))```,output,1,410
get the 5th item of a generator,instruction,0,411
"```next(itertools.islice(range(10), 5, 5 + 1))```",output,1,411
Print a string `word` with string format,instruction,0,412
"```print('""{}""'.format(word))```",output,1,412
join a list of strings `list` using a space ' ',instruction,0,413
"```"""""" """""".join(list)```",output,1,413
create list `y` containing two empty lists,instruction,0,414
```y = [[] for n in range(2)]```,output,1,414
read a file 'C:/name/MyDocuments/numbers' into a list `data`,instruction,0,415
"```data = [line.strip() for line in open('C:/name/MyDocuments/numbers', 'r')]```",output,1,415
delete all occurrences of character 'i' in string 'it is icy',instruction,0,416
"```"""""""""""".join([char for char in 'it is icy' if char != 'i'])```",output,1,416
delete all instances of a character 'i' in a string 'it is icy',instruction,0,417
"```re.sub('i', '', 'it is icy')```",output,1,417
"delete all characters ""i"" in string ""it is icy""",instruction,0,418
"```""""""it is icy"""""".replace('i', '')```",output,1,418
,instruction,0,419
"```"""""""""""".join([char for char in 'it is icy' if char != 'i'])```",output,1,419
"Drop rows of pandas dataframe `df` having NaN in column at index ""1""",instruction,0,420
```df.dropna(subset=[1])```,output,1,420
"get elements from list `myList`, that have a field `n` value 30",instruction,0,421
```[x for x in myList if x.n == 30]```,output,1,421
converting list of strings `intstringlist` to list of integer `nums`,instruction,0,422
```nums = [int(x) for x in intstringlist]```,output,1,422
convert list of string numbers into list of integers,instruction,0,423
"```map(int, eval(input('Enter the unfriendly numbers: ')))```",output,1,423
"print ""."" without newline",instruction,0,424
```sys.stdout.write('.')```,output,1,424
round off the float that is the product of `2.52 * 100` and convert it to an int,instruction,0,425
```int(round(2.51 * 100))```,output,1,425
"Find all files in directory ""/mydir"" with extension "".txt""",instruction,0,426
"```os.chdir('/mydir')
for file in glob.glob('*.txt'):
pass```",output,1,426
"Find all files in directory ""/mydir"" with extension "".txt""",instruction,0,427
"```for file in os.listdir('/mydir'):
if file.endswith('.txt'):
pass```",output,1,427
"Find all files in directory ""/mydir"" with extension "".txt""",instruction,0,428
"```for (root, dirs, files) in os.walk('/mydir'):
for file in files:
if file.endswith('.txt'):
pass```",output,1,428
plot dataframe `df` without a legend,instruction,0,429
```df.plot(legend=False)```,output,1,429
"loop through the IP address range ""192.168.x.x""",instruction,0,430
"```for i in range(256):
for j in range(256):
ip = ('192.168.%d.%d' % (i, j))
print(ip)```",output,1,430
"loop through the IP address range ""192.168.x.x""",instruction,0,431
"```for (i, j) in product(list(range(256)), list(range(256))):
pass```",output,1,431
"loop through the IP address range ""192.168.x.x""",instruction,0,432
"```generator = iter_iprange('192.168.1.1', '192.168.255.255', step=1)```",output,1,432
Sum the corresponding decimal values for binary values of each boolean element in list `x`,instruction,0,433
"```sum(1 << i for i, b in enumerate(x) if b)```",output,1,433
"write multiple strings `line1`, `line2` and `line3` in one line in a file `target`",instruction,0,434
"```target.write('%r\n%r\n%r\n' % (line1, line2, line3))```",output,1,434
Convert list of lists `data` into a flat list,instruction,0,435
"```[y for x in data for y in (x if isinstance(x, list) else [x])]```",output,1,435
Print new line character as `\n` in a string `foo\nbar`,instruction,0,436
```print('foo\nbar'.encode('string_escape'))```,output,1,436
"remove last comma character ',' in string `s`",instruction,0,437
"```"""""""""""".join(s.rsplit(',', 1))```",output,1,437
calculate the mean of each element in array `x` with the element previous to it,instruction,0,438
```(x[1:] + x[:-1]) / 2```,output,1,438
get an array of the mean of each two consecutive values in numpy array `x`,instruction,0,439
```x[:-1] + (x[1:] - x[:-1]) / 2```,output,1,439
load data containing `utf-8` from file `new.txt` into numpy array `arr`,instruction,0,440
"```arr = numpy.fromiter(codecs.open('new.txt', encoding='utf-8'), dtype='<U2')```",output,1,440
reverse sort list of dicts `l` by value for key `time`,instruction,0,441
"```l = sorted(l, key=itemgetter('time'), reverse=True)```",output,1,441
Sort a list of dictionary `l` based on key `time` in descending order,instruction,0,442
"```l = sorted(l, key=lambda a: a['time'], reverse=True)```",output,1,442
get rows of dataframe `df` that match regex '(Hel|Just)',instruction,0,443
```df.loc[df[0].str.contains('(Hel|Just)')]```,output,1,443
"find the string in `your_string` between two special characters ""["" and ""]""",instruction,0,444
"```re.search('\\[(.*)\\]', your_string).group(1)```",output,1,444
,instruction,0,445
"```[d.strftime('%Y%m%d') for d in pandas.date_range('20130226', '20130302')]```",output,1,445
count number of times string 'brown' occurred in string 'The big brown fox is brown',instruction,0,446
"```""""""The big brown fox is brown"""""".count('brown')```",output,1,446
decode json string `request.body` to python dict,instruction,0,447
```json.loads(request.body)```,output,1,447
download the file from url `url` and save it under file `file_name`,instruction,0,448
"```urllib.request.urlretrieve(url, file_name)```",output,1,448
split string `text` by space,instruction,0,449
```text.split()```,output,1,449
"split string `text` by "",""",instruction,0,450
"```text.split(',')```",output,1,450
Split string `line` into a list by whitespace,instruction,0,451
```line.split()```,output,1,451
replace dot characters '.' associated with ascii letters in list `s` with space ' ',instruction,0,452
"```[re.sub('(?<!\\d)\\.(?!\\d)', ' ', i) for i in s]```",output,1,452
sort list `list_of_strings` based on second index of each string `s`,instruction,0,453
"```sorted(list_of_strings, key=lambda s: s.split(',')[1])```",output,1,453
call multiple bash function ‘vasp’ and ‘tee tee_output’ using ‘|’,instruction,0,454
"```subprocess.check_call('vasp | tee tee_output', shell=True)```",output,1,454
eliminate all strings from list `lst`,instruction,0,455
"```[element for element in lst if isinstance(element, int)]```",output,1,455
get all the elements except strings from the list 'lst'.,instruction,0,456
"```[element for element in lst if not isinstance(element, str)]```",output,1,456
Sort a list of dictionaries `list_to_be_sorted` by the value of the dictionary key `name`,instruction,0,457
"```newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])```",output,1,457
sort a list of dictionaries `l` by values in key `name` in descending order,instruction,0,458
"```newlist = sorted(l, key=itemgetter('name'), reverse=True)```",output,1,458
,instruction,0,459
```list_of_dicts.sort(key=operator.itemgetter('name'))```,output,1,459
,instruction,0,460
```list_of_dicts.sort(key=operator.itemgetter('age'))```,output,1,460
,instruction,0,461
"```df.groupby('prots').sum().sort('scores', ascending=False)```",output,1,461
"join together with "","" elements inside a list indexed with 'category' within a dictionary `trans`",instruction,0,462
"```"""""","""""".join(trans['category'])```",output,1,462
"concatenate array of strings `['A', 'B', 'C', 'D']` into a string",instruction,0,463
"```"""""""""""".join(['A', 'B', 'C', 'D'])```",output,1,463
get json data from restful service 'url',instruction,0,464
```json.load(urllib.request.urlopen('url'))```,output,1,464
Remove all strings from a list a strings `sents` where the values starts with `@$\t` or `#`,instruction,0,465
```[x for x in sents if not x.startswith('@$\t') and not x.startswith('#')]```,output,1,465
django filter by hour,instruction,0,466
```Entry.objects.filter(pub_date__contains='08:00')```,output,1,466
sort a list of dictionary `list` first by key `points` and then by `time`,instruction,0,467
"```list.sort(key=lambda item: (item['points'], item['time']))```",output,1,467
"convert datetime object `(1970, 1, 1)` to seconds",instruction,0,468
"```(t - datetime.datetime(1970, 1, 1)).total_seconds()```",output,1,468
insert `_suff` before the file extension in `long.file.name.jpg` or replace `_a` with `suff` if it precedes the extension.,instruction,0,469
"```re.sub('(\\_a)?\\.([^\\.]*)$', '_suff.\\2', 'long.file.name.jpg')```",output,1,469
reload a module `module`,instruction,0,470
"```import imp
imp.reload(module)```",output,1,470
Convert integer `number` into an unassigned integer,instruction,0,471
"```struct.unpack('H', struct.pack('h', number))```",output,1,471
convert int values in list `numlist` to float,instruction,0,472
```numlist = [float(x) for x in numlist]```,output,1,472
"write dataframe `df`, excluding index, to a csv file",instruction,0,473
"```df.to_csv(filename, index=False)```",output,1,473
convert a urllib unquoted string `unescaped` to a json data `json_data`,instruction,0,474
```json_data = json.loads(unescaped)```,output,1,474
Create a list containing all ascii characters as its elements,instruction,0,475
```[chr(i) for i in range(127)]```,output,1,475
write `newFileBytes` to a binary file `newFile`,instruction,0,476
"```newFile.write(struct.pack('5B', *newFileBytes))```",output,1,476
python regex - check for a capital letter with a following lowercase in string `string`,instruction,0,477
"```re.sub('^[A-Z0-9]*(?![a-z])', '', string)```",output,1,477
get the last key of dictionary `dict`,instruction,0,478
```list(dict.keys())[-1]```,output,1,478
"write line ""hi there"" to file `f`",instruction,0,479
"```print('hi there', file=f)```",output,1,479
"write line ""hi there"" to file `myfile`",instruction,0,480
"```f = open('myfile', 'w')
f.write('hi there\n')
f.close()```",output,1,480
"write line ""Hello"" to file `somefile.txt`",instruction,0,481
"```with open('somefile.txt', 'a') as the_file:
the_file.write('Hello\n')```",output,1,481
convert unicode string `s` to ascii,instruction,0,482
```s.encode('iso-8859-15')```,output,1,482
Django get maximum value associated with field 'added' in model `AuthorizedEmail`,instruction,0,483
```AuthorizedEmail.objects.filter(group=group).order_by('-added')[0]```,output,1,483
Find all numbers and dots from a string `text` using regex,instruction,0,484
"```re.findall('Test([0-9.]*[0-9]+)', text)```",output,1,484
python regex to find all numbers and dots from 'text',instruction,0,485
"```re.findall('Test([\\d.]*\\d+)', text)```",output,1,485
execute script 'script.ps1' using 'powershell.exe' shell,instruction,0,486
"```os.system('powershell.exe', 'script.ps1')```",output,1,486
Sort a list of tuples `b` by third item in the tuple,instruction,0,487
```b.sort(key=lambda x: x[1][2])```,output,1,487
get a list of all keys in Cassandra database `cf` with pycassa,instruction,0,488
```list(cf.get_range().get_keys())```,output,1,488
create a datetime with the current date & time,instruction,0,489
```datetime.datetime.now()```,output,1,489
get the index of an integer `1` from a list `lst` if the list also contains boolean items,instruction,0,490
"```next(i for i, x in enumerate(lst) if not isinstance(x, bool) and x == 1)```",output,1,490
subtract 13 from every number in a list `a`,instruction,0,491
```a[:] = [(x - 13) for x in a]```,output,1,491
"choose a random file from the directory contents of the C drive, `C:\\`",instruction,0,492
```random.choice(os.listdir('C:\\'))```,output,1,492
get the highest element in absolute value in a numpy matrix `x`,instruction,0,493
"```max(x.min(), x.max(), key=abs)```",output,1,493
Get all urls within text `s`,instruction,0,494
"```re.findall('""(http.*?)""', s, re.MULTILINE | re.DOTALL)```",output,1,494
match urls whose domain doesn't start with `t` from string `document` using regex,instruction,0,495
"```re.findall('http://[^t][^s""]+\\.html', document)```",output,1,495
split a string `mystring` considering the spaces ' ',instruction,0,496
"```mystring.replace(' ', '! !').split('!')```",output,1,496
open file `path` with mode 'r',instruction,0,497
"```open(path, 'r')```",output,1,497
sum elements at the same index in list `data`,instruction,0,498
```[[sum(item) for item in zip(*items)] for items in zip(*data)]```,output,1,498
add a new axis to array `a`,instruction,0,499
"```a[:, (np.newaxis)]```",output,1,499