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 |
---|---|---|---|---|---|
9938130-67 | plotting stacked barplots on a panda data frame | df.plot(kind='barh', stacked=True) | [
"pandas.reference.api.pandas.dataframe.plot"
] | df.plot(kind='barh', stacked=True) | conala |
35945473-75 | reverse the keys and values in a dictionary `myDictionary` | {i[1]: i[0] for i in list(myDictionary.items())} | [
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] | {i[1]: i[0] for i in list(VAR_STR.items())} | conala |
1303243-70 | check if object `obj` is a string | isinstance(obj, str) | [
"python.library.functions#isinstance"
] | isinstance(VAR_STR, str) | conala |
1303243-15 | check if object `o` is a string | isinstance(o, str) | [
"python.library.functions#isinstance"
] | isinstance(VAR_STR, str) | conala |
1303243-31 | check if object `o` is a string | (type(o) is str) | [
"python.library.functions#type"
] | type(VAR_STR) is str | conala |
1303243-32 | check if object `o` is a string | isinstance(o, str) | [
"python.library.functions#isinstance"
] | isinstance(VAR_STR, str) | conala |
1303243-47 | check if `obj_to_test` is a string | isinstance(obj_to_test, str) | [
"python.library.functions#isinstance"
] | isinstance(VAR_STR, str) | conala |
8177079-17 | append list `list1` to `list2` | list2.extend(list1) | [
"python.library.collections#collections.deque.extend"
] | VAR_STR.extend(VAR_STR) | conala |
8177079-3 | append list `mylog` to `list1` | list1.extend(mylog) | [
"python.library.collections#collections.deque.extend"
] | VAR_STR.extend(VAR_STR) | conala |
8177079-50 | append list `a` to `c` | c.extend(a) | [
"python.library.collections#collections.deque.extend"
] | VAR_STR.extend(VAR_STR) | conala |
8177079-4 | append items in list `mylog` to `list1` | for line in mylog:
list1.append(line) | [
"numpy.reference.generated.numpy.append"
] | for line in VAR_STR:
VAR_STR.append(line) | conala |
4126227-85 | append a tuple of elements from list `a` with indexes '[0][0] [0][2]' to list `b` | b.append((a[0][0], a[0][2])) | [
"numpy.reference.generated.numpy.append"
] | VAR_STR.append((VAR_STR[0][0], VAR_STR[0][2])) | conala |
34902378-5 | Initialize `SECRET_KEY` in flask config with `Your_secret_string ` | app.config['SECRET_KEY'] = 'Your_secret_string' | [] | app.config['VAR_STR'] = 'VAR_STR' | conala |
1762484-85 | find the index of an element 'MSFT' in a list `stocks_list` | [x for x in range(len(stocks_list)) if stocks_list[x] == 'MSFT'] | [
"python.library.functions#len",
"python.library.functions#range"
] | [x for x in range(len(VAR_STR)) if VAR_STR[x] == 'VAR_STR'] | conala |
875968-40 | remove symbols from a string `s` | re.sub('[^\\w]', ' ', s) | [
"python.library.re#re.sub"
] | re.sub('[^\\w]', ' ', VAR_STR) | conala |
31258561-66 | Get the current directory of a script | os.path.basename(os.path.dirname(os.path.realpath(__file__))) | [
"python.library.os.path#os.path.basename",
"python.library.os.path#os.path.dirname",
"python.library.os.path#os.path.realpath"
] | os.path.basename(os.path.dirname(os.path.realpath(__file__))) | conala |
34750084-45 | Find octal characters matches from a string `str` using regex | print(re.findall("'\\\\[0-7]{1,3}'", str)) | [
"python.library.re#re.findall"
] | print(re.findall("'\\\\[0-7]{1,3}'", VAR_STR)) | conala |
13209288-55 | split string `input` based on occurrences of regex pattern '[ ](?=[A-Z]+\\b)' | re.split('[ ](?=[A-Z]+\\b)', input) | [
"python.library.re#re.split"
] | re.split('VAR_STR', VAR_STR) | conala |
13209288-65 | Split string `input` at every space followed by an upper-case letter | re.split('[ ](?=[A-Z])', input) | [
"python.library.re#re.split"
] | re.split('[ ](?=[A-Z])', VAR_STR) | conala |
24642040-8 | send multipart encoded file `files` to url `url` with headers `headers` and metadata `data` | r = requests.post(url, files=files, headers=headers, data=data) | [
"pygame.ref.fastevent#pygame.fastevent.post"
] | r = requests.post(VAR_STR, VAR_STR=VAR_STR, VAR_STR=VAR_STR, VAR_STR=VAR_STR) | conala |
4290716-97 | write bytes `bytes_` to a file `filename` in python 3 | open('filename', 'wb').write(bytes_) | [
"python.library.urllib.request#open",
"python.library.os#os.write"
] | open('VAR_STR', 'wb').write(VAR_STR) | conala |
33078554-39 | get a list from a list `lst` with values mapped into a dictionary `dct` | [dct[k] for k in lst] | [] | [VAR_STR[k] for k in VAR_STR] | conala |
15247628-33 | find duplicate names in column 'name' of the dataframe `x` | x.set_index('name').index.get_duplicates() | [
"pandas.reference.api.pandas.dataframe.set_index"
] | VAR_STR.set_index('VAR_STR').index.get_duplicates() | conala |
783897-89 | truncate float 1.923328437452 to 3 decimal places | round(1.923328437452, 3) | [
"python.library.functions#round"
] | round(1.923328437452, 3) | conala |
22859493-62 | sort list `li` in descending order based on the date value in second element of each list in list `li` | sorted(li, key=lambda x: datetime.strptime(x[1], '%d/%m/%Y'), reverse=True) | [
"python.library.functions#sorted",
"python.library.datetime#datetime.datetime.strptime"
] | sorted(VAR_STR, key=lambda x: datetime.strptime(x[1], '%d/%m/%Y'), reverse=True) | conala |
29394552-74 | place the radial ticks in plot `ax` at 135 degrees | ax.set_rlabel_position(135) | [
"matplotlib.projections_api#matplotlib.projections.polar.PolarAxes.set_rlabel_position"
] | VAR_STR.set_rlabel_position(135) | conala |
3320406-28 | check if path `my_path` is an absolute path | os.path.isabs(my_path) | [
"python.library.os.path#os.path.isabs"
] | os.path.isabs(VAR_STR) | conala |
20067636-10 | pandas dataframe get first row of each group by 'id' | df.groupby('id').first() | [
"pandas.reference.api.pandas.dataframe.groupby",
"pandas.reference.api.pandas.dataframe.first"
] | df.groupby('VAR_STR').first() | conala |
30759776-2 | extract attributes 'src="js/([^"]*\\bjquery\\b[^"]*)"' from string `data` | re.findall('src="js/([^"]*\\bjquery\\b[^"]*)"', data) | [
"python.library.re#re.findall"
] | re.findall('VAR_STR', VAR_STR) | conala |
25388796-87 | Sum integers contained in strings in list `['', '3.4', '', '', '1.0']` | sum(int(float(item)) for item in [_f for _f in ['', '3.4', '', '', '1.0'] if _f]) | [
"python.library.functions#float",
"python.library.functions#int",
"python.library.functions#sum"
] | sum(int(float(item)) for item in [_f for _f in [VAR_STR] if
_f]) | conala |
18897261-72 | make a barplot of data in column `group` of dataframe `df` colour-coded according to list `color` | df['group'].plot(kind='bar', color=['r', 'g', 'b', 'r', 'g', 'b', 'r']) | [
"pandas.reference.api.pandas.dataframe.plot"
] | VAR_STR['VAR_STR'].plot(kind='bar', VAR_STR=['r', 'g', 'b', 'r', 'g', 'b', 'r']) | conala |
373194-29 | find all matches of regex pattern '([a-fA-F\\d]{32})' in string `data` | re.findall('([a-fA-F\\d]{32})', data) | [
"python.library.re#re.findall"
] | re.findall('VAR_STR', VAR_STR) | conala |
518021-20 | Get the length of list `my_list` | len(my_list) | [
"python.library.functions#len"
] | len(VAR_STR) | conala |
518021-61 | Getting the length of array `l` | len(l) | [
"python.library.functions#len"
] | len(VAR_STR) | conala |
518021-63 | Getting the length of array `s` | len(s) | [
"python.library.functions#len"
] | len(VAR_STR) | conala |
518021-87 | Getting the length of `my_tuple` | len(my_tuple) | [
"python.library.functions#len"
] | len(VAR_STR) | conala |
518021-86 | Getting the length of `my_string` | len(my_string) | [
"python.library.functions#len"
] | len(VAR_STR) | conala |
40452956-17 | remove escape character from string "\\a" | """\\a""".decode('string_escape') | [
"python.library.stdtypes#bytearray.decode"
] | """VAR_STR""".decode('string_escape') | conala |
8687018-68 | replace each 'a' with 'b' and each 'b' with 'a' in the string 'obama' in a single pass. | """obama""".replace('a', '%temp%').replace('b', 'a').replace('%temp%', 'b') | [
"python.library.stdtypes#str.replace"
] | """VAR_STR""".replace('VAR_STR', '%temp%').replace('VAR_STR', 'VAR_STR').replace(
'%temp%', 'VAR_STR') | conala |
303200-79 | remove directory tree '/folder_name' | shutil.rmtree('/folder_name') | [
"python.library.shutil#shutil.rmtree"
] | shutil.rmtree('VAR_STR') | conala |
13740672-79 | create a new column `weekday` in pandas data frame `data` based on the values in column `my_dt` | data['weekday'] = data['my_dt'].apply(lambda x: x.weekday()) | [
"pandas.reference.api.pandas.series.apply"
] | VAR_STR['VAR_STR'] = VAR_STR['VAR_STR'].apply(lambda x: x.VAR_STR()) | conala |
20950650-8 | reverse sort Counter `x` by values | sorted(x, key=x.get, reverse=True) | [
"python.library.functions#sorted"
] | sorted(VAR_STR, key=VAR_STR.get, reverse=True) | conala |
20950650-18 | reverse sort counter `x` by value | sorted(list(x.items()), key=lambda pair: pair[1], reverse=True) | [
"python.library.functions#sorted",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] | sorted(list(VAR_STR.items()), key=lambda pair: pair[1], reverse=True) | conala |
9775297-68 | append a numpy array 'b' to a numpy array 'a' | np.vstack((a, b)) | [
"numpy.reference.generated.numpy.vstack"
] | np.vstack((VAR_STR, VAR_STR)) | conala |
2805231-96 | fetch address information for host 'google.com' ion port 80 | print(socket.getaddrinfo('google.com', 80)) | [
"python.library.socket#socket.getaddrinfo"
] | print(socket.getaddrinfo('VAR_STR', 80)) | conala |
17552997-64 | add a column 'day' with value 'sat' to dataframe `df` | df.xs('sat', level='day', drop_level=False) | [
"pandas.reference.api.pandas.dataframe.xs"
] | VAR_STR.xs('VAR_STR', level='VAR_STR', drop_level=False) | conala |
13598363-99 | Flask set folder 'wherever' as the default template folder | Flask(__name__, template_folder='wherever') | [
"flask.api.index#flask.Flask"
] | Flask(__name__, template_folder='VAR_STR') | conala |
1849375-50 | How do I INSERT INTO t1 (SELECT * FROM t2) in SQLAlchemy? | session.execute('INSERT INTO t1 (SELECT * FROM t2)') | [
"python.library.msilib#msilib.View.Execute"
] | session.execute('INSERT INTO t1 (SELECT * FROM t2)') | conala |
3398589-41 | sort a list of lists 'c2' such that third row comes first | c2.sort(key=lambda row: row[2]) | [
"python.library.stdtypes#list.sort"
] | VAR_STR.sort(key=lambda row: row[2]) | conala |
3398589-16 | Sorting a list of lists in Python | c2.sort(key=lambda row: (row[2], row[1], row[0])) | [
"python.library.stdtypes#list.sort"
] | c2.sort(key=lambda row: (row[2], row[1], row[0])) | conala |
3398589-90 | Sorting a list of lists in Python | c2.sort(key=lambda row: (row[2], row[1])) | [
"python.library.stdtypes#list.sort"
] | c2.sort(key=lambda row: (row[2], row[1])) | conala |
10960463-71 | set font `Arial` to display non-ascii characters in matplotlib | matplotlib.rc('font', **{'sans-serif': 'Arial', 'family': 'sans-serif'}) | [
"matplotlib._as_gen.matplotlib.pyplot.rc"
] | matplotlib.rc('font', **{'sans-serif': 'VAR_STR', 'family': 'sans-serif'}) | conala |
20576618-72 | Convert DateTime column 'date' of pandas dataframe 'df' to ordinal | df['date'].apply(lambda x: x.toordinal()) | [
"pandas.reference.api.pandas.timestamp.toordinal",
"pandas.reference.api.pandas.series.apply"
] | VAR_STR['VAR_STR'].apply(lambda x: x.toordinal()) | conala |
7263824-68 | get html source of Selenium WebElement `element` | element.get_attribute('innerHTML') | [
"python.library.test#test.support.get_attribute"
] | VAR_STR.get_attribute('innerHTML') | conala |
7574841-76 | open a 'gnome' terminal from python script and run 'sudo apt-get update' command. | os.system('gnome-terminal -e \'bash -c "sudo apt-get update; exec bash"\'') | [
"python.library.os#os.system"
] | os.system('gnome-terminal -e \'bash -c "sudo apt-get update; exec bash"\'') | conala |
10487278-57 | add an item with key 'third_key' and value 1 to an dictionary `my_dict` | my_dict.update({'third_key': 1}) | [
"python.library.stdtypes#dict.update"
] | VAR_STR.update({'VAR_STR': 1}) | conala |
10487278-5 | declare an array | my_list = [] | [] | my_list = [] | conala |
10487278-47 | Insert item `12` to a list `my_list` | my_list.append(12) | [
"numpy.reference.generated.numpy.append"
] | VAR_STR.append(12) | conala |
10155684-8 | add an entry 'wuggah' at the beginning of list `myList` | myList.insert(0, 'wuggah') | [
"numpy.reference.generated.numpy.insert"
] | VAR_STR.insert(0, 'VAR_STR') | conala |
3519125-47 | convert a hex-string representation to actual bytes | """\\xF3\\xBE\\x80\\x80""".replace('\\x', '').decode('hex') | [
"python.library.stdtypes#bytearray.decode",
"python.library.stdtypes#str.replace"
] | """\\xF3\\xBE\\x80\\x80""".replace('\\x', '').decode('hex') | conala |
40144769-97 | select the last column of dataframe `df` | df[df.columns[-1]] | [] | VAR_STR[VAR_STR.columns[-1]] | conala |
30787901-86 | get the first value from dataframe `df` where column 'Letters' is equal to 'C' | df.loc[df['Letters'] == 'C', 'Letters'].values[0] | [
"pandas.reference.api.pandas.dataframe.loc"
] | VAR_STR.loc[VAR_STR['VAR_STR'] == 'VAR_STR', 'VAR_STR'].values[0] | conala |
402504-5 | get the type of `i` | type(i) | [
"python.library.functions#type"
] | type(VAR_STR) | conala |
402504-77 | determine the type of variable `v` | type(v) | [
"python.library.functions#type"
] | type(VAR_STR) | conala |
402504-78 | determine the type of variable `v` | type(v) | [
"python.library.functions#type"
] | type(VAR_STR) | conala |
402504-9 | determine the type of variable `v` | type(v) | [
"python.library.functions#type"
] | type(VAR_STR) | conala |
402504-40 | determine the type of variable `v` | type(v) | [
"python.library.functions#type"
] | type(VAR_STR) | conala |
402504-29 | get the type of variable `variable_name` | print(type(variable_name)) | [
"python.library.functions#type"
] | print(type(VAR_STR)) | conala |
2300756-79 | get the 5th item of a generator | next(itertools.islice(range(10), 5, 5 + 1)) | [
"python.library.itertools#itertools.islice",
"python.library.functions#range",
"python.library.functions#next"
] | next(itertools.islice(range(10), 5, 5 + 1)) | conala |
20056548-25 | Print a string `word` with string format | print('"{}"'.format(word)) | [
"python.library.functions#format"
] | print('"{}"'.format(VAR_STR)) | conala |
8546245-44 | join a list of strings `list` using a space ' ' | """ """.join(list) | [
"python.library.stdtypes#str.join"
] | """ """.join(VAR_STR) | conala |
2276416-66 | create list `y` containing two empty lists | y = [[] for n in range(2)] | [
"python.library.functions#range"
] | VAR_STR = [[] for n in range(2)] | conala |
3925614-88 | read a file 'C:/name/MyDocuments/numbers' into a list `data` | data = [line.strip() for line in open('C:/name/MyDocuments/numbers', 'r')] | [
"python.library.urllib.request#open",
"python.library.stdtypes#str.strip"
] | VAR_STR = [line.strip() for line in open('VAR_STR', 'r')] | conala |
13413590-6 | Drop rows of pandas dataframe `df` having NaN in column at index "1" | df.dropna(subset=[1]) | [
"pandas.reference.api.pandas.dataframe.dropna"
] | VAR_STR.dropna(subset=[1]) | conala |
598398-3 | get elements from list `myList`, that have a field `n` value 30 | [x for x in myList if x.n == 30] | [] | [x for x in VAR_STR if x.VAR_STR == 30] | conala |
493386-37 | print "." without newline | sys.stdout.write('.') | [
"python.library.os#os.write"
] | sys.stdout.write('VAR_STR') | conala |
6569528-54 | round off the float that is the product of `2.52 * 100` and convert it to an int | int(round(2.51 * 100)) | [
"python.library.functions#int",
"python.library.functions#round"
] | int(round(2.51 * 100)) | conala |
20865487-86 | plot dataframe `df` without a legend | df.plot(legend=False) | [
"pandas.reference.api.pandas.dataframe.plot"
] | VAR_STR.plot(legend=False) | conala |
13368659-96 | loop through the IP address range "192.168.x.x" | for i in range(256):
for j in range(256):
ip = ('192.168.%d.%d' % (i, j))
print(ip) | [
"python.library.functions#range"
] | for i in range(256):
for j in range(256):
ip = '192.168.%d.%d' % (i, j)
print(ip) | conala |
13368659-83 | loop through the IP address range "192.168.x.x" | for (i, j) in product(list(range(256)), list(range(256))):
pass | [
"python.library.functions#range",
"python.library.functions#list"
] | for i, j in product(list(range(256)), list(range(256))):
pass | conala |
13368659-30 | loop through the IP address range "192.168.x.x" | generator = iter_iprange('192.168.1.1', '192.168.255.255', step=1) | [] | generator = iter_iprange('192.168.1.1', '192.168.255.255', step=1) | conala |
4065737-88 | Sum the corresponding decimal values for binary values of each boolean element in list `x` | sum(1 << i for i, b in enumerate(x) if b) | [
"python.library.functions#enumerate",
"python.library.functions#sum"
] | sum(1 << i for i, b in enumerate(VAR_STR) if b) | conala |
8691311-3 | write multiple strings `line1`, `line2` and `line3` in one line in a file `target` | target.write('%r\n%r\n%r\n' % (line1, line2, line3)) | [
"python.library.os#os.write"
] | VAR_STR.write('%r\n%r\n%r\n' % (VAR_STR, VAR_STR, VAR_STR)) | conala |
10632111-94 | Convert list of lists `data` into a flat list | [y for x in data for y in (x if isinstance(x, list) else [x])] | [
"python.library.functions#isinstance"
] | [y for x in VAR_STR for y in (x if isinstance(x, list) else [x])] | conala |
15392730-45 | Print new line character as `\n` in a string `foo\nbar` | print('foo\nbar'.encode('string_escape')) | [
"python.library.stdtypes#str.encode"
] | print('VAR_STR'.encode('string_escape')) | conala |
1010961-75 | remove last comma character ',' in string `s` | """""".join(s.rsplit(',', 1)) | [
"python.library.stdtypes#str.rsplit",
"python.library.stdtypes#str.join"
] | """""".join(VAR_STR.rsplit('VAR_STR', 1)) | conala |
23855976-47 | calculate the mean of each element in array `x` with the element previous to it | (x[1:] + x[:-1]) / 2 | [] | (VAR_STR[1:] + VAR_STR[:-1]) / 2 | conala |
23855976-53 | get an array of the mean of each two consecutive values in numpy array `x` | x[:-1] + (x[1:] - x[:-1]) / 2 | [] | VAR_STR[:-1] + (VAR_STR[1:] - VAR_STR[:-1]) / 2 | conala |
6375343-22 | load data containing `utf-8` from file `new.txt` into numpy array `arr` | arr = numpy.fromiter(codecs.open('new.txt', encoding='utf-8'), dtype='<U2') | [
"python.library.codecs#codecs.open",
"numpy.reference.generated.numpy.fromiter"
] | VAR_STR = numpy.fromiter(codecs.open('VAR_STR', encoding='VAR_STR'), dtype='<U2') | conala |
1547733-9 | reverse sort list of dicts `l` by value for key `time` | l = sorted(l, key=itemgetter('time'), reverse=True) | [
"python.library.functions#sorted",
"python.library.operator#operator.itemgetter"
] | VAR_STR = sorted(VAR_STR, key=itemgetter('VAR_STR'), reverse=True) | conala |
1547733-81 | Sort a list of dictionary `l` based on key `time` in descending order | l = sorted(l, key=lambda a: a['time'], reverse=True) | [
"python.library.functions#sorted"
] | VAR_STR = sorted(VAR_STR, key=lambda a: a['VAR_STR'], reverse=True) | conala |
37080612-2 | get rows of dataframe `df` that match regex '(Hel|Just)' | df.loc[df[0].str.contains('(Hel|Just)')] | [
"pandas.reference.api.pandas.dataframe.loc",
"pandas.reference.api.pandas.series.str.contains"
] | VAR_STR.loc[VAR_STR[0].str.contains('VAR_STR')] | conala |
14716342-27 | find the string in `your_string` between two special characters "[" and "]" | re.search('\\[(.*)\\]', your_string).group(1) | [
"python.library.re#re.search",
"python.library.re#re.Match.group"
] | re.search('\\[(.*)\\]', VAR_STR).group(1) | conala |
18684076-99 | How to create a list of date string in 'yyyymmdd' format with Python Pandas? | [d.strftime('%Y%m%d') for d in pandas.date_range('20130226', '20130302')] | [
"pandas.reference.api.pandas.date_range",
"pandas.reference.api.pandas.timestamp.strftime"
] | [d.strftime('%Y%m%d') for d in pandas.date_range('20130226', '20130302')] | conala |
1666700-25 | count number of times string 'brown' occurred in string 'The big brown fox is brown' | """The big brown fox is brown""".count('brown') | [
"python.library.stdtypes#str.count"
] | """VAR_STR""".count('VAR_STR') | conala |
7243750-79 | download the file from url `url` and save it under file `file_name` | urllib.request.urlretrieve(url, file_name) | [
"python.library.urllib.request#urllib.request.urlretrieve"
] | urllib.request.urlretrieve(VAR_STR, VAR_STR) | conala |
743806-70 | split string `text` by space | text.split() | [
"python.library.stdtypes#str.split"
] | VAR_STR.split() | conala |
743806-93 | split string `text` by "," | text.split(',') | [
"python.library.stdtypes#str.split"
] | VAR_STR.split('VAR_STR') | conala |
743806-18 | Split string `line` into a list by whitespace | line.split() | [
"python.library.stdtypes#str.split"
] | VAR_STR.split() | conala |
35044115-64 | replace dot characters '.' associated with ascii letters in list `s` with space ' ' | [re.sub('(?<!\\d)\\.(?!\\d)', ' ', i) for i in s] | [
"python.library.re#re.sub"
] | [re.sub('(?<!\\d)\\.(?!\\d)', ' ', i) for i in VAR_STR] | conala |
Subsets and Splits