{"nl": "Get pandas GroupBy object with sum over the rows with same column names within dataframe `df`", "cmd": "df.groupby(df.columns, axis=1).sum()", "question_id": "13078751-34", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.groupby", "python.library.functions#sum"], "canonical_cmd": "VAR_STR.groupby(VAR_STR.columns, axis=1).sum()"} {"nl": "divide the value for each key `k` in dict `d2` by the value for the same key `k` in dict `d1`", "cmd": "{k: (d2[k] / d1[k]) for k in list(d1.keys()) & d2}", "question_id": "11840111-76", "cmd_name": "conala", "oracle_man": ["python.library.functions#list", "python.library.stdtypes#dict.keys"], "canonical_cmd": "{VAR_STR: (VAR_STR[VAR_STR] / VAR_STR[VAR_STR]) for VAR_STR in list(VAR_STR.keys()) & VAR_STR}"} {"nl": "combining rows in pandas by adding their values", "cmd": "df.groupby(df.index).sum()", "question_id": "17438906-51", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.groupby", "python.library.functions#sum"], "canonical_cmd": "df.groupby(df.index).sum()"} {"nl": "make all keys lowercase in dictionary `d`", "cmd": "d = {(a.lower(), b): v for (a, b), v in list(d.items())}", "question_id": "21833383-37", "cmd_name": "conala", "oracle_man": ["python.library.functions#list", "python.library.stdtypes#str.lower", "python.library.stdtypes#dict.items"], "canonical_cmd": "VAR_STR = {(a.lower(), b): v for (a, b), v in list(VAR_STR.items())}"} {"nl": "create a dataframe `d` filled with zeros with indices from 0 to length of `data` and column names from `feature_list`", "cmd": "d = pd.DataFrame(0, index=np.arange(len(data)), columns=feature_list)", "question_id": "22963263-45", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.arange", "python.library.functions#len", "pandas.reference.api.pandas.dataframe"], "canonical_cmd": "VAR_STR = pd.DataFrame(0, index=np.arange(len(VAR_STR)), columns=VAR_STR)"} {"nl": "get a dict of variable names `['some', 'list', 'of', 'vars']` as a string and their values", "cmd": "dict((name, eval(name)) for name in ['some', 'list', 'of', 'vars'])", "question_id": "2553354-9", "cmd_name": "conala", "oracle_man": ["python.library.functions#eval", "python.library.stdtypes#dict"], "canonical_cmd": "dict((name, eval(name)) for name in [VAR_STR])"} {"nl": "Format a date object `str_data` into iso fomrat", "cmd": "datetime.datetime.strptime(str_date, '%m/%d/%Y').date().isoformat()", "question_id": "12772057-25", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.datetime.strptime", "python.library.datetime#datetime.date.isoformat", "python.library.datetime#datetime.datetime.date"], "canonical_cmd": "datetime.datetime.strptime(str_date, '%m/%d/%Y').date().isoformat()"} {"nl": "sort dictionary `mydict` in descending order based on the sum of each value in it", "cmd": "sorted(iter(mydict.items()), key=lambda tup: sum(tup[1]), reverse=True)[:3]", "question_id": "3411025-33", "cmd_name": "conala", "oracle_man": ["python.library.functions#sorted", "python.library.functions#iter", "python.library.functions#sum", "python.library.stdtypes#dict.items"], "canonical_cmd": "sorted(iter(VAR_STR.items()), key=lambda tup: sum(tup[1]), reverse=True)[:3]"} {"nl": "get top `3` items from a dictionary `mydict` with largest sum of values", "cmd": "heapq.nlargest(3, iter(mydict.items()), key=lambda tup: sum(tup[1]))", "question_id": "3411025-3", "cmd_name": "conala", "oracle_man": ["python.library.heapq#heapq.nlargest", "python.library.functions#iter", "python.library.functions#sum", "python.library.stdtypes#dict.items"], "canonical_cmd": "heapq.nlargest(3, iter(VAR_STR.items()), key=lambda tup: sum(tup[1]))"} {"nl": "calculate the md5 checksum of a file named 'filename.exe'", "cmd": "hashlib.md5(open('filename.exe', 'rb').read()).hexdigest()", "question_id": "16874598-40", "cmd_name": "conala", "oracle_man": ["python.library.urllib.request#open", "python.library.hashlib#hashlib.hash.hexdigest", "python.library.os#os.read"], "canonical_cmd": "hashlib.md5(open('VAR_STR', 'rb').read()).hexdigest()"} {"nl": "get max key in dictionary `MyCount`", "cmd": "max(list(MyCount.keys()), key=int)", "question_id": "3108042-55", "cmd_name": "conala", "oracle_man": ["python.library.functions#max", "python.library.functions#list", "python.library.stdtypes#dict.keys"], "canonical_cmd": "max(list(VAR_STR.keys()), key=int)"} {"nl": "return a string from a regex match with pattern '' in string 'line'", "cmd": "imtag = re.match('', line).group(0)", "question_id": "18493677-21", "cmd_name": "conala", "oracle_man": ["python.library.re#re.match", "python.library.re#re.Match.group"], "canonical_cmd": "imtag = re.match('VAR_STR', VAR_STR).group(0)"} {"nl": "In Django, filter `Task.objects` based on all entities in ['A', 'P', 'F']", "cmd": "Task.objects.exclude(prerequisites__status__in=['A', 'P', 'F'])", "question_id": "1516795-1", "cmd_name": "conala", "oracle_man": ["django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.exclude"], "canonical_cmd": "Task.objects.exclude(prerequisites__status__in=['VAR_STR', 'VAR_STR', 'VAR_STR'])"} {"nl": "remove duplicated items from list of lists `testdata`", "cmd": "list(map(list, set(map(lambda i: tuple(i), testdata))))", "question_id": "3724551-76", "cmd_name": "conala", "oracle_man": ["python.library.functions#map", "python.library.functions#list", "python.library.functions#tuple", "python.library.stdtypes#set"], "canonical_cmd": "list(map(list, set(map(lambda i: tuple(i), VAR_STR))))"} {"nl": "uniqueness for list of lists `testdata`", "cmd": "[list(i) for i in set(tuple(i) for i in testdata)]", "question_id": "3724551-76", "cmd_name": "conala", "oracle_man": ["python.library.functions#map", "python.library.functions#list", "python.library.functions#tuple", "python.library.stdtypes#set"], "canonical_cmd": "[list(i) for i in set(tuple(i) for i in VAR_STR)]"} {"nl": "download file from http url `file_url`", "cmd": "file_name = wget.download(file_url)", "question_id": "19602931-66", "cmd_name": "conala", "oracle_man": ["matplotlib.backend_webagg_api#matplotlib.backends.backend_webagg.WebAggApplication.Download"], "canonical_cmd": "file_name = wget.download(VAR_STR)"} {"nl": "produce a pivot table as dataframe using column 'Y' in datafram `df` to form the axes of the resulting dataframe", "cmd": "df.pivot_table('Y', rows='X', cols='X2')", "question_id": "9550867-20", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.pivot_table"], "canonical_cmd": "VAR_STR.pivot_table('VAR_STR', rows='X', cols='X2')"} {"nl": "remove duplicate dict in list `l`", "cmd": "[dict(t) for t in set([tuple(d.items()) for d in l])]", "question_id": "9427163-45", "cmd_name": "conala", "oracle_man": ["python.library.functions#tuple", "python.library.stdtypes#dict", "python.library.stdtypes#set", "python.library.stdtypes#dict.items"], "canonical_cmd": "[dict(t) for t in set([tuple(d.items()) for d in VAR_STR])]"} {"nl": "request url 'https://www.reporo.com/' without verifying SSL certificates", "cmd": "requests.get('https://www.reporo.com/', verify=False)", "question_id": "28667684-80", "cmd_name": "conala", "oracle_man": ["python.library.webbrowser#webbrowser.get"], "canonical_cmd": "requests.get('VAR_STR', verify=False)"} {"nl": "Filter queryset for all objects in Django model `MyModel` where texts length are greater than `254`", "cmd": "MyModel.objects.filter(text__regex='^.{254}.*')", "question_id": "23351183-55", "cmd_name": "conala", "oracle_man": ["python.library.logging#logging.Filter.filter"], "canonical_cmd": "VAR_STR.objects.filter(text__regex='^.{254}.*')"} {"nl": "Get value for \"username\" parameter in GET request in Django", "cmd": "request.GET.get('username', '')", "question_id": "23531030-8", "cmd_name": "conala", "oracle_man": [], "canonical_cmd": "request.GET.get('VAR_STR', '')"} {"nl": "convert binary string '\\x00\\x00\\x80?\\x00\\x00\\x00@\\x00\\x00@@\\x00\\x00\\x80@' to numpy array", "cmd": "np.fromstring('\\x00\\x00\\x80?\\x00\\x00\\x00@\\x00\\x00@@\\x00\\x00\\x80@', dtype='...', vf, vf)", "question_id": "19863964-8", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.einsum"], "canonical_cmd": "np.einsum('...j,...j->...', VAR_STR, VAR_STR)"} {"nl": "Get `3` unique items from a list", "cmd": "random.sample(list(range(1, 16)), 3)", "question_id": "6494508-48", "cmd_name": "conala", "oracle_man": ["python.library.random#random.sample", "python.library.functions#range", "python.library.functions#list"], "canonical_cmd": "random.sample(list(range(1, 16)), 3)"} {"nl": "convert string of bytes `y\\xcc\\xa6\\xbb` into an int", "cmd": "struct.unpack('j', a, b)", "question_id": "21562986-78", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.einsum"], "canonical_cmd": "np.einsum('ji,i->j', VAR_STR, VAR_STR)"} {"nl": "add field names as headers in csv constructor `writer`", "cmd": "writer.writeheader()", "question_id": "20347766-10", "cmd_name": "conala", "oracle_man": ["python.library.csv#csv.DictWriter.writeheader"], "canonical_cmd": "VAR_STR.writeheader()"} {"nl": "execute sql query 'INSERT INTO table VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)' with all parameters in list `tup`", "cmd": "cur.executemany('INSERT INTO table VALUES(%s,%s,%s,%s,%s,%s,%s,%s,%s)', tup)", "question_id": "8134602-90", "cmd_name": "conala", "oracle_man": ["python.library.sqlite3#sqlite3.Connection.executemany"], "canonical_cmd": "cur.executemany('VAR_STR', VAR_STR)"} {"nl": "lowercase string values with key 'content' in a list of dictionaries `messages`", "cmd": "[{'content': x['content'].lower()} for x in messages]", "question_id": "42353686-21", "cmd_name": "conala", "oracle_man": ["python.library.stdtypes#str.lower"], "canonical_cmd": "[{'VAR_STR': x['VAR_STR'].lower()} for x in VAR_STR]"} {"nl": "Unpack column 'stats' in dataframe `df` into a series of columns", "cmd": "df['stats'].apply(pd.Series)", "question_id": "29370211-89", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.series.apply"], "canonical_cmd": "VAR_STR['VAR_STR'].apply(pd.Series)"} {"nl": "lookup an attribute in any scope by name 'range'", "cmd": "getattr(__builtins__, 'range')", "question_id": "2850966-83", "cmd_name": "conala", "oracle_man": ["python.library.functions#getattr"], "canonical_cmd": "getattr(__builtins__, 'VAR_STR')"} {"nl": "Remove character `char` from a string `a`", "cmd": "a = a.replace(char, '')", "question_id": "3939361-45", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.char.replace"], "canonical_cmd": "VAR_STR = VAR_STR.replace(VAR_STR, '')"} {"nl": "Remove characters in `b` from a string `a`", "cmd": "a = a.replace(char, '')", "question_id": "3939361-16", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.char.replace"], "canonical_cmd": "VAR_STR = VAR_STR.replace(char, '')"} {"nl": "SQLAlchemy count the number of rows in table `Congress`", "cmd": "rows = session.query(Congress).count()", "question_id": "10822635-77", "cmd_name": "conala", "oracle_man": ["python.library.stdtypes#str.count"], "canonical_cmd": "rows = session.query(VAR_STR).count()"} {"nl": "find the index of the second occurrence of the substring `bar` in string `foo bar bar bar`", "cmd": "\"\"\"foo bar bar bar\"\"\".replace('bar', 'XXX', 1).find('bar')", "question_id": "1883980-4", "cmd_name": "conala", "oracle_man": ["python.library.stdtypes#str.find", "python.library.stdtypes#str.replace"], "canonical_cmd": "\"\"\"VAR_STR\"\"\".replace('VAR_STR', 'XXX', 1).find('VAR_STR')"} {"nl": "concatenate a series `students` onto a dataframe `marks` with pandas", "cmd": "pd.concat([students, pd.DataFrame(marks)], axis=1)", "question_id": "20512297-60", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.concat", "pandas.reference.api.pandas.dataframe"], "canonical_cmd": "pd.concat([VAR_STR, pd.DataFrame(VAR_STR)], axis=1)"} {"nl": "create list `randomList` with 10 random floating point numbers between 0.0 and 1.0", "cmd": "randomList = [random.random() for _ in range(10)]", "question_id": "20733827-49", "cmd_name": "conala", "oracle_man": ["python.library.functions#range"], "canonical_cmd": "VAR_STR = [random.random() for _ in range(10)]"} {"nl": "create dictionary from list of variables 'foo' and 'bar' already defined", "cmd": "dict((k, globals()[k]) for k in ('foo', 'bar'))", "question_id": "9495262-53", "cmd_name": "conala", "oracle_man": ["python.library.functions#globals", "python.library.stdtypes#dict"], "canonical_cmd": "dict((k, globals()[k]) for k in ('VAR_STR', 'VAR_STR'))"} {"nl": "get a dataframe `df2` that contains all the columns of dataframe `df` that do not end in `prefix`", "cmd": "df2 = df.ix[:, (~df.columns.str.endswith('prefix'))]", "question_id": "38426168-57", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.series.str.endswith"], "canonical_cmd": "VAR_STR = VAR_STR.ix[:, (~VAR_STR.columns.str.endswith('VAR_STR'))]"} {"nl": "substract 1 hour and 10 minutes from current time", "cmd": "t = datetime.datetime.now()\n(t - datetime.timedelta(hours=1, minutes=10))", "question_id": "14043934-77", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.datetime.now", "python.library.datetime#datetime.timedelta"], "canonical_cmd": "t = datetime.datetime.now()\nt - datetime.timedelta(hours=1, minutes=10)"} {"nl": "add 1 hour and 2 minutes to time object `t`", "cmd": "dt = datetime.datetime.combine(datetime.date.today(), t)", "question_id": "14043934-78", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.date.today", "python.library.datetime#datetime.datetime.combine"], "canonical_cmd": "dt = datetime.datetime.combine(datetime.date.today(), VAR_STR)"} {"nl": "Create new string with unique characters from `s` seperated by ' '", "cmd": "print(' '.join(OrderedDict.fromkeys(s)))", "question_id": "29360607-46", "cmd_name": "conala", "oracle_man": ["python.library.stdtypes#dict.fromkeys", "python.library.stdtypes#str.join"], "canonical_cmd": "print(' '.join(OrderedDict.fromkeys(VAR_STR)))"} {"nl": "create a set from string `s` to remove duplicate characters", "cmd": "print(' '.join(set(s)))", "question_id": "29360607-46", "cmd_name": "conala", "oracle_man": ["python.library.stdtypes#dict.fromkeys", "python.library.stdtypes#str.join"], "canonical_cmd": "print(' '.join(set(VAR_STR)))"} {"nl": "find the index of the maximum value in the array `arr` where the boolean condition in array `cond` is true", "cmd": "np.ma.array(np.tile(arr, 2).reshape(2, 3), mask=~cond).argmax(axis=1)", "question_id": "31767173-52", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.ma.array", "numpy.reference.generated.numpy.tile", "numpy.reference.generated.numpy.ma.argmax", "numpy.reference.generated.numpy.ma.reshape"], "canonical_cmd": "np.ma.array(np.tile(VAR_STR, 2).reshape(2, 3), mask=~VAR_STR).argmax(axis=1)"} {"nl": "Get data from matplotlib plot", "cmd": "gca().get_lines()[n].get_xydata()", "question_id": "8938449-32", "cmd_name": "conala", "oracle_man": ["matplotlib._as_gen.matplotlib.lines.line2d#matplotlib.lines.Line2D.get_xydata", "matplotlib.legend_api#matplotlib.legend.Legend.get_lines", "matplotlib.figure_api#matplotlib.figure.SubFigure.gca"], "canonical_cmd": "gca().get_lines()[n].get_xydata()"} {"nl": "BeautifulSoup search string 'Elsie' inside tag 'a'", "cmd": "soup.find_all('a', string='Elsie')", "question_id": "31958637-91", "cmd_name": "conala", "oracle_man": [], "canonical_cmd": "soup.find_all('VAR_STR', string='VAR_STR')"} {"nl": "create a dataframe containing the multiplication of element-wise in dataframe `df` and dataframe `df2` using index name and column labels of dataframe `df`", "cmd": "pd.DataFrame(df.values * df2.values, columns=df.columns, index=df.index)", "question_id": "21022865-77", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe"], "canonical_cmd": "pd.DataFrame(VAR_STR.values * VAR_STR.values, columns=VAR_STR.columns, index=\n VAR_STR.index)"} {"nl": "sort a list of dictionaries `list_of_dct` by values in an order `order`", "cmd": "sorted(list_of_dct, key=lambda x: order.index(list(x.values())[0]))", "question_id": "35078261-21", "cmd_name": "conala", "oracle_man": ["python.library.functions#sorted", "python.library.functions#list", "pandas.reference.api.pandas.index.values"], "canonical_cmd": "sorted(VAR_STR, key=lambda x: VAR_STR.index(list(x.values())[0]))"} {"nl": "concatenate dataframe `df1` with `df2` whilst removing duplicates", "cmd": "pandas.concat([df1, df2]).drop_duplicates().reset_index(drop=True)", "question_id": "21317384-58", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.concat", "pandas.reference.api.pandas.dataframe.reset_index", "pandas.reference.api.pandas.dataframe.drop_duplicates"], "canonical_cmd": "pandas.concat([VAR_STR, VAR_STR]).drop_duplicates().reset_index(drop=True)"} {"nl": "pretty-print ordered dictionary `o`", "cmd": "pprint(dict(list(o.items())))", "question_id": "4301069-72", "cmd_name": "conala", "oracle_man": ["python.library.stdtypes#dict", "python.library.functions#list", "python.library.stdtypes#dict.items", "python.library.pprint#pprint.pprint"], "canonical_cmd": "pprint(dict(list(VAR_STR.items())))"} {"nl": "import a nested module `c.py` within `b` within `a` with importlib", "cmd": "importlib.import_module('.c', 'a.b')", "question_id": "10675054-45", "cmd_name": "conala", "oracle_man": ["python.library.importlib#importlib.import_module"], "canonical_cmd": "importlib.import_module('.c', 'a.b')"} {"nl": "import a module 'a.b.c' with importlib.import_module in python 2", "cmd": "importlib.import_module('a.b.c')", "question_id": "10675054-25", "cmd_name": "conala", "oracle_man": ["python.library.importlib#importlib.import_module"], "canonical_cmd": "importlib.import_module('VAR_STR')"} {"nl": "update fields in Django model `Book` with arguments in dictionary `d` where primary key is equal to `pk`", "cmd": "Book.objects.filter(pk=pk).update(**d)", "question_id": "5503925-38", "cmd_name": "conala", "oracle_man": ["python.library.logging#logging.Filter.filter", "python.library.stdtypes#dict.update"], "canonical_cmd": "VAR_STR.objects.filter(VAR_STR=VAR_STR).update(**VAR_STR)"} {"nl": "update the fields in django model `Book` using dictionary `d`", "cmd": "Book.objects.create(**d)", "question_id": "5503925-47", "cmd_name": "conala", "oracle_man": ["python.library.venv#venv.create"], "canonical_cmd": "VAR_STR.objects.create(**VAR_STR)"} {"nl": "Generate MD5 checksum of file in the path `full_path` in hashlib", "cmd": "print(hashlib.md5(open(full_path, 'rb').read()).hexdigest())", "question_id": "3431825-77", "cmd_name": "conala", "oracle_man": ["python.library.urllib.request#open", "python.library.hashlib#hashlib.hash.hexdigest", "python.library.os#os.read"], "canonical_cmd": "print(hashlib.md5(open(VAR_STR, 'rb').read()).hexdigest())"} {"nl": "Get the number of NaN values in each column of dataframe `df`", "cmd": "df.isnull().sum()", "question_id": "26266362-41", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.isnull", "python.library.functions#sum"], "canonical_cmd": "VAR_STR.isnull().sum()"} {"nl": "find all anchor tags in html `soup` whose url begins with `http://www.iwashere.com`", "cmd": "soup.find_all('a', href=re.compile('http://www\\\\.iwashere\\\\.com/'))", "question_id": "15313250-71", "cmd_name": "conala", "oracle_man": ["python.library.re#re.compile"], "canonical_cmd": "VAR_STR.find_all('a', href=re.compile('http://www\\\\.iwashere\\\\.com/'))"} {"nl": "find all anchors with a hyperlink that matches the pattern '^(?!(?:[a-zA-Z][a-zA-Z0-9+.-]*:|//))'", "cmd": "soup.find_all('a', href=re.compile('^(?!(?:[a-zA-Z][a-zA-Z0-9+.-]*:|//))'))", "question_id": "15313250-56", "cmd_name": "conala", "oracle_man": ["python.library.re#re.compile"], "canonical_cmd": "soup.find_all('a', href=re.compile('VAR_STR'))"} {"nl": "generate a random 12-digit number", "cmd": "int(''.join(str(random.randint(0, 9)) for _ in range(12)))", "question_id": "13496087-15", "cmd_name": "conala", "oracle_man": ["python.library.random#random.randint", "python.library.functions#range", "python.library.functions#int", "python.library.stdtypes#str", "python.library.stdtypes#str.join"], "canonical_cmd": "int(''.join(str(random.randint(0, 9)) for _ in range(12)))"} {"nl": "generate a random 12-digit number", "cmd": "\"\"\"\"\"\".join(str(random.randint(0, 9)) for _ in range(12))", "question_id": "13496087-80", "cmd_name": "conala", "oracle_man": ["python.library.random#random.randint", "python.library.functions#range", "python.library.stdtypes#str", "python.library.stdtypes#str.join"], "canonical_cmd": "\"\"\"\"\"\".join(str(random.randint(0, 9)) for _ in range(12))"} {"nl": "How to delete a record in Django models?", "cmd": "SomeModel.objects.filter(id=id).delete()", "question_id": "3805958-22", "cmd_name": "conala", "oracle_man": ["python.library.logging#logging.Filter.filter", "python.library.ast#ast.Delete"], "canonical_cmd": "SomeModel.objects.filter(id=id).delete()"} {"nl": "retrieve all items in an numpy array 'x' except the item of the index 1", "cmd": "x[(np.arange(x.shape[0]) != 1), :, :]", "question_id": "8712332-35", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.arange"], "canonical_cmd": "VAR_STR[(np.arange(VAR_STR.shape[0]) != 1), :, :]"} {"nl": "split dataframe `df` where the value of column `a` is equal to 'B'", "cmd": "df.groupby((df.a == 'B').shift(1).fillna(0).cumsum())", "question_id": "13353233-57", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.groupby", "pandas.reference.api.pandas.dataframe.fillna", "pandas.reference.api.pandas.dataframe.shift", "pandas.reference.api.pandas.dataframe.cumsum"], "canonical_cmd": "VAR_STR.groupby((VAR_STR.VAR_STR == 'VAR_STR').shift(1).fillna(0).cumsum())"} {"nl": "removing control characters from a string `s`", "cmd": "return ''.join(ch for ch in s if unicodedata.category(ch)[0] != 'C')", "question_id": "4324790-58", "cmd_name": "conala", "oracle_man": ["python.library.unicodedata#unicodedata.category", "python.library.stdtypes#str.join"], "canonical_cmd": "return ''.join(ch for ch in VAR_STR if unicodedata.category(ch)[0] != 'C')"} {"nl": "return a DateTime object with the current UTC date", "cmd": "today = datetime.datetime.utcnow().date()", "question_id": "27587127-62", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.datetime.utcnow", "python.library.datetime#datetime.datetime.date"], "canonical_cmd": "today = datetime.datetime.utcnow().date()"} {"nl": "remove decimal points in pandas data frame using round", "cmd": "df.round()", "question_id": "37084812-85", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.round"], "canonical_cmd": "df.round()"} {"nl": "print the truth value of `a`", "cmd": "print(bool(a))", "question_id": "39604780-88", "cmd_name": "conala", "oracle_man": ["python.library.functions#bool"], "canonical_cmd": "print(bool(VAR_STR))"} {"nl": "Parsing HTML string `html` using BeautifulSoup", "cmd": "parsed_html = BeautifulSoup(html)\nprint(parsed_html.body.find('div', attrs={'class': 'container', }).text)", "question_id": "11709079-7", "cmd_name": "conala", "oracle_man": ["python.library.stdtypes#str.find"], "canonical_cmd": "parsed_html = BeautifulSoup(VAR_STR)\nprint(parsed_html.body.find('div', attrs={'class': 'container'}).text)"} {"nl": "convert a column of list in series `s` to dummies", "cmd": "pd.get_dummies(s.apply(pd.Series).stack()).sum(level=0)", "question_id": "29034928-61", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.get_dummies", "python.library.functions#sum", "pandas.reference.api.pandas.series.apply", "pandas.reference.api.pandas.dataframe.stack"], "canonical_cmd": "pd.get_dummies(VAR_STR.apply(pd.Series).stack()).sum(level=0)"} {"nl": "create a matrix from a list `[1, 2, 3]`", "cmd": "x = scipy.matrix([1, 2, 3]).transpose()", "question_id": "4690366-20", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.matrix.transpose"], "canonical_cmd": "x = scipy.matrix([VAR_STR]).transpose()"} {"nl": "convert radians 1 to degrees", "cmd": "math.cos(math.radians(1))", "question_id": "9875964-60", "cmd_name": "conala", "oracle_man": ["python.library.math#math.radians", "python.library.math#math.cos"], "canonical_cmd": "math.cos(math.radians(1))"} {"nl": "create an empty data frame `df2` with index from another data frame `df1`", "cmd": "df2 = pd.DataFrame(index=df1.index)", "question_id": "18176933-47", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe"], "canonical_cmd": "VAR_STR = pd.DataFrame(index=VAR_STR.index)"} {"nl": "make a window `root` jump to the front", "cmd": "root.attributes('-topmost', True)", "question_id": "1892339-81", "cmd_name": "conala", "oracle_man": ["python.library.xml.dom#xml.dom.Node.attributes"], "canonical_cmd": "VAR_STR.attributes('-topmost', True)"} {"nl": "apply function `log2` to the grouped values by 'type' in dataframe `df`", "cmd": "df.groupby('type').apply(lambda x: np.mean(np.log2(x['v'])))", "question_id": "18137341-8", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.log2", "numpy.reference.generated.numpy.mean", "pandas.reference.api.pandas.dataframe.groupby", "pandas.reference.api.pandas.dataframe.apply"], "canonical_cmd": "VAR_STR.groupby('VAR_STR').apply(lambda x: np.mean(np.VAR_STR(x['v'])))"} {"nl": "Convert JSON array `array` to Python object", "cmd": "data = json.loads(array)", "question_id": "10973614-40", "cmd_name": "conala", "oracle_man": ["python.library.json#json.loads"], "canonical_cmd": "data = json.loads(VAR_STR)"} {"nl": "Convert JSON array `array` to Python object", "cmd": "data = json.loads(array)", "question_id": "10973614-6", "cmd_name": "conala", "oracle_man": ["python.library.json#json.loads"], "canonical_cmd": "data = json.loads(VAR_STR)"} {"nl": "print number 1255000 as thousands separators", "cmd": "locale.setlocale(locale.LC_ALL, 'en_US')\nlocale.format('%d', 1255000, grouping=True)", "question_id": "1823058-88", "cmd_name": "conala", "oracle_man": ["python.library.locale#locale.setlocale", "python.library.locale#locale.format"], "canonical_cmd": "locale.setlocale(locale.LC_ALL, 'en_US')\nlocale.format('%d', 1255000, grouping=True)"} {"nl": "Filter a json from a key-value pair as `{'fixed_key_1': 'foo2'}` in Django", "cmd": "Test.objects.filter(actions__contains=[{'fixed_key_1': 'foo2'}])", "question_id": "34358278-63", "cmd_name": "conala", "oracle_man": ["python.library.logging#logging.Filter.filter"], "canonical_cmd": "Test.objects.filter(actions__contains=[{VAR_STR}])"} {"nl": "Move x-axis of the pyplot object `ax` to the top of a plot in matplotlib", "cmd": "ax.xaxis.set_ticks_position('top')", "question_id": "14406214-99", "cmd_name": "conala", "oracle_man": ["matplotlib._as_gen.matplotlib.axis.xaxis.set_ticks_position"], "canonical_cmd": "VAR_STR.xaxis.set_ticks_position('top')"} {"nl": "check if date `yourdatetime` is equal to today's date", "cmd": "yourdatetime.date() == datetime.today().date()", "question_id": "6407362-46", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.date.today", "python.library.datetime#datetime.date"], "canonical_cmd": "VAR_STR.date() == datetime.today().date()"} {"nl": "disable the certificate check in https requests for url `https://kennethreitz.com`", "cmd": "requests.get('https://kennethreitz.com', verify=False)", "question_id": "15445981-81", "cmd_name": "conala", "oracle_man": ["python.library.webbrowser#webbrowser.get"], "canonical_cmd": "requests.get('VAR_STR', verify=False)"} {"nl": "create a list containing all cartesian products of elements in list `a`", "cmd": "list(itertools.product(*a))", "question_id": "798854-41", "cmd_name": "conala", "oracle_man": ["python.library.itertools#itertools.product", "python.library.functions#list"], "canonical_cmd": "list(itertools.product(*VAR_STR))"} {"nl": "generate a random string of length `x` containing lower cased ASCII letters", "cmd": "\"\"\"\"\"\".join(random.choice(string.lowercase) for x in range(X))", "question_id": "1957273-17", "cmd_name": "conala", "oracle_man": ["python.library.random#random.choice", "python.library.functions#range", "python.library.stdtypes#str.join"], "canonical_cmd": "\"\"\"\"\"\".join(random.choice(string.lowercase) for VAR_STR in range(X))"} {"nl": "get current datetime in ISO format", "cmd": "datetime.datetime.now().isoformat()", "question_id": "2150739-61", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.datetime.now", "python.library.datetime#datetime.datetime.isoformat"], "canonical_cmd": "datetime.datetime.now().isoformat()"} {"nl": "get UTC datetime in ISO format", "cmd": "datetime.datetime.utcnow().isoformat()", "question_id": "2150739-5", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.datetime.utcnow", "python.library.datetime#datetime.datetime.isoformat"], "canonical_cmd": "datetime.datetime.utcnow().isoformat()"} {"nl": "Keep only unique words in list of words `words` and join into string", "cmd": "print(' '.join(sorted(set(words), key=words.index)))", "question_id": "7794208-3", "cmd_name": "conala", "oracle_man": ["python.library.functions#sorted", "python.library.stdtypes#set", "pandas.reference.api.pandas.index.join"], "canonical_cmd": "print(' '.join(sorted(set(VAR_STR), key=VAR_STR.index)))"} {"nl": "plot logarithmic axes with matplotlib", "cmd": "ax.set_yscale('log')", "question_id": "773814-28", "cmd_name": "conala", "oracle_man": ["matplotlib.projections_api#matplotlib.projections.polar.PolarAxes.set_yscale"], "canonical_cmd": "ax.set_yscale('log')"} {"nl": "convert a number 2130706433 to ip string", "cmd": "socket.inet_ntoa(struct.pack('!L', 2130706433))", "question_id": "9590965-88", "cmd_name": "conala", "oracle_man": ["python.library.struct#struct.pack", "python.library.socket#socket.inet_ntoa"], "canonical_cmd": "socket.inet_ntoa(struct.pack('!L', 2130706433))"} {"nl": "numpy: check if array 'a' contains all the numbers in array 'b'.", "cmd": "numpy.array([(x in a) for x in b])", "question_id": "10565598-47", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.array"], "canonical_cmd": "numpy.array([(x in VAR_STR) for x in VAR_STR])"} {"nl": "Write column 'sum' of DataFrame `a` to csv file 'test.csv'", "cmd": "a.to_csv('test.csv', cols=['sum'])", "question_id": "21206395-91", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.to_csv"], "canonical_cmd": "VAR_STR.to_csv('VAR_STR', cols=['VAR_STR'])"} {"nl": "filter dataframe `grouped` where the length of each group `x` is bigger than 1", "cmd": "grouped.filter(lambda x: len(x) > 1)", "question_id": "13167391-7", "cmd_name": "conala", "oracle_man": ["python.library.functions#len", "python.library.logging#logging.Filter.filter"], "canonical_cmd": "VAR_STR.filter(lambda VAR_STR: len(VAR_STR) > 1)"} {"nl": "set the y axis range to `0, 1000` in subplot using pylab", "cmd": "pylab.ylim([0, 1000])", "question_id": "2849286-49", "cmd_name": "conala", "oracle_man": ["matplotlib._as_gen.matplotlib.pyplot.ylim"], "canonical_cmd": "pylab.ylim([0, 1000])"} {"nl": "get yesterday's date as a string in `YYYY-MM-DD` format using timedelta", "cmd": "(datetime.now() - timedelta(1)).strftime('%Y-%m-%d')", "question_id": "30483977-35", "cmd_name": "conala", "oracle_man": ["python.library.datetime#datetime.datetime.now", "python.library.datetime#datetime.datetime.strftime", "python.library.datetime#datetime.timedelta"], "canonical_cmd": "(datetime.now() - timedelta(1)).strftime('%Y-%m-%d')"} {"nl": "Display a image file `pathToFile`", "cmd": "Image.open('pathToFile').show()", "question_id": "5333244-64", "cmd_name": "conala", "oracle_man": ["python.library.urllib.request#open"], "canonical_cmd": "Image.open('VAR_STR').show()"} {"nl": "convert decimal `8` to binary list", "cmd": "[int(x) for x in bin(8)[2:]]", "question_id": "13557937-95", "cmd_name": "conala", "oracle_man": ["python.library.functions#bin", "python.library.functions#int"], "canonical_cmd": "[int(x) for x in bin(8)[2:]]"} {"nl": "Rename a folder `Joe Blow` to `Blow, Joe`", "cmd": "os.rename('Joe Blow', 'Blow, Joe')", "question_id": "8735312-37", "cmd_name": "conala", "oracle_man": ["python.library.os#os.rename"], "canonical_cmd": "os.rename('VAR_STR', 'VAR_STR')"} {"nl": "create a 2D array of `Node` objects with dimensions `cols` columns and `rows` rows", "cmd": "nodes = [[Node() for j in range(cols)] for i in range(rows)]", "question_id": "6480441-53", "cmd_name": "conala", "oracle_man": ["python.library.functions#range", "python.library.platform#platform.node"], "canonical_cmd": "nodes = [[VAR_STR() for j in range(VAR_STR)] for i in range(VAR_STR)]"} {"nl": "get the indexes of the x and y axes in Numpy array `np` where variable `a` is equal to variable `value`", "cmd": "i, j = np.where(a == value)", "question_id": "18079029-69", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.where"], "canonical_cmd": "i, j = VAR_STR.where(VAR_STR == VAR_STR)"} {"nl": "Convert a binary value '1633837924' to string", "cmd": "struct.pack('q', s)[0]", "question_id": "4433017-13", "cmd_name": "conala", "oracle_man": ["python.library.struct#struct.unpack"], "canonical_cmd": "struct.unpack('>q', VAR_STR)[0]"} {"nl": "Get a random string of length `length`", "cmd": "return ''.join(random.choice(string.lowercase) for i in range(length))", "question_id": "2030053-18", "cmd_name": "conala", "oracle_man": ["python.library.random#random.choice", "python.library.functions#range", "python.library.stdtypes#str.join"], "canonical_cmd": "return ''.join(random.choice(string.lowercase) for i in range(VAR_STR))"} {"nl": "access the class variable `a_string` from a class object `test`", "cmd": "getattr(test, a_string)", "question_id": "13303100-52", "cmd_name": "conala", "oracle_man": ["python.library.functions#getattr"], "canonical_cmd": "getattr(VAR_STR, VAR_STR)"} {"nl": "disable abbreviation in argparse", "cmd": "parser = argparse.ArgumentParser(allow_abbrev=False)", "question_id": "10750802-58", "cmd_name": "conala", "oracle_man": ["python.library.argparse#argparse.ArgumentParser"], "canonical_cmd": "parser = argparse.ArgumentParser(allow_abbrev=False)"} {"nl": "get a dictionary in list `dicts` which key 'ratio' is closer to a global value 1.77672955975", "cmd": "min(dicts, key=lambda x: (abs(1.77672955975 - x['ratio']), -x['pixels']))", "question_id": "42442428-5", "cmd_name": "conala", "oracle_man": ["python.library.functions#abs", "python.library.functions#min"], "canonical_cmd": "min(VAR_STR, key=lambda x: (abs(1.77672955975 - x['VAR_STR']), -x['pixels']))"} {"nl": "copy the content of file 'file.txt' to file 'file2.txt'", "cmd": "shutil.copy('file.txt', 'file2.txt')", "question_id": "36875258-12", "cmd_name": "conala", "oracle_man": ["python.library.shutil#shutil.copy"], "canonical_cmd": "shutil.copy('VAR_STR', 'VAR_STR')"} {"nl": "Calling an external command \"echo Hello World\"", "cmd": "print(subprocess.Popen('echo Hello World', shell=True, stdout=subprocess.PIPE).stdout.read())", "question_id": "89228-69", "cmd_name": "conala", "oracle_man": ["python.library.subprocess#subprocess.Popen", "python.library.os#os.read"], "canonical_cmd": "print(subprocess.Popen('VAR_STR', shell=True, stdout=subprocess.PIPE).stdout.\n read())"} {"nl": "Calling an external command \"echo Hello World\"", "cmd": "print(os.popen('echo Hello World').read())", "question_id": "89228-17", "cmd_name": "conala", "oracle_man": ["python.library.os#os.popen", "python.library.os#os.read"], "canonical_cmd": "print(os.popen('VAR_STR').read())"} {"nl": "Calling an external command \"ls\"", "cmd": "p = subprocess.Popen('ls', shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)\nfor line in p.stdout.readlines():\n print(line, end=' ')\nretval = p.wait()", "question_id": "89228-83", "cmd_name": "conala", "oracle_man": ["python.library.subprocess#subprocess.Popen", "python.library.subprocess#subprocess.Popen.wait", "python.library.io#io.IOBase.readlines"], "canonical_cmd": "p = subprocess.Popen('VAR_STR', shell=True, stdout=subprocess.PIPE, stderr=\n subprocess.STDOUT)\nfor line in p.stdout.readlines():\n print(line, end=' ')\nretval = p.wait()"} {"nl": "convert numpy array into python list structure", "cmd": "np.array([[1, 2, 3], [4, 5, 6]]).tolist()", "question_id": "1966207-46", "cmd_name": "conala", "oracle_man": ["numpy.reference.generated.numpy.array", "python.library.array#array.array.tolist"], "canonical_cmd": "np.array([[1, 2, 3], [4, 5, 6]]).tolist()"} {"nl": "rename file `dir` to `dir` + '!'", "cmd": "os.rename(dir, dir + '!')", "question_id": "11816315-65", "cmd_name": "conala", "oracle_man": ["python.library.os#os.rename"], "canonical_cmd": "os.rename(VAR_STR, VAR_STR + 'VAR_STR')"} {"nl": "find the current directory", "cmd": "os.getcwd()", "question_id": "5137497-38", "cmd_name": "conala", "oracle_man": ["python.library.os#os.getcwd"], "canonical_cmd": "os.getcwd()"} {"nl": "Find current directory", "cmd": "cwd = os.getcwd()", "question_id": "5137497-54", "cmd_name": "conala", "oracle_man": ["python.library.os#os.getcwd"], "canonical_cmd": "cwd = os.getcwd()"} {"nl": "use operations like max/min within a row to a dataframe 'd' in pandas", "cmd": "d.apply(lambda row: min([row['A'], row['B']]) - row['C'], axis=1)", "question_id": "12376863-62", "cmd_name": "conala", "oracle_man": ["python.library.functions#min"], "canonical_cmd": "VAR_STR.apply(lambda row: min([row['A'], row['B']]) - row['C'], axis=1)"} {"nl": "How to plot with x-axis at the top of the figure?", "cmd": "ax.xaxis.set_ticks_position('top')", "question_id": "8639973-88", "cmd_name": "conala", "oracle_man": ["matplotlib._as_gen.matplotlib.axis.xaxis.set_ticks_position"], "canonical_cmd": "ax.xaxis.set_ticks_position('top')"} {"nl": "sum the column `positions` along the other columns `stock`, `same1`, `same2` in a pandas data frame `df`", "cmd": "df.groupby(['stock', 'same1', 'same2'], as_index=False)['positions'].sum()", "question_id": "17166601-53", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.groupby", "python.library.functions#sum"], "canonical_cmd": "VAR_STR.groupby(['VAR_STR', 'VAR_STR', 'VAR_STR'], as_index=False)['VAR_STR'].sum()"} {"nl": "Summing across rows of Pandas Dataframe", "cmd": "df.groupby(['stock', 'same1', 'same2'])['positions'].sum().reset_index()", "question_id": "17166601-28", "cmd_name": "conala", "oracle_man": ["pandas.reference.api.pandas.dataframe.groupby", "python.library.functions#sum", "pandas.reference.api.pandas.dataframe.reset_index"], "canonical_cmd": "df.groupby(['stock', 'same1', 'same2'])['positions'].sum().reset_index()"}