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 |
---|---|---|---|---|---|
16159228-35 | right align string `mystring` with a width of 7 | """{:>7s}""".format(mystring) | [
"python.library.functions#format"
] | """{:>7s}""".format(VAR_STR) | conala |
18253210-93 | creating a numpy array of 3d coordinates from three 1d arrays `x_p`, `y_p` and `z_p` | np.vstack(np.meshgrid(x_p, y_p, z_p)).reshape(3, -1).T | [
"numpy.reference.generated.numpy.meshgrid",
"numpy.reference.generated.numpy.vstack",
"numpy.reference.generated.numpy.reshape"
] | np.vstack(np.meshgrid(VAR_STR, VAR_STR, VAR_STR)).reshape(3, -1).T | conala |
12845112-46 | move last item of array `a` to the first position | a[-1:] + a[:-1] | [] | VAR_STR[-1:] + VAR_STR[:-1] | conala |
113655-47 | split string `Word to Split` into a list of characters | list('Word to Split') | [
"python.library.functions#list"
] | list('VAR_STR') | conala |
15465204-13 | Sum of sums of each list, in a list of lists named 'lists'. | sum(sum(x) for x in lists) | [
"python.library.functions#sum"
] | sum(sum(x) for x in VAR_STR) | conala |
21899953-68 | Set a window size to `1400, 1000` using selenium webdriver | driver.set_window_size(1400, 1000) | [] | driver.set_window_size(1400, 1000) | conala |
4223923-88 | change the case of the first letter in string `s` | return s[0].upper() + s[1:] | [
"python.library.stdtypes#str.upper"
] | return VAR_STR[0].upper() + VAR_STR[1:] | conala |
41821112-71 | get the sum of the products of each pair of corresponding elements in lists `a` and `b` | sum(x * y for x, y in zip(a, b)) | [
"python.library.functions#zip",
"python.library.functions#sum"
] | sum(x * y for x, y in zip(VAR_STR, VAR_STR)) | conala |
41821112-50 | sum the products of each two elements at the same index of list `a` and list `b` | list(x * y for x, y in list(zip(a, b))) | [
"python.library.functions#list",
"python.library.functions#zip"
] | list(x * y for x, y in list(zip(VAR_STR, VAR_STR))) | conala |
41821112-48 | sum the product of each two items at the same index of list `a` and list `b` | sum(i * j for i, j in zip(a, b)) | [
"python.library.functions#zip",
"python.library.functions#sum"
] | sum(i * j for i, j in zip(VAR_STR, VAR_STR)) | conala |
41821112-6 | sum the product of elements of two lists named `a` and `b` | sum(x * y for x, y in list(zip(a, b))) | [
"python.library.functions#zip",
"python.library.functions#sum",
"python.library.functions#list"
] | sum(x * y for x, y in list(zip(VAR_STR, VAR_STR))) | conala |
14737222-31 | Split string `Hello` into a string of letters seperated by `,` | """,""".join('Hello') | [
"python.library.stdtypes#str.join"
] | """VAR_STR""".join('VAR_STR') | conala |
19948732-25 | Matplotlib change marker size to 500 | scatter(x, y, s=500, color='green', marker='h') | [
"pandas.reference.api.pandas.dataframe.plot.scatter"
] | scatter(x, y, s=500, color='green', marker='h') | conala |
3842155-75 | change the state of the Tkinter `Text` widget to read only i.e. `disabled` | text.config(state=DISABLED) | [
"flask.api.index#flask.Config"
] | text.config(state=DISABLED) | conala |
2375335-29 | clear session key 'mykey' | del request.session['mykey'] | [] | del request.session['VAR_STR'] | conala |
444058-10 | display attribute `attr` for each object `obj` in list `my_list_of_objs` | print([obj.attr for obj in my_list_of_objs]) | [] | print([VAR_STR.VAR_STR for VAR_STR in VAR_STR]) | conala |
19745091-95 | lookup dictionary key `key1` in Django template `json` | {{json.key1}} | [] | {{VAR_STR.VAR_STR}} | conala |
40313203-39 | Sum elements of tuple `b` to their respective elements of each tuple in list `a` | c = [[(i + j) for i, j in zip(e, b)] for e in a] | [
"python.library.functions#zip"
] | c = [[(i + j) for i, j in zip(e, VAR_STR)] for e in VAR_STR] | conala |
2556108-6 | replace the last occurence of an expression '</div>' with '</bad>' in a string `s` | re.sub('(.*)</div>', '\\1</bad>', s) | [
"python.library.re#re.sub"
] | re.sub('(.*)</div>', '\\1</bad>', VAR_STR) | conala |
13411544-24 | delete column 'column_name' from dataframe `df` | df = df.drop('column_name', 1) | [
"pandas.reference.api.pandas.dataframe.drop"
] | VAR_STR = VAR_STR.drop('VAR_STR', 1) | conala |
13411544-67 | delete 1st, 2nd and 4th columns from dataframe `df` | df.drop(df.columns[[0, 1, 3]], axis=1) | [
"pandas.reference.api.pandas.dataframe.drop"
] | VAR_STR.drop(VAR_STR.columns[[0, 1, 3]], axis=1) | conala |
13411544-59 | delete a column `column_name` without having to reassign from pandas data frame `df` | df.drop('column_name', axis=1, inplace=True) | [
"pandas.reference.api.pandas.dataframe.drop"
] | VAR_STR.drop('VAR_STR', axis=1, inplace=True) | conala |
3766633-89 | Sort a data `a` in descending order based on the `modified` attribute of elements using lambda function | a = sorted(a, key=lambda x: x.modified, reverse=True) | [
"python.library.functions#sorted"
] | VAR_STR = sorted(VAR_STR, key=lambda x: x.VAR_STR, reverse=True) | conala |
20059427-99 | create a dictionary `list_dict` containing each tuple in list `tuple_list` as values and the tuple's first element as the corresponding key | list_dict = {t[0]: t for t in tuple_list} | [] | VAR_STR = {t[0]: t for t in VAR_STR} | conala |
16677816-22 | print list `t` into a table-like shape | print('\n'.join(' '.join(map(str, row)) for row in t)) | [
"python.library.functions#map",
"python.library.stdtypes#str.join"
] | print('\n'.join(' '.join(map(str, row)) for row in VAR_STR)) | conala |
42458734-13 | factorize all string values in dataframe `s` into floats | (s.factorize()[0] + 1).astype('float') | [
"pandas.reference.api.pandas.factorize",
"pandas.reference.api.pandas.dataframe.astype"
] | (VAR_STR.factorize()[0] + 1).astype('float') | conala |
14914615-30 | find out the number of non-matched elements at the same index of list `a` and list `b` | sum(1 for i, j in zip(a, b) if i != j) | [
"python.library.functions#zip",
"python.library.functions#sum"
] | sum(1 for i, j in zip(VAR_STR, VAR_STR) if i != j) | conala |
903853-42 | Get all the second values from a list of lists `A` | [row[1] for row in A] | [] | [row[1] for row in VAR_STR] | conala |
903853-19 | extract first column from a multi-dimensional array `a` | [row[0] for row in a] | [] | [row[0] for row in VAR_STR] | conala |
8440117-70 | print a celsius symbol on x axis of a plot `ax` | ax.set_xlabel('Temperature (\u2103)') | [
"matplotlib._as_gen.matplotlib.axes.axes.set_xlabel"
] | VAR_STR.set_xlabel('Temperature (℃)') | conala |
8440117-34 | Print a celsius symbol with matplotlib | ax.set_xlabel('Temperature ($^\\circ$C)') | [
"matplotlib._as_gen.matplotlib.axes.axes.set_xlabel"
] | ax.set_xlabel('Temperature ($^\\circ$C)') | conala |
3494906-84 | Convert list of dictionaries `L` into a flat dictionary | dict(pair for d in L for pair in list(d.items())) | [
"python.library.stdtypes#dict",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] | dict(pair for d in VAR_STR for pair in list(d.items())) | conala |
3494906-48 | merge a list of dictionaries in list `L` into a single dict | {k: v for d in L for k, v in list(d.items())} | [
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] | {k: v for d in VAR_STR for k, v in list(d.items())} | conala |
498106-72 | compile Visual Studio project `project.sln` from the command line through python | os.system('msbuild project.sln /p:Configuration=Debug') | [
"python.library.os#os.system"
] | os.system('msbuild project.sln /p:Configuration=Debug') | conala |
1532810-2 | read lines from a csv file `./urls-eu.csv` into a list of lists `arr` | arr = [line.split(',') for line in open('./urls-eu.csv')] | [
"python.library.urllib.request#open",
"python.library.stdtypes#str.split"
] | VAR_STR = [line.split(',') for line in open('VAR_STR')] | conala |
943809-13 | replace occurrences of two whitespaces or more with one whitespace ' ' in string `s` | re.sub(' +', ' ', s) | [
"python.library.re#re.sub"
] | re.sub(' +', ' ', VAR_STR) | conala |
28199524-81 | count the number of rows with missing values in a pandas dataframe `df` | sum(df.apply(lambda x: sum(x.isnull().values), axis=1) > 0) | [
"python.library.functions#sum",
"pandas.reference.api.pandas.dataframe.apply",
"pandas.reference.api.pandas.dataframe.isnull"
] | sum(VAR_STR.apply(lambda x: sum(x.isnull().values), axis=1) > 0) | conala |
17498027-0 | Clicking a link using selenium using python | driver.find_element_by_xpath('xpath').click() | [] | driver.find_element_by_xpath('xpath').click() | conala |
7262828-60 | convert a string literal `s` with values `\\` to raw string literal | s = s.replace('\\', '\\\\') | [
"python.library.stdtypes#str.replace"
] | VAR_STR = VAR_STR.replace('VAR_STR', '\\\\') | conala |
11339210-72 | get multiple integer values from a string 'string1' | map(int, re.findall('\\d+', string1)) | [
"python.library.re#re.findall",
"python.library.functions#map"
] | map(int, re.findall('\\d+', VAR_STR)) | conala |
39129846-99 | sort list `l` based on its elements' digits | sorted(l, key=lambda x: int(re.search('\\d+', x).group(0))) | [
"python.library.re#re.search",
"python.library.functions#sorted",
"python.library.functions#int",
"python.library.re#re.Match.group"
] | sorted(VAR_STR, key=lambda x: int(re.search('\\d+', x).group(0))) | conala |
31302904-21 | get first element of each tuple in list `A` | [tup[0] for tup in A] | [] | [tup[0] for tup in VAR_STR] | conala |
30994370-39 | Write a comment `# Data for Class A\n` to a file object `f` | f.write('# Data for Class A\n') | [
"python.library.os#os.write"
] | VAR_STR.write('VAR_STR') | conala |
3090175-87 | Find the greatest number in set `(1, 2, 3)` | print(max(1, 2, 3)) | [
"python.library.functions#max"
] | print(max(VAR_STR)) | conala |
19894478-99 | split string 'Words, words, words.' on punctuation | re.split('\\W+', 'Words, words, words.') | [
"python.library.re#re.split"
] | re.split('\\W+', 'VAR_STR') | conala |
18500541-37 | flatten a tuple `l` | [(a, b, c) for a, (b, c) in l] | [] | [(a, b, c) for a, (b, c) in VAR_STR] | conala |
42172204-74 | replace value '-' in any column of pandas dataframe to "NaN" | df.replace('-', 'NaN') | [
"pandas.reference.api.pandas.dataframe.replace"
] | df.replace('VAR_STR', 'VAR_STR') | conala |
3996904-78 | Generate a random integer between 0 and 9 | randint(0, 9) | [
"python.library.random#random.randint"
] | randint(0, 9) | conala |
3996904-29 | Generate a random integer between `a` and `b` | random.randint(a, b) | [
"python.library.random#random.randint"
] | random.randint(VAR_STR, VAR_STR) | conala |
3996904-34 | Generate random integers between 0 and 9 | print((random.randint(0, 9))) | [
"python.library.random#random.randint"
] | print(random.randint(0, 9)) | conala |
3582601-40 | get an element at index `[1,1]`in a numpy array `arr` | print(arr[1, 1]) | [] | print(VAR_STR[1, 1]) | conala |
730764-0 | call `doSomething()` in a try-except without handling the exception | try:
doSomething()
except:
pass | [] | try:
doSomething()
except:
pass | conala |
730764-10 | call `doSomething()` in a try-except without handling the exception | try:
doSomething()
except Exception:
pass | [] | try:
doSomething()
except Exception:
pass | conala |
38862349-53 | Create a list containing words that contain vowel letter followed by the same vowel in file 'file.text' | [w for w in open('file.txt') if not re.search('[aeiou]{2}', w)] | [
"python.library.re#re.search",
"python.library.urllib.request#open"
] | [w for w in open('file.txt') if not re.search('[aeiou]{2}', w)] | conala |
39381222-81 | print a rational number `3/2` | print('\n\x1b[4m' + '3' + '\x1b[0m' + '\n2') | [] | print('\n\x1b[4m' + '3' + '\x1b[0m' + '\n2') | conala |
4641765-34 | append 4 to list `foo` | foo.append(4) | [
"numpy.reference.generated.numpy.append"
] | VAR_STR.append(4) | conala |
4641765-55 | append a list [8, 7] to list `foo` | foo.append([8, 7]) | [
"numpy.reference.generated.numpy.append"
] | VAR_STR.append([8, 7]) | conala |
4641765-97 | insert 77 to index 2 of list `x` | x.insert(2, 77) | [
"numpy.reference.generated.numpy.insert"
] | VAR_STR.insert(2, 77) | conala |
4231345-36 | apply a list of functions named 'functions' over a list of values named 'values' | [x(y) for x, y in zip(functions, values)] | [
"python.library.functions#zip"
] | [x(y) for x, y in zip(VAR_STR, VAR_STR)] | conala |
18432823-76 | Convert array `x` into a correlation matrix | np.corrcoef(x) | [
"numpy.reference.generated.numpy.corrcoef"
] | np.corrcoef(VAR_STR) | conala |
27896214-81 | reading tab-delimited csv file `filename` with pandas on mac | pandas.read_csv(filename, sep='\t', lineterminator='\r') | [
"pandas.reference.api.pandas.read_csv"
] | pandas.read_csv(VAR_STR, sep='\t', lineterminator='\r') | conala |
30026815-9 | add multiple columns `hour`, `weekday`, `weeknum` to pandas data frame `df` from lambda function `lambdafunc` | df[['hour', 'weekday', 'weeknum']] = df.apply(lambdafunc, axis=1) | [
"pandas.reference.api.pandas.dataframe.apply"
] | VAR_STR[['VAR_STR', 'VAR_STR', 'VAR_STR']] = VAR_STR.apply(VAR_STR, axis=1) | conala |
1602934-33 | Check if key 'key1' in `dict` | ('key1' in dict) | [] | 'VAR_STR' in VAR_STR | conala |
1602934-63 | Check if key 'a' in `d` | ('a' in d) | [] | 'VAR_STR' in VAR_STR | conala |
1602934-89 | Check if key 'c' in `d` | ('c' in d) | [] | 'VAR_STR' in VAR_STR | conala |
1602934-96 | Check if a given key 'key1' exists in dictionary `dict` | if ('key1' in dict):
pass | [] | if 'VAR_STR' in VAR_STR:
pass | conala |
1602934-21 | Check if a given key `key` exists in dictionary `d` | if (key in d):
pass | [] | if VAR_STR in VAR_STR:
pass | conala |
1546226-68 | remove multiple spaces in a string `foo` | """ """.join(foo.split()) | [
"python.library.stdtypes#str.join",
"python.library.stdtypes#str.split"
] | """ """.join(VAR_STR.split()) | conala |
3886669-57 | convert tuple `tst` to string `tst2` | tst2 = str(tst) | [
"python.library.stdtypes#str"
] | VAR_STR = str(VAR_STR) | conala |
2674391-16 | Get the position of a regex match for word `is` in a string `String` | re.search('\\bis\\b', String).start() | [
"python.library.re#re.search",
"python.library.re#re.Match.start"
] | re.search('\\bis\\b', VAR_STR).start() | conala |
2674391-66 | Get the position of a regex match `is` in a string `String` | re.search('is', String).start() | [
"python.library.re#re.search",
"python.library.re#re.Match.start"
] | re.search('VAR_STR', VAR_STR).start() | conala |
9542738-42 | check if 3 is inside list `[1, 2, 3]` | 3 in [1, 2, 3] | [] | 3 in [VAR_STR] | conala |
15474933-42 | get items from list `a` that don't appear in list `b` | [y for y in a if y not in b] | [] | [y for y in VAR_STR if y not in VAR_STR] | conala |
37497559-37 | identify duplicated rows in columns 'PplNum' and 'RoomNum' with additional column in dataframe `df` | df.groupby(['PplNum', 'RoomNum']).cumcount() + 1 | [
"pandas.reference.api.pandas.dataframe.groupby",
"pandas.reference.api.pandas.core.groupby.groupby.cumcount"
] | VAR_STR.groupby(['VAR_STR', 'VAR_STR']).cumcount() + 1 | conala |
13002848-88 | Jinja join elements of array `tags` with space string ' ' | {{tags | join(' ')}} | [
"python.library.stdtypes#str.join"
] | {{VAR_STR | join(' ')}} | conala |
2229827-41 | django urlsafe base64 decode string `uenc` with decryption | base64.urlsafe_b64decode(uenc.encode('ascii')) | [
"python.library.base64#base64.urlsafe_b64decode",
"python.library.base64#base64.encode"
] | base64.urlsafe_b64decode(VAR_STR.encode('ascii')) | conala |
2612802-18 | copy list `old_list` as `new_list` | new_list = old_list[:] | [] | VAR_STR = VAR_STR[:] | conala |
2612802-25 | copy list `old_list` as `new_list` | new_list = list(old_list) | [
"python.library.functions#list"
] | VAR_STR = list(VAR_STR) | conala |
2612802-99 | copy list `old_list` as `new_list` | new_list = copy.copy(old_list) | [] | VAR_STR = copy.copy(VAR_STR) | conala |
2612802-37 | deep copy list `old_list` as `new_list` | new_list = copy.deepcopy(old_list) | [
"python.library.copy#copy.deepcopy"
] | VAR_STR = copy.deepcopy(VAR_STR) | conala |
2612802-26 | make a copy of list `old_list` | [i for i in old_list] | [] | [i for i in VAR_STR] | conala |
16735786-56 | generate unique equal hash for equal dictionaries `a` and `b` | hash(pformat(a)) == hash(pformat(b)) | [
"python.library.functions#hash",
"python.library.pprint#pprint.pformat"
] | hash(pformat(VAR_STR)) == hash(pformat(VAR_STR)) | conala |
13128565-88 | split string `s` by letter 's' | s.split('s') | [
"python.library.stdtypes#str.split"
] | VAR_STR.split('VAR_STR') | conala |
6372228-68 | Get a list of strings `split_text` with fixed chunk size `n` from a string `the_list` | split_list = [the_list[i:i + n] for i in range(0, len(the_list), n)] | [
"python.library.functions#len",
"python.library.functions#range"
] | split_list = [VAR_STR[i:i + VAR_STR] for i in range(0, len(VAR_STR), VAR_STR)] | conala |
26894227-7 | sum of squares values in a list `l` | sum(i * i for i in l) | [
"python.library.functions#sum"
] | sum(i * i for i in VAR_STR) | conala |
26894227-0 | calculate the sum of the squares of each value in list `l` | sum(map(lambda x: x * x, l)) | [
"python.library.functions#map",
"python.library.functions#sum"
] | sum(map(lambda x: x * x, VAR_STR)) | conala |
41127441-97 | get a list each value `i` in the implicit tuple `range(3)` | list(i for i in range(3)) | [
"python.library.functions#range",
"python.library.functions#list"
] | list(VAR_STR for VAR_STR in range(3)) | conala |
12681945-62 | revers correlating bits of integer `n` | int('{:08b}'.format(n)[::-1], 2) | [
"python.library.functions#int",
"python.library.functions#format"
] | int('{:08b}'.format(VAR_STR)[::-1], 2) | conala |
5301996-48 | Filter Django objects by `author` with ids `1` and `2` | Book.objects.filter(author__id=1).filter(author__id=2) | [
"python.library.functions#filter"
] | Book.objects.filter(author__id=1).filter(author__id=2) | conala |
3895874-90 | Write a regex statement to match 'lol' to 'lolllll'. | re.sub('l+', 'l', 'lollll') | [
"python.library.re#re.sub"
] | re.sub('l+', 'l', 'lollll') | conala |
3241594-99 | printing numbers rounding up to third decimal place | print('%.3f' % 3.1415) | [] | print('%.3f' % 3.1415) | conala |
6027690-60 | Plot using the color code `#112233` in matplotlib pyplot | pyplot.plot(x, y, color='#112233') | [
"matplotlib._as_gen.matplotlib.pyplot.plot"
] | pyplot.plot(x, y, color='VAR_STR') | conala |
4358701-40 | remove 20 symbols in front of '.' in string 'unique12345678901234567890.mkv' | re.sub('.{20}(.mkv)', '\\1', 'unique12345678901234567890.mkv') | [
"python.library.re#re.sub"
] | re.sub('.{20}(.mkv)', '\\1', 'VAR_STR') | conala |
8122079-23 | check if any element of list `substring_list` are in string `string` | any(substring in string for substring in substring_list) | [
"python.library.functions#any"
] | any(substring in VAR_STR for substring in VAR_STR) | conala |
3855093-58 | convert list `myintegers` into a unicode string | """""".join(chr(i) for i in myintegers) | [
"python.library.functions#chr",
"python.library.stdtypes#str.join"
] | """""".join(chr(i) for i in VAR_STR) | conala |
1854-80 | get os name | import platform
platform.system() | [
"python.library.os#os.system"
] | import platform
platform.system() | conala |
1854-31 | get os version | import platform
platform.release() | [
"python.library.stdtypes#memoryview.release"
] | import platform
platform.release() | conala |
1854-51 | get the name of the OS | print(os.name) | [] | print(os.name) | conala |
7668141-64 | Make function `WRITEFUNCTION` output nothing in curl `p` | p.setopt(pycurl.WRITEFUNCTION, lambda x: None) | [] | VAR_STR.setopt(pycurl.VAR_STR, lambda x: None) | conala |
21205074-1 | split a string `s` at line breaks `\r\n` | [map(int, x.split('\t')) for x in s.rstrip().split('\r\n')] | [
"python.library.functions#map",
"python.library.stdtypes#str.split"
] | [map(int, x.split('\t')) for x in VAR_STR.rstrip().split('VAR_STR')] | conala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.