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
15286401-72
print string including multiple variables `name` and `score`
print(('Total score for', name, 'is', score))
[]
print(('Total score for', VAR_STR, 'is', VAR_STR))
conala
455612-84
print float `a` with two decimal points
print(('%.2f' % a))
[]
print('%.2f' % VAR_STR)
conala
455612-33
print float `a` with two decimal points
print(('{0:.2f}'.format(a)))
[ "python.library.functions#format" ]
print('{0:.2f}'.format(VAR_STR))
conala
455612-78
print float `a` with two decimal points
print(('{0:.2f}'.format(round(a, 2))))
[ "python.library.functions#round", "python.library.functions#format" ]
print('{0:.2f}'.format(round(VAR_STR, 2)))
conala
455612-39
print float `a` with two decimal points
print(('%.2f' % round(a, 2)))
[ "python.library.functions#round" ]
print('%.2f' % round(VAR_STR, 2))
conala
455612-31
limit float 13.9499999 to two decimal points
('%.2f' % 13.9499999)
[]
'%.2f' % 13.9499999
conala
455612-37
limit float 3.14159 to two decimal points
('%.2f' % 3.14159)
[]
'%.2f' % 3.14159
conala
455612-21
limit float 13.949999999999999 to two decimal points
float('{0:.2f}'.format(13.95))
[ "python.library.functions#float", "python.library.functions#format" ]
float('{0:.2f}'.format(13.95))
conala
455612-19
limit float 13.949999999999999 to two decimal points
'{0:.2f}'.format(13.95)
[ "python.library.functions#format" ]
"""{0:.2f}""".format(13.95)
conala
4287209-80
sort list of strings in list `the_list` by integer suffix
sorted(the_list, key=lambda k: int(k.split('_')[1]))
[ "python.library.functions#sorted", "python.library.functions#int", "python.library.stdtypes#str.split" ]
sorted(VAR_STR, key=lambda k: int(k.split('_')[1]))
conala
4287209-74
sort list of strings `the_list` by integer suffix before "_"
sorted(the_list, key=lambda x: int(x.split('_')[1]))
[ "python.library.functions#sorted", "python.library.functions#int", "python.library.stdtypes#str.split" ]
sorted(VAR_STR, key=lambda x: int(x.split('VAR_STR')[1]))
conala
8671702-94
pass a list of parameters `((1, 2, 3),) to sql queue 'SELECT * FROM table WHERE column IN %s;'
cur.mogrify('SELECT * FROM table WHERE column IN %s;', ((1, 2, 3),))
[]
cur.mogrify('VAR_STR', ((1, 2, 3),))
conala
3804727-58
flush output of python print
sys.stdout.flush()
[ "python.library.logging#logging.Handler.flush" ]
sys.stdout.flush()
conala
4664850-7
find indexes of all occurrences of a substring `tt` in a string `ttt`
[m.start() for m in re.finditer('(?=tt)', 'ttt')]
[ "python.library.re#re.finditer", "python.library.re#re.Match.start" ]
[m.start() for m in re.finditer('(?=tt)', 'VAR_STR')]
conala
4664850-33
find all occurrences of a substring in a string
[m.start() for m in re.finditer('test', 'test test test test')]
[ "python.library.re#re.finditer", "python.library.re#re.Match.start" ]
[m.start() for m in re.finditer('test', 'test test test test')]
conala
6740311-53
join Numpy array `b` with Numpy array 'a' along axis 0
b = np.concatenate((a, a), axis=0)
[ "numpy.reference.generated.numpy.concatenate" ]
VAR_STR = np.concatenate((VAR_STR, VAR_STR), axis=0)
conala
41256648-47
select multiple ranges of columns 1-10, 15, 17, and 50-100 in pandas dataframe `df`
df.iloc[:, (np.r_[1:10, (15), (17), 50:100])]
[]
VAR_STR.iloc[:, (np.r_[1:10, (15), (17), 50:100])]
conala
8654637-6
fetch all elements in a dictionary `parent_dict`, falling between two keys 2 and 4
dict((k, v) for k, v in parent_dict.items() if 2 < k < 4)
[ "python.library.stdtypes#dict", "python.library.stdtypes#dict.items" ]
dict((k, v) for k, v in VAR_STR.items() if 2 < k < 4)
conala
8654637-44
fetch all elements in a dictionary 'parent_dict' where the key is between the range of 2 to 4
dict((k, v) for k, v in parent_dict.items() if k > 2 and k < 4)
[ "python.library.stdtypes#dict", "python.library.stdtypes#dict.items" ]
dict((k, v) for k, v in VAR_STR.items() if k > 2 and k < 4)
conala
19641579-81
concatenate strings in tuple `('a', 'b', 'c', 'd', 'g', 'x', 'r', 'e')` into a single string
"""""".join(('a', 'b', 'c', 'd', 'g', 'x', 'r', 'e'))
[ "python.library.stdtypes#str.join" ]
"""""".join((VAR_STR))
conala
9072844-100
check if string `the_string` contains any upper or lower-case ASCII letters
re.search('[a-zA-Z]', the_string)
[ "python.library.re#re.search" ]
re.search('[a-zA-Z]', VAR_STR)
conala
1962795-99
get alpha value `alpha` of a png image `img`
alpha = img.split()[-1]
[ "python.library.stdtypes#str.split" ]
VAR_STR = VAR_STR.split()[-1]
conala
902761-90
save a numpy array `image_array` as an image 'outfile.jpg'
scipy.misc.imsave('outfile.jpg', image_array)
[ "matplotlib.image_api#matplotlib.image.imsave" ]
scipy.misc.imsave('VAR_STR', VAR_STR)
conala
6710684-100
delete the last column of numpy array `a` and assign resulting array to `b`
b = np.delete(a, -1, 1)
[ "numpy.reference.generated.numpy.delete" ]
VAR_STR = np.delete(VAR_STR, -1, 1)
conala
10677350-1
Convert float 24322.34 to comma-separated string
"""{0:,.2f}""".format(24322.34)
[ "python.library.functions#format" ]
"""{0:,.2f}""".format(24322.34)
conala
5061582-64
Setting stacksize in a python script
os.system('ulimit -s unlimited; some_executable')
[ "python.library.os#os.system" ]
os.system('ulimit -s unlimited; some_executable')
conala
961263-25
assign values to two variables, `var1` and `var2` from user input response to `'Enter two numbers here: ` split on whitespace
var1, var2 = input('Enter two numbers here: ').split()
[ "python.library.functions#input", "python.library.stdtypes#str.split" ]
VAR_STR, VAR_STR = input('Enter two numbers here: ').split()
conala
3220755-78
get canonical path of the filename `path`
os.path.realpath(path)
[ "python.library.os.path#os.path.realpath" ]
os.VAR_STR.realpath(VAR_STR)
conala
30357276-39
fill missing value in one column 'Cat1' with the value of another column 'Cat2'
df['Cat1'].fillna(df['Cat2'])
[ "pandas.reference.api.pandas.dataframe.fillna" ]
df['VAR_STR'].fillna(df['VAR_STR'])
conala
19069701-24
request URI '<MY_URI>' and pass authorization token 'TOK:<MY_TOKEN>' to the header
r = requests.get('<MY_URI>', headers={'Authorization': 'TOK:<MY_TOKEN>'})
[ "python.library.webbrowser#webbrowser.get" ]
r = requests.get('VAR_STR', headers={'Authorization': 'VAR_STR'})
conala
53513-86
check if list `a` is empty
if (not a): pass
[]
if not VAR_STR: pass
conala
53513-49
check if list `seq` is empty
if (not seq): pass
[]
if not VAR_STR: pass
conala
53513-83
check if list `li` is empty
if (len(li) == 0): pass
[ "python.library.functions#len" ]
if len(VAR_STR) == 0: pass
conala
5927180-86
Extract values not equal to 0 from numpy array `a`
a[a != 0]
[]
VAR_STR[VAR_STR != 0]
conala
5864485-86
print a string `s` by splitting with comma `,`
print(s.split(','))
[ "python.library.stdtypes#str.split" ]
print(VAR_STR.split('VAR_STR'))
conala
5864485-36
Create list by splitting string `mystring` using "," as delimiter
mystring.split(',')
[ "python.library.stdtypes#str.split" ]
VAR_STR.split('VAR_STR')
conala
40196941-40
remove periods inbetween capital letters that aren't immediately preceeded by word character(s) in a string `s` using regular expressions
re.sub('(?<!\\w)([A-Z])\\.', '\\1', s)
[ "python.library.re#re.sub" ]
re.sub('(?<!\\w)([A-Z])\\.', '\\1', VAR_STR)
conala
4365964-71
Construct an array with data type float32 `a` from data in binary file 'filename'
a = numpy.fromfile('filename', dtype=numpy.float32)
[ "numpy.reference.generated.numpy.fromfile" ]
VAR_STR = numpy.fromfile('VAR_STR', dtype=numpy.float32)
conala
22749706-34
How to get the length of words in a sentence?
[len(x) for x in s.split()]
[ "python.library.functions#len", "python.library.stdtypes#str.split" ]
[len(x) for x in s.split()]
conala
29703793-83
get a string `randomkey123xyz987` between two substrings in a string `api('randomkey123xyz987', 'key', 'text')` using regex
re.findall("api\\('(.*?)'", "api('randomkey123xyz987', 'key', 'text')")
[ "python.library.re#re.findall" ]
re.findall("api\\('(.*?)'", 'VAR_STR')
conala
16568056-66
create a list of aggregation of each element from list `l2` to all elements of list `l1`
[(x + y) for x in l2 for y in l1]
[]
[(x + y) for x in VAR_STR for y in VAR_STR]
conala
16176996-7
get date from dataframe `df` column 'dates' to column 'just_date'
df['just_date'] = df['dates'].dt.date
[]
VAR_STR['VAR_STR'] = VAR_STR['VAR_STR'].dt.date
conala
17038639-32
sort a list `your_list` of class objects by their values for the attribute `anniversary_score`
your_list.sort(key=operator.attrgetter('anniversary_score'))
[ "python.library.operator#operator.attrgetter", "python.library.stdtypes#list.sort" ]
VAR_STR.sort(key=operator.attrgetter('VAR_STR'))
conala
17038639-24
sort list `your_list` by the `anniversary_score` attribute of each object
your_list.sort(key=lambda x: x.anniversary_score)
[ "python.library.stdtypes#list.sort" ]
VAR_STR.sort(key=lambda x: x.VAR_STR)
conala
373459-40
split string 'a b.c' on space " " and dot character "."
re.split('[ .]', 'a b.c')
[ "python.library.re#re.split" ]
re.split('[ .]', 'VAR_STR')
conala
19384532-12
count number of rows in a group `key_columns` in pandas groupby object `df`
df.groupby(key_columns).size()
[ "pandas.reference.api.pandas.dataframe.groupby", "pandas.reference.api.pandas.dataframe.size" ]
VAR_STR.groupby(VAR_STR).size()
conala
8337004-51
Print +1 using format '{0:+d}'
print('{0:+d}'.format(score))
[ "python.library.functions#format" ]
print('VAR_STR'.format(score))
conala
26541968-79
delete every non `utf-8` characters from a string `line`
line = line.decode('utf-8', 'ignore').encode('utf-8')
[ "python.library.stdtypes#str.encode", "python.library.stdtypes#bytearray.decode" ]
VAR_STR = VAR_STR.decode('VAR_STR', 'ignore').encode('VAR_STR')
conala
22245171-54
lowercase a python dataframe string in column 'x' if it has missing values in dataframe `df`
df['x'].str.lower()
[ "python.library.stdtypes#str.lower" ]
VAR_STR['VAR_STR'].str.lower()
conala
13384841-37
swap values in a tuple/list inside a list `mylist`
map(lambda t: (t[1], t[0]), mylist)
[ "python.library.functions#map" ]
map(lambda t: (t[1], t[0]), VAR_STR)
conala
13384841-49
Swap values in a tuple/list in list `mylist`
[(t[1], t[0]) for t in mylist]
[]
[(t[1], t[0]) for t in VAR_STR]
conala
33565643-86
Set index equal to field 'TRX_DATE' in dataframe `df`
df = df.set_index(['TRX_DATE'])
[ "pandas.reference.api.pandas.dataframe.set_index" ]
VAR_STR = VAR_STR.set_index(['VAR_STR'])
conala
17109608-36
change figure size to 3 by 4 in matplotlib
plt.figure(figsize=(3, 4))
[ "matplotlib.figure_api#matplotlib.figure.Figure" ]
plt.figure(figsize=(3, 4))
conala
11040626-65
add column `d` to index of dataframe `df`
df.set_index(['d'], append=True)
[ "pandas.reference.api.pandas.dataframe.set_index" ]
VAR_STR.set_index(['VAR_STR'], append=True)
conala
587345-88
create a regular expression that matches the pattern '^(.+)(?:\\n|\\r\\n?)((?:(?:\\n|\\r\\n?).+)+)' over multiple lines of text
re.compile('^(.+)(?:\\n|\\r\\n?)((?:(?:\\n|\\r\\n?).+)+)', re.MULTILINE)
[ "python.library.re#re.compile" ]
re.compile('VAR_STR', re.MULTILINE)
conala
587345-23
regular expression "^(.+)\\n((?:\\n.+)+)" matching a multiline block of text
re.compile('^(.+)\\n((?:\\n.+)+)', re.MULTILINE)
[ "python.library.re#re.compile" ]
re.compile('VAR_STR', re.MULTILINE)
conala
2600775-7
get equivalent week number from a date `2010/6/16` using isocalendar
datetime.date(2010, 6, 16).isocalendar()[1]
[ "python.library.datetime#datetime.date", "python.library.datetime#datetime.date.isocalendar" ]
datetime.date(2010, 6, 16).isocalendar()[1]
conala
5180365-48
format floating point number `TotalAmount` to be rounded off to two decimal places and have a comma thousands' seperator
print('Total cost is: ${:,.2f}'.format(TotalAmount))
[ "python.library.functions#format" ]
print('Total cost is: ${:,.2f}'.format(VAR_STR))
conala
464736-72
split string 'abcdefg' into a list of characters
re.findall('\\w', 'abcdefg')
[ "python.library.re#re.findall" ]
re.findall('\\w', 'VAR_STR')
conala
18071222-58
set columns `['race_date', 'track_code', 'race_number']` as indexes in dataframe `rdata`
rdata.set_index(['race_date', 'track_code', 'race_number'])
[ "pandas.reference.api.pandas.dataframe.set_index" ]
VAR_STR.set_index([VAR_STR])
conala
3008992-74
replace a string `Abc` in case sensitive way using maketrans
"""Abc""".translate(maketrans('abcABC', 'defDEF'))
[ "python.library.stdtypes#str.maketrans", "python.library.stdtypes#str.translate" ]
"""VAR_STR""".translate(maketrans('abcABC', 'defDEF'))
conala
25040875-80
get a list of values with key 'key' from a list of dictionaries `l`
[d['key'] for d in l if 'key' in d]
[]
[d['VAR_STR'] for d in VAR_STR if 'VAR_STR' in d]
conala
25040875-99
get a list of values for key 'key' from a list of dictionaries `l`
[d['key'] for d in l]
[]
[d['VAR_STR'] for d in VAR_STR]
conala
25040875-16
get a list of values for key "key" from a list of dictionaries in `l`
[d['key'] for d in l]
[]
[d['VAR_STR'] for d in VAR_STR]
conala
3899980-30
change the font size on plot `matplotlib` to 22
matplotlib.rcParams.update({'font.size': 22})
[ "matplotlib.figure_api#matplotlib.figure.SubplotParams.update" ]
VAR_STR.rcParams.update({'font.size': 22})
conala
16233593-48
replace comma in string `s` with empty string ''
s = s.replace(',', '')
[ "python.library.stdtypes#str.replace" ]
VAR_STR = VAR_STR.replace(',', 'VAR_STR')
conala
39607540-52
get the count of each unique value in column `Country` of dataframe `df` and store in column `Sum of Accidents`
df.Country.value_counts().reset_index(name='Sum of Accidents')
[ "pandas.reference.api.pandas.dataframe.reset_index", "pandas.reference.api.pandas.dataframe.value_counts" ]
VAR_STR.VAR_STR.value_counts().reset_index(name='VAR_STR')
conala
9001509-32
sort dictionary `d` by key
od = collections.OrderedDict(sorted(d.items()))
[ "python.library.collections#collections.OrderedDict", "python.library.functions#sorted", "python.library.stdtypes#dict.items" ]
od = collections.OrderedDict(sorted(VAR_STR.items()))
conala
9001509-28
sort a dictionary `d` by key
OrderedDict(sorted(list(d.items()), key=(lambda t: t[0])))
[ "python.library.functions#sorted", "python.library.functions#list", "python.library.collections#collections.OrderedDict", "python.library.stdtypes#dict.items" ]
OrderedDict(sorted(list(VAR_STR.items()), key=lambda t: t[0]))
conala
30546889-40
get dictionary with max value of key 'size' in list of dicts `ld`
max(ld, key=lambda d: d['size'])
[ "python.library.functions#max" ]
max(VAR_STR, key=lambda d: d['VAR_STR'])
conala
12739911-21
create a dictionary containing each string in list `my_list` split by '=' as a key/value pairs
print(dict([s.split('=') for s in my_list]))
[ "python.library.stdtypes#dict", "python.library.stdtypes#str.split" ]
print(dict([s.split('VAR_STR') for s in VAR_STR]))
conala
2514961-92
remove all values within one list `[2, 3, 7]` from another list `a`
[x for x in a if x not in [2, 3, 7]]
[]
[x for x in VAR_STR if x not in [VAR_STR]]
conala
32296933-71
remove all duplicates from a list of sets `L`
list(set(frozenset(item) for item in L))
[ "python.library.stdtypes#frozenset", "python.library.functions#list", "python.library.stdtypes#set" ]
list(set(frozenset(item) for item in VAR_STR))
conala
32296933-32
remove duplicates from a list of sets 'L'
[set(item) for item in set(frozenset(item) for item in L)]
[ "python.library.stdtypes#set", "python.library.stdtypes#frozenset" ]
[set(item) for item in set(frozenset(item) for item in VAR_STR)]
conala
41067960-51
Concatenate elements of a list 'x' of multiple integers to a single integer
sum(d * 10 ** i for i, d in enumerate(x[::-1]))
[ "python.library.functions#enumerate", "python.library.functions#sum" ]
sum(d * 10 ** i for i, d in enumerate(VAR_STR[::-1]))
conala
41067960-57
convert a list of integers into a single integer
r = int(''.join(map(str, x)))
[ "python.library.functions#int", "python.library.functions#map", "python.library.stdtypes#str.join" ]
r = int(''.join(map(str, x)))
conala
19454970-33
create dict of squared int values in range of 100
{(x ** 2) for x in range(100)}
[ "python.library.functions#range" ]
{(x ** 2) for x in range(100)}
conala
9534608-97
get complete path of a module named `os`
imp.find_module('os')[1]
[ "python.library.zipimport#zipimport.zipimporter.find_module" ]
imp.find_module('VAR_STR')[1]
conala
276052-11
get current CPU and RAM usage
psutil.cpu_percent() psutil.virtual_memory()
[]
psutil.cpu_percent() psutil.virtual_memory()
conala
276052-21
get current RAM usage of current program
pid = os.getpid() py = psutil.Process(pid) memoryUse = (py.memory_info()[0] / (2.0 ** 30))
[ "python.library.os#os.getpid", "python.library.multiprocessing#multiprocessing.Process" ]
pid = os.getpid() py = psutil.Process(pid) memoryUse = py.memory_info()[0] / 2.0 ** 30
conala
276052-66
print cpu and memory usage
print((psutil.cpu_percent())) print((psutil.virtual_memory()))
[]
print(psutil.cpu_percent()) print(psutil.virtual_memory())
conala
39821166-6
given list `to_reverse`, reverse the all sublists and the list itself
[sublist[::-1] for sublist in to_reverse[::-1]]
[]
[sublist[::-1] for sublist in VAR_STR[::-1]]
conala
7571635-38
check if 7 is in `a`
(7 in a)
[]
7 in VAR_STR
conala
7571635-96
check if 'a' is in list `a`
('a' in a)
[]
'VAR_STR' in VAR_STR
conala
8139797-27
extract table data from table `rows` using beautifulsoup
[[td.findNext(text=True) for td in tr.findAll('td')] for tr in rows]
[ "python.library.re#re.findall" ]
[[td.findNext(text=True) for td in tr.findAll('td')] for tr in VAR_STR]
conala
14299978-48
find element `a` that contains string "TEXT A" in file `root`
e = root.xpath('.//a[contains(text(),"TEXT A")]')
[]
e = VAR_STR.xpath('.//a[contains(text(),"TEXT A")]')
conala
14299978-16
Find the`a` tag in html `root` which starts with the text `TEXT A` and assign it to `e`
e = root.xpath('.//a[starts-with(text(),"TEXT A")]')
[]
VAR_STR = VAR_STR.xpath('.//a[starts-with(text(),"TEXT A")]')
conala
14299978-52
find the element that holds string 'TEXT A' in file `root`
e = root.xpath('.//a[text()="TEXT A"]')
[]
e = VAR_STR.xpath('.//a[text()="TEXT A"]')
conala
31818050-79
round number `x` to nearest integer
int(round(x))
[ "python.library.functions#int", "python.library.functions#round" ]
int(round(VAR_STR))
conala
31818050-74
round number `h` to nearest integer
h = int(round(h))
[ "python.library.functions#int", "python.library.functions#round" ]
VAR_STR = int(round(VAR_STR))
conala
31818050-9
round number 32.268907563 up to 3 decimal points
round(32.268907563, 3)
[ "python.library.functions#round" ]
round(32.268907563, 3)
conala
31818050-24
round number `value` up to `significantDigit` decimal places
round(value, significantDigit)
[ "python.library.functions#round" ]
round(VAR_STR, VAR_STR)
conala
31818050-19
round number 1.0005 up to 3 decimal places
round(1.0005, 3)
[ "python.library.functions#round" ]
round(1.0005, 3)
conala
31818050-37
round number 2.0005 up to 3 decimal places
round(2.0005, 3)
[ "python.library.functions#round" ]
round(2.0005, 3)
conala
31818050-47
round number 3.0005 up to 3 decimal places
round(3.0005, 3)
[ "python.library.functions#round" ]
round(3.0005, 3)
conala
31818050-37
round number 4.0005 up to 3 decimal places
round(4.0005, 3)
[ "python.library.functions#round" ]
round(4.0005, 3)
conala
31818050-23
round number 8.005 up to 2 decimal places
round(8.005, 2)
[ "python.library.functions#round" ]
round(8.005, 2)
conala
31818050-74
round number 7.005 up to 2 decimal places
round(7.005, 2)
[ "python.library.functions#int", "python.library.functions#round" ]
round(7.005, 2)
conala
31818050-68
round number 6.005 up to 2 decimal places
round(6.005, 2)
[ "python.library.functions#round" ]
round(6.005, 2)
conala
31818050-55
round number 1.005 up to 2 decimal places
round(1.005, 2)
[ "python.library.functions#round" ]
round(1.005, 2)
conala