question_id
stringlengths
7
12
nl
stringlengths
4
200
cmd
stringlengths
2
232
oracle_man
sequence
canonical_cmd
stringlengths
2
228
cmd_name
stringclasses
1 value
38388799-16
sort list `list_of_strings` based on second index of each string `s`
sorted(list_of_strings, key=lambda s: s.split(',')[1])
[ "python.library.functions#sorted", "python.library.stdtypes#str.split" ]
sorted(VAR_STR, key=lambda VAR_STR: VAR_STR.split(',')[1])
conala
9609375-86
call multiple bash function ‘vasp’ and ‘tee tee_output’ using ‘|’
subprocess.check_call('vasp | tee tee_output', shell=True)
[ "python.library.subprocess#subprocess.check_call" ]
subprocess.check_call('vasp | tee tee_output', shell=True)
conala
37004138-32
eliminate all strings from list `lst`
[element for element in lst if isinstance(element, int)]
[ "python.library.functions#isinstance" ]
[element for element in VAR_STR if isinstance(element, int)]
conala
37004138-83
get all the elements except strings from the list 'lst'.
[element for element in lst if not isinstance(element, str)]
[ "python.library.functions#isinstance" ]
[element for element in VAR_STR if not isinstance(element, str)]
conala
72899-95
Sort a list of dictionaries `list_to_be_sorted` by the value of the dictionary key `name`
newlist = sorted(list_to_be_sorted, key=lambda k: k['name'])
[ "python.library.functions#sorted" ]
newlist = sorted(VAR_STR, key=lambda k: k['VAR_STR'])
conala
72899-6
sort a list of dictionaries `l` by values in key `name` in descending order
newlist = sorted(l, key=itemgetter('name'), reverse=True)
[ "python.library.functions#sorted", "python.library.operator#operator.itemgetter" ]
newlist = sorted(VAR_STR, key=itemgetter('VAR_STR'), reverse=True)
conala
72899-76
How do I sort a list of dictionaries by values of the dictionary in Python?
list_of_dicts.sort(key=operator.itemgetter('name'))
[ "python.library.operator#operator.itemgetter", "python.library.stdtypes#list.sort" ]
list_of_dicts.sort(key=operator.itemgetter('name'))
conala
72899-59
How do I sort a list of dictionaries by values of the dictionary in Python?
list_of_dicts.sort(key=operator.itemgetter('age'))
[ "python.library.operator#operator.itemgetter", "python.library.stdtypes#list.sort" ]
list_of_dicts.sort(key=operator.itemgetter('age'))
conala
29881993-76
join together with "," elements inside a list indexed with 'category' within a dictionary `trans`
""",""".join(trans['category'])
[ "python.library.stdtypes#str.join" ]
"""VAR_STR""".join(VAR_STR['VAR_STR'])
conala
34158494-93
concatenate array of strings `['A', 'B', 'C', 'D']` into a string
"""""".join(['A', 'B', 'C', 'D'])
[ "python.library.stdtypes#str.join" ]
"""""".join([VAR_STR])
conala
12666897-36
Remove all strings from a list a strings `sents` where the values starts with `@$\t` or `#`
[x for x in sents if not x.startswith('@$\t') and not x.startswith('#')]
[ "python.library.stdtypes#str.startswith" ]
[x for x in VAR_STR if not x.startswith('VAR_STR') and not x.startswith('VAR_STR')]
conala
7852855-99
convert datetime object `(1970, 1, 1)` to seconds
(t - datetime.datetime(1970, 1, 1)).total_seconds()
[ "python.library.datetime#datetime.timedelta.total_seconds" ]
(t - datetime.datetime(VAR_STR)).total_seconds()
conala
2763750-47
insert `_suff` before the file extension in `long.file.name.jpg` or replace `_a` with `suff` if it precedes the extension.
re.sub('(\\_a)?\\.([^\\.]*)$', '_suff.\\2', 'long.file.name.jpg')
[ "python.library.re#re.sub" ]
re.sub('(\\_a)?\\.([^\\.]*)$', '_suff.\\2', 'VAR_STR')
conala
6420361-29
reload a module `module`
import imp imp.reload(module)
[ "python.library.importlib#importlib.reload" ]
import imp imp.reload(VAR_STR)
conala
9746522-1
convert int values in list `numlist` to float
numlist = [float(x) for x in numlist]
[ "python.library.functions#float" ]
VAR_STR = [float(x) for x in VAR_STR]
conala
5891453-34
Create a list containing all ascii characters as its elements
[chr(i) for i in range(127)]
[ "python.library.functions#chr", "python.library.functions#range" ]
[chr(i) for i in range(127)]
conala
21805490-69
python regex - check for a capital letter with a following lowercase in string `string`
re.sub('^[A-Z0-9]*(?![a-z])', '', string)
[ "python.library.re#re.sub" ]
re.sub('^[A-Z0-9]*(?![a-z])', '', VAR_STR)
conala
6159900-4
write line "hi there" to file `f`
print('hi there', file=f)
[]
print('VAR_STR', file=VAR_STR)
conala
6159900-27
write line "hi there" to file `myfile`
f = open('myfile', 'w') f.write('hi there\n') f.close()
[ "python.library.urllib.request#open", "python.library.os#os.write" ]
f = open('VAR_STR', 'w') f.write('hi there\n') f.close()
conala
6159900-68
write line "Hello" to file `somefile.txt`
with open('somefile.txt', 'a') as the_file: the_file.write('Hello\n')
[ "python.library.urllib.request#open", "python.library.os#os.write" ]
with open('VAR_STR', 'a') as the_file: the_file.write('Hello\n')
conala
19527279-73
convert unicode string `s` to ascii
s.encode('iso-8859-15')
[ "python.library.stdtypes#str.encode" ]
VAR_STR.encode('iso-8859-15')
conala
356483-47
Find all numbers and dots from a string `text` using regex
re.findall('Test([0-9.]*[0-9]+)', text)
[ "python.library.re#re.findall" ]
re.findall('Test([0-9.]*[0-9]+)', VAR_STR)
conala
356483-68
python regex to find all numbers and dots from 'text'
re.findall('Test([\\d.]*\\d+)', text)
[ "python.library.re#re.findall" ]
re.findall('Test([\\d.]*\\d+)', VAR_STR)
conala
38081866-23
execute script 'script.ps1' using 'powershell.exe' shell
os.system('powershell.exe', 'script.ps1')
[ "python.library.os#os.system" ]
os.system('VAR_STR', 'VAR_STR')
conala
7349646-41
Sort a list of tuples `b` by third item in the tuple
b.sort(key=lambda x: x[1][2])
[ "python.library.stdtypes#list.sort" ]
VAR_STR.sort(key=lambda x: x[1][2])
conala
2430539-37
get a list of all keys in Cassandra database `cf` with pycassa
list(cf.get_range().get_keys())
[ "python.library.functions#list" ]
list(VAR_STR.get_range().get_keys())
conala
30843103-34
get the index of an integer `1` from a list `lst` if the list also contains boolean items
next(i for i, x in enumerate(lst) if not isinstance(x, bool) and x == 1)
[ "python.library.functions#isinstance", "python.library.functions#enumerate", "python.library.functions#next" ]
next(i for i, x in enumerate(VAR_STR) if not isinstance(x, bool) and x == 1)
conala
4918425-91
subtract 13 from every number in a list `a`
a[:] = [(x - 13) for x in a]
[]
VAR_STR[:] = [(x - 13) for x in VAR_STR]
conala
701402-88
choose a random file from the directory contents of the C drive, `C:\\`
random.choice(os.listdir('C:\\'))
[ "python.library.random#random.choice", "python.library.os#os.listdir" ]
random.choice(os.listdir('VAR_STR'))
conala
30551576-22
Get all urls within text `s`
re.findall('"(http.*?)"', s, re.MULTILINE | re.DOTALL)
[ "python.library.re#re.findall" ]
re.findall('"(http.*?)"', VAR_STR, re.MULTILINE | re.DOTALL)
conala
30551576-58
match urls whose domain doesn't start with `t` from string `document` using regex
re.findall('http://[^t][^s"]+\\.html', document)
[ "python.library.re#re.findall" ]
re.findall('http://[^t][^s"]+\\.html', VAR_STR)
conala
113534-21
split a string `mystring` considering the spaces ' '
mystring.replace(' ', '! !').split('!')
[ "python.library.stdtypes#str.replace", "python.library.stdtypes#str.split" ]
VAR_STR.replace(' ', '! !').split('!')
conala
5838735-0
open file `path` with mode 'r'
open(path, 'r')
[ "python.library.urllib.request#open" ]
open(VAR_STR, 'VAR_STR')
conala
36003967-69
sum elements at the same index in list `data`
[[sum(item) for item in zip(*items)] for items in zip(*data)]
[ "python.library.functions#zip", "python.library.functions#sum" ]
[[sum(item) for item in zip(*items)] for items in zip(*VAR_STR)]
conala
7635237-89
add a new axis to array `a`
a[:, (np.newaxis)]
[]
VAR_STR[:, (np.newaxis)]
conala