question_id
stringlengths 7
12
| nl
stringlengths 4
200
| cmd
stringlengths 2
232
| oracle_man
list | canonical_cmd
stringlengths 2
228
| cmd_name
stringclasses 1
value |
---|---|---|---|---|---|
19490064-50
|
merge rows from dataframe `df1` with rows from dataframe `df2` and calculate the mean for rows that have the same value of axis 1
|
pd.concat((df1, df2), axis=1).mean(axis=1)
|
[
"pandas.reference.api.pandas.concat",
"pandas.reference.api.pandas.dataframe.mean"
] |
pd.concat((VAR_STR, VAR_STR), axis=1).mean(axis=1)
|
conala
|
4880960-33
|
sum of all values in a python dict `d`
|
sum(d.values())
|
[
"python.library.functions#sum",
"python.library.stdtypes#dict.values"
] |
sum(VAR_STR.values())
|
conala
|
4880960-87
|
Sum of all values in a Python dict
|
sum(d.values())
|
[
"python.library.functions#sum",
"python.library.stdtypes#dict.values"
] |
sum(d.values())
|
conala
|
627435-73
|
remove the last element in list `a`
|
del a[(-1)]
|
[] |
del VAR_STR[-1]
|
conala
|
627435-63
|
remove the element in list `a` with index 1
|
a.pop(1)
|
[
"python.library.stdtypes#frozenset.pop"
] |
VAR_STR.pop(1)
|
conala
|
627435-40
|
remove the last element in list `a`
|
a.pop()
|
[
"python.library.stdtypes#frozenset.pop"
] |
VAR_STR.pop()
|
conala
|
627435-31
|
remove the element in list `a` at index `index`
|
a.pop(index)
|
[
"python.library.stdtypes#frozenset.pop"
] |
VAR_STR.pop(VAR_STR)
|
conala
|
627435-36
|
remove the element in list `a` at index `index`
|
del a[index]
|
[] |
del VAR_STR[VAR_STR]
|
conala
|
16868457-20
|
sort a dictionary `d` by length of its values and print as string
|
print(' '.join(sorted(d, key=lambda k: len(d[k]), reverse=True)))
|
[
"python.library.functions#sorted",
"python.library.functions#len",
"python.library.stdtypes#str.join"
] |
print(' '.join(sorted(VAR_STR, key=lambda k: len(VAR_STR[k]), reverse=True)))
|
conala
|
8172861-52
|
Replace comma with dot in a string `original_string` using regex
|
new_string = re.sub('"(\\d+),(\\d+)"', '\\1.\\2', original_string)
|
[
"python.library.re#re.sub"
] |
new_string = re.sub('"(\\d+),(\\d+)"', '\\1.\\2', VAR_STR)
|
conala
|
20084487-20
|
plot data of column 'index' versus column 'A' of dataframe `monthly_mean` after resetting its index
|
monthly_mean.reset_index().plot(x='index', y='A')
|
[
"pandas.reference.api.pandas.dataframe.reset_index",
"pandas.reference.api.pandas.dataframe.plot"
] |
VAR_STR.reset_index().plot(x='VAR_STR', y='VAR_STR')
|
conala
|
5971312-4
|
set environment variable 'DEBUSSY' equal to 1
|
os.environ['DEBUSSY'] = '1'
|
[] |
os.environ['VAR_STR'] = '1'
|
conala
|
5971312-29
|
Get a environment variable `DEBUSSY`
|
print(os.environ['DEBUSSY'])
|
[] |
print(os.environ['VAR_STR'])
|
conala
|
5971312-73
|
set environment variable 'DEBUSSY' to '1'
|
os.environ['DEBUSSY'] = '1'
|
[] |
os.environ['VAR_STR'] = 'VAR_STR'
|
conala
|
4921038-69
|
flask-sqlalchemy delete row `page`
|
db.session.delete(page)
|
[
"python.library.ast#ast.Delete"
] |
db.session.delete(VAR_STR)
|
conala
|
14301913-69
|
convert pandas group by object to multi-indexed dataframe with indices 'Name' and 'Destination'
|
df.set_index(['Name', 'Destination'])
|
[
"pandas.reference.api.pandas.dataframe.set_index"
] |
df.set_index(['VAR_STR', 'VAR_STR'])
|
conala
|
6504200-56
|
decode unicode string `s` into a readable unicode literal
|
s.decode('unicode_escape')
|
[
"python.library.stdtypes#bytearray.decode"
] |
VAR_STR.decode('unicode_escape')
|
conala
|
3262437-3
|
get the non-masked values of array `m`
|
m[~m.mask]
|
[] |
VAR_STR[~VAR_STR.mask]
|
conala
|
4859292-70
|
get a random key `country` and value `capital` form a dictionary `d`
|
country, capital = random.choice(list(d.items()))
|
[
"python.library.random#random.choice",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
VAR_STR, VAR_STR = random.choice(list(VAR_STR.items()))
|
conala
|
12777222-51
|
zip file `pdffile` using its basename as directory name
|
archive.write(pdffile, os.path.basename(pdffile))
|
[
"python.library.os.path#os.path.basename",
"python.library.os#os.write"
] |
archive.write(VAR_STR, os.path.basename(VAR_STR))
|
conala
|
7323859-99
|
call bash command 'tar c my_dir | md5sum' with pipe
|
subprocess.call('tar c my_dir | md5sum', shell=True)
|
[
"python.library.subprocess#subprocess.call"
] |
subprocess.call('VAR_STR', shell=True)
|
conala
|
1185524-91
|
trim whitespace in string `s`
|
s.strip()
|
[
"python.library.stdtypes#str.strip"
] |
VAR_STR.strip()
|
conala
|
1185524-91
|
trim whitespace (including tabs) in `s` on the left side
|
s = s.lstrip()
|
[
"python.library.stdtypes#str.strip"
] |
VAR_STR = VAR_STR.lstrip()
|
conala
|
1185524-8
|
trim whitespace (including tabs) in `s` on the right side
|
s = s.rstrip()
|
[
"python.library.stdtypes#str.rstrip"
] |
VAR_STR = VAR_STR.rstrip()
|
conala
|
1185524-9
|
trim characters ' \t\n\r' in `s`
|
s = s.strip(' \t\n\r')
|
[
"python.library.stdtypes#str.strip"
] |
VAR_STR = VAR_STR.strip(' \t\n\r')
|
conala
|
1185524-31
|
trim whitespaces (including tabs) in string `s`
|
print(re.sub('[\\s+]', '', s))
|
[
"python.library.re#re.sub"
] |
print(re.sub('[\\s+]', '', VAR_STR))
|
conala
|
8409095-82
|
set color marker styles `--bo` in matplotlib
|
plt.plot(list(range(10)), '--bo')
|
[
"python.library.functions#range",
"python.library.functions#list",
"pandas.reference.api.pandas.dataframe.plot"
] |
plt.plot(list(range(10)), 'VAR_STR')
|
conala
|
8409095-48
|
set circle markers on plot for individual points defined in list `[1,2,3,4,5,6,7,8,9,10]` created by range(10)
|
plt.plot(list(range(10)), linestyle='--', marker='o', color='b')
|
[
"python.library.functions#range",
"python.library.functions#list",
"pandas.reference.api.pandas.dataframe.plot"
] |
plt.plot(list(range(10)), linestyle='--', marker='o', color='b')
|
conala
|
13438574-91
|
sort list `results` by keys value 'year'
|
sorted(results, key=itemgetter('year'))
|
[
"python.library.functions#sorted",
"python.library.operator#operator.itemgetter"
] |
sorted(VAR_STR, key=itemgetter('VAR_STR'))
|
conala
|
10078470-99
|
sort array `arr` in ascending order by values of the 3rd column
|
arr[arr[:, (2)].argsort()]
|
[
"numpy.reference.generated.numpy.argsort"
] |
VAR_STR[VAR_STR[:, (2)].argsort()]
|
conala
|
10078470-100
|
sort rows of numpy matrix `arr` in ascending order according to all column values
|
numpy.sort(arr, axis=0)
|
[
"numpy.reference.generated.numpy.sort"
] |
numpy.sort(VAR_STR, axis=0)
|
conala
|
2783079-30
|
Format a string `u'Andr\xc3\xa9'` that has unicode characters
|
"""""".join(chr(ord(c)) for c in 'Andr\xc3\xa9')
|
[
"python.library.functions#chr",
"python.library.functions#ord",
"python.library.stdtypes#str.join"
] |
"""""".join(chr(ord(c)) for c in 'André')
|
conala
|
2783079-88
|
convert a unicode 'Andr\xc3\xa9' to a string
|
"""""".join(chr(ord(c)) for c in 'Andr\xc3\xa9').decode('utf8')
|
[
"python.library.functions#chr",
"python.library.functions#ord",
"python.library.stdtypes#str.join",
"python.library.stdtypes#bytearray.decode"
] |
"""""".join(chr(ord(c)) for c in 'VAR_STR').decode('utf8')
|
conala
|
2372573-38
|
remove white spaces from the end of string " xyz "
|
""" xyz """.rstrip()
|
[
"python.library.stdtypes#str.rstrip"
] |
""" xyz """.rstrip()
|
conala
|
14295673-41
|
Convert string '03:55' into datetime.time object
|
datetime.datetime.strptime('03:55', '%H:%M').time()
|
[
"python.library.datetime#datetime.datetime.strptime",
"python.library.datetime#datetime.datetime.time"
] |
datetime.datetime.strptime('VAR_STR', '%H:%M').time()
|
conala
|
4059550-66
|
generate all possible string permutations of each two elements in list `['hel', 'lo', 'bye']`
|
print([''.join(a) for a in combinations(['hel', 'lo', 'bye'], 2)])
|
[
"python.library.itertools#itertools.combinations",
"python.library.stdtypes#str.join"
] |
print([''.join(a) for a in combinations([VAR_STR], 2)])
|
conala
|
3590165-87
|
print a list of integers `list_of_ints` using string formatting
|
print(', '.join(str(x) for x in list_of_ints))
|
[
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
print(', '.join(str(x) for x in VAR_STR))
|
conala
|
5555063-8
|
un-escaping characters in a string with python
|
"""\\u003Cp\\u003E""".decode('unicode-escape')
|
[
"python.library.stdtypes#bytearray.decode"
] |
"""\\u003Cp\\u003E""".decode('unicode-escape')
|
conala
|
9402255-38
|
save current figure to file 'graph.png' with resolution of 1000 dpi
|
plt.savefig('graph.png', dpi=1000)
|
[
"matplotlib.figure_api#matplotlib.figure.Figure.savefig"
] |
plt.savefig('VAR_STR', dpi=1000)
|
conala
|
38147259-48
|
Print a emoji from a string `\\ud83d\\ude4f` having surrogate pairs
|
"""\\ud83d\\ude4f""".encode('utf-16', 'surrogatepass').decode('utf-16')
|
[
"python.library.stdtypes#str.encode",
"python.library.stdtypes#bytearray.decode"
] |
"""VAR_STR""".encode('utf-16', 'surrogatepass').decode('utf-16')
|
conala
|
12589481-54
|
apply two different aggregating functions `mean` and `sum` to the same column `dummy` in pandas data frame `df`
|
df.groupby('dummy').agg({'returns': [np.mean, np.sum]})
|
[
"pandas.reference.api.pandas.dataframe.groupby",
"pandas.reference.api.pandas.dataframe.agg"
] |
VAR_STR.groupby('VAR_STR').agg({'returns': [np.VAR_STR, np.VAR_STR]})
|
conala
|
209840-22
|
map two lists `keys` and `values` into a dictionary
|
new_dict = {k: v for k, v in zip(keys, values)}
|
[
"python.library.functions#zip"
] |
new_dict = {k: v for k, v in zip(VAR_STR, VAR_STR)}
|
conala
|
209840-67
|
map two lists `keys` and `values` into a dictionary
|
dict((k, v) for k, v in zip(keys, values))
|
[
"python.library.functions#zip",
"python.library.stdtypes#dict"
] |
dict((k, v) for k, v in zip(VAR_STR, VAR_STR))
|
conala
|
209840-17
|
map two lists `keys` and `values` into a dictionary
|
dict([(k, v) for k, v in zip(keys, values)])
|
[
"python.library.functions#zip",
"python.library.stdtypes#dict"
] |
dict([(k, v) for k, v in zip(VAR_STR, VAR_STR)])
|
conala
|
38379453-42
|
get a list of substrings consisting of the first 5 characters of every string in list `buckets`
|
[s[:5] for s in buckets]
|
[] |
[s[:5] for s in VAR_STR]
|
conala
|
12329853-55
|
Rearrange the columns 'a','b','x','y' of pandas DataFrame `df` in mentioned sequence 'x' ,'y','a' ,'b'
|
df = df[['x', 'y', 'a', 'b']]
|
[] |
VAR_STR = VAR_STR[['VAR_STR', 'VAR_STR', 'VAR_STR', 'VAR_STR']]
|
conala
|
8586738-95
|
Get a list of all fields in class `User` that are marked `required`
|
[k for k, v in User._fields.items() if v.required]
|
[
"python.library.stdtypes#dict.items"
] |
[k for k, v in VAR_STR._fields.items() if v.VAR_STR]
|
conala
|
3817529-35
|
create a dictionary `{'spam': 5, 'ham': 6}` into another dictionary `d` field 'dict3'
|
d['dict3'] = {'spam': 5, 'ham': 6}
|
[] |
VAR_STR['VAR_STR'] = {VAR_STR}
|
conala
|
26720916-8
|
Get rank of rows from highest to lowest of dataframe `df`, grouped by value in column `group`, according to value in column `value`
|
df.groupby('group')['value'].rank(ascending=False)
|
[
"pandas.reference.api.pandas.dataframe.groupby",
"pandas.reference.api.pandas.dataframe.rank"
] |
VAR_STR.groupby('VAR_STR')['VAR_STR'].rank(ascending=False)
|
conala
|
19973489-29
|
remove column by index `[:, 0:2]` in dataframe `df`
|
df = df.ix[:, 0:2]
|
[] |
VAR_STR = VAR_STR.ix[VAR_STR]
|
conala
|
2397687-56
|
convert a list of hex byte strings `['BB', 'A7', 'F6', '9E']` to a list of hex integers
|
[int(x, 16) for x in ['BB', 'A7', 'F6', '9E']]
|
[
"python.library.functions#int"
] |
[int(x, 16) for x in [VAR_STR]]
|
conala
|
2397687-31
|
convert the elements of list `L` from hex byte strings to hex integers
|
[int(x, 16) for x in L]
|
[
"python.library.functions#int"
] |
[int(x, 16) for x in VAR_STR]
|
conala
|
1747817-96
|
Create a dictionary `d` from list `iterable`
|
d = dict(((key, value) for (key, value) in iterable))
|
[
"python.library.stdtypes#dict"
] |
VAR_STR = dict((key, value) for key, value in VAR_STR)
|
conala
|
1747817-8
|
Create a dictionary `d` from list `iterable`
|
d = {key: value for (key, value) in iterable}
|
[] |
VAR_STR = {key: value for key, value in VAR_STR}
|
conala
|
1747817-34
|
Create a dictionary `d` from list of key value pairs `iterable`
|
d = {k: v for (k, v) in iterable}
|
[] |
VAR_STR = {k: v for k, v in VAR_STR}
|
conala
|
22397058-19
|
drop a single subcolumn 'a' in column 'col1' from a dataframe `df`
|
df.drop(('col1', 'a'), axis=1)
|
[
"pandas.reference.api.pandas.dataframe.drop"
] |
VAR_STR.drop(('VAR_STR', 'VAR_STR'), axis=1)
|
conala
|
22397058-80
|
dropping all columns named 'a' from a multiindex 'df', across all level.
|
df.drop('a', level=1, axis=1)
|
[
"pandas.reference.api.pandas.dataframe.drop"
] |
VAR_STR.drop('VAR_STR', level=1, axis=1)
|
conala
|
13283689-71
|
return list `result` of sum of elements of each list `b` in list of lists `a`
|
result = [sum(b) for b in a]
|
[
"python.library.functions#sum"
] |
VAR_STR = [sum(VAR_STR) for VAR_STR in VAR_STR]
|
conala
|
13395888-35
|
make a line plot with errorbars, `ebar`, from data `x, y, err` and set color of the errorbars to `y` (yellow)
|
ebar = plt.errorbar(x, y, yerr=err, ecolor='y')
|
[
"matplotlib._as_gen.mpl_toolkits.mplot3d.axes3d.axes3d#mpl_toolkits.mplot3d.axes3d.Axes3D.errorbar"
] |
VAR_STR = plt.errorbar(x, VAR_STR, yerr=err, ecolor='VAR_STR')
|
conala
|
5285181-18
|
open a file `/home/user/test/wsservice/data.pkl` in binary write mode
|
output = open('/home/user/test/wsservice/data.pkl', 'wb')
|
[
"python.library.urllib.request#open"
] |
output = open('VAR_STR', 'wb')
|
conala
|
1388818-50
|
compare two lists in python `a` and `b` and return matches
|
set(a).intersection(b)
|
[
"python.library.stdtypes#set",
"python.library.stdtypes#frozenset.intersection"
] |
set(VAR_STR).intersection(VAR_STR)
|
conala
|
1388818-27
|
How can I compare two lists in python and return matches
|
[i for i, j in zip(a, b) if i == j]
|
[
"python.library.functions#zip"
] |
[i for i, j in zip(a, b) if i == j]
|
conala
|
20230211-71
|
sort a dictionary `a` by values that are list type
|
t = sorted(list(a.items()), key=lambda x: x[1])
|
[
"python.library.functions#sorted",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
t = sorted(list(VAR_STR.items()), key=lambda x: x[1])
|
conala
|
12985456-66
|
Replace all non-alphanumeric characters in a string
|
re.sub('[^0-9a-zA-Z]+', '*', 'h^&ell`.,|o w]{+orld')
|
[
"python.library.re#re.sub"
] |
re.sub('[^0-9a-zA-Z]+', '*', 'h^&ell`.,|o w]{+orld')
|
conala
|
9040939-18
|
find all possible sequences of elements in a list `[2, 3, 4]`
|
map(list, permutations([2, 3, 4]))
|
[
"python.library.functions#map",
"python.library.itertools#itertools.permutations"
] |
map(list, permutations([VAR_STR]))
|
conala
|
35797523-43
|
create a list by appending components from list `a` and reversed list `b` interchangeably
|
[value for pair in zip(a, b[::-1]) for value in pair]
|
[
"python.library.functions#zip"
] |
[value for pair in zip(VAR_STR, VAR_STR[::-1]) for value in pair]
|
conala
|
29386995-92
|
get http header of the key 'your-header-name' in flask
|
request.headers['your-header-name']
|
[] |
request.headers['VAR_STR']
|
conala
|
7745562-86
|
Create list `listy` containing 3 empty lists
|
listy = [[] for i in range(3)]
|
[
"python.library.functions#range"
] |
VAR_STR = [[] for i in range(3)]
|
conala
|
8777753-52
|
convert datetime.date `dt` to utc timestamp
|
timestamp = (dt - datetime(1970, 1, 1)).total_seconds()
|
[
"python.library.datetime#datetime.timedelta.total_seconds",
"python.library.datetime#datetime.datetime"
] |
timestamp = (VAR_STR - datetime(1970, 1, 1)).total_seconds()
|
conala
|
12211944-86
|
find float number proceeding sub-string `par` in string `dir`
|
float(re.findall('(?:^|_)' + par + '(\\d+\\.\\d*)', dir)[0])
|
[
"python.library.re#re.findall",
"python.library.functions#float"
] |
float(re.findall('(?:^|_)' + VAR_STR + '(\\d+\\.\\d*)', VAR_STR)[0])
|
conala
|
12211944-0
|
Get all the matches from a string `abcd` if it begins with a character `a`
|
re.findall('[^a]', 'abcd')
|
[
"python.library.re#re.findall"
] |
re.findall('[^a]', 'VAR_STR')
|
conala
|
1270951-66
|
get a relative path of file 'my_file' into variable `fn`
|
fn = os.path.join(os.path.dirname(__file__), 'my_file')
|
[
"python.library.os.path#os.path.dirname",
"python.library.os.path#os.path.join"
] |
VAR_STR = os.path.join(os.path.dirname(__file__), 'VAR_STR')
|
conala
|
1534542-44
|
Can I sort text by its numeric value in Python?
|
sorted(list(mydict.items()), key=lambda a: map(int, a[0].split('.')))
|
[
"python.library.functions#sorted",
"python.library.functions#map",
"python.library.functions#list",
"python.library.stdtypes#dict.items",
"python.library.stdtypes#str.split"
] |
sorted(list(mydict.items()), key=lambda a: map(int, a[0].split('.')))
|
conala
|
39538010-46
|
execute python code `myscript.py` in a virtualenv `/path/to/my/venv` from matlab
|
system('/path/to/my/venv/bin/python myscript.py')
|
[
"python.library.os#os.system"
] |
system('/path/to/my/venv/bin/python myscript.py')
|
conala
|
42260840-56
|
remove dictionary from list `a` if the value associated with its key 'link' is in list `b`
|
a = [x for x in a if x['link'] not in b]
|
[] |
VAR_STR = [x for x in VAR_STR if x['VAR_STR'] not in VAR_STR]
|
conala
|
19334374-30
|
Convert a string of numbers `example_string` separated by `,` into a list of integers
|
map(int, example_string.split(','))
|
[
"python.library.functions#map",
"python.library.stdtypes#str.split"
] |
map(int, VAR_STR.split('VAR_STR'))
|
conala
|
19334374-87
|
Convert a string of numbers 'example_string' separated by comma into a list of numbers
|
[int(s) for s in example_string.split(',')]
|
[
"python.library.functions#int",
"python.library.stdtypes#str.split"
] |
[int(s) for s in VAR_STR.split(',')]
|
conala
|
4270742-97
|
remove newlines and whitespace from string `yourstring`
|
re.sub('[\\ \\n]{2,}', '', yourstring)
|
[
"python.library.re#re.sub"
] |
re.sub('[\\ \\n]{2,}', '', VAR_STR)
|
conala
|
16772071-63
|
sort dict `data` by value
|
sorted(data, key=data.get)
|
[
"python.library.functions#sorted"
] |
sorted(VAR_STR, key=VAR_STR.get)
|
conala
|
16772071-53
|
Sort a dictionary `data` by its values
|
sorted(data.values())
|
[
"python.library.functions#sorted",
"python.library.stdtypes#dict.values"
] |
sorted(VAR_STR.values())
|
conala
|
16772071-42
|
Get a list of pairs of key-value sorted by values in dictionary `data`
|
sorted(list(data.items()), key=lambda x: x[1])
|
[
"python.library.functions#sorted",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
sorted(list(VAR_STR.items()), key=lambda x: x[1])
|
conala
|
16772071-83
|
sort dict by value python
|
sorted(list(data.items()), key=lambda x: x[1])
|
[
"python.library.functions#sorted",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
sorted(list(data.items()), key=lambda x: x[1])
|
conala
|
4484690-74
|
update all values associated with key `i` to string 'updated' if value `j` is not equal to 'None' in dictionary `d`
|
{i: 'updated' for i, j in list(d.items()) if j != 'None'}
|
[
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
{VAR_STR: 'VAR_STR' for VAR_STR, VAR_STR in list(VAR_STR.items()) if VAR_STR != 'VAR_STR'}
|
conala
|
4484690-66
|
Filter a dictionary `d` to remove keys with value None and replace other values with 'updated'
|
dict((k, 'updated') for k, v in d.items() if v is None)
|
[
"python.library.stdtypes#dict",
"python.library.stdtypes#dict.items"
] |
dict((k, 'VAR_STR') for k, v in VAR_STR.items() if v is None)
|
conala
|
4484690-31
|
Filter a dictionary `d` to remove keys with value 'None' and replace other values with 'updated'
|
dict((k, 'updated') for k, v in d.items() if v != 'None')
|
[
"python.library.stdtypes#dict",
"python.library.stdtypes#dict.items"
] |
dict((k, 'VAR_STR') for k, v in VAR_STR.items() if v != 'VAR_STR')
|
conala
|
8528178-96
|
create a list `listofzeros` of `n` zeros
|
listofzeros = [0] * n
|
[] |
VAR_STR = [0] * VAR_STR
|
conala
|
4233476-75
|
sort a list `s` by first and second attributes
|
s = sorted(s, key=lambda x: (x[1], x[2]))
|
[
"python.library.functions#sorted"
] |
VAR_STR = sorted(VAR_STR, key=lambda x: (x[1], x[2]))
|
conala
|
4233476-98
|
sort a list of lists `s` by second and third element in each list.
|
s.sort(key=operator.itemgetter(1, 2))
|
[
"python.library.operator#operator.itemgetter",
"python.library.stdtypes#list.sort"
] |
VAR_STR.sort(key=operator.itemgetter(1, 2))
|
conala
|
1217251-72
|
sort dictionary of lists `myDict` by the third item in each list
|
sorted(list(myDict.items()), key=lambda e: e[1][2])
|
[
"python.library.functions#sorted",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
sorted(list(VAR_STR.items()), key=lambda e: e[1][2])
|
conala
|
22412258-62
|
get the first element of each tuple in a list `rows`
|
[x[0] for x in rows]
|
[] |
[x[0] for x in VAR_STR]
|
conala
|
22412258-39
|
get a list `res_list` of the first elements of each tuple in a list of tuples `rows`
|
res_list = [x[0] for x in rows]
|
[] |
VAR_STR = [x[0] for x in VAR_STR]
|
conala
|
7332841-60
|
append the first element of array `a` to array `a`
|
numpy.append(a, a[0])
|
[
"numpy.reference.generated.numpy.append"
] |
numpy.append(VAR_STR, VAR_STR[0])
|
conala
|
18624039-75
|
reset index of series `s`
|
s.reset_index(0).reset_index(drop=True)
|
[
"pandas.reference.api.pandas.dataframe.reset_index"
] |
VAR_STR.reset_index(0).reset_index(drop=True)
|
conala
|
4060221-89
|
open a file 'bundled-resource.jpg' in the same directory as a python script
|
f = open(os.path.join(__location__, 'bundled-resource.jpg'))
|
[
"python.library.os.path#os.path.join",
"python.library.urllib.request#open"
] |
f = open(os.path.join(__location__, 'VAR_STR'))
|
conala
|
18663026-72
|
Set value for key `a` in dict `count` to `0` if key `a` does not exist or if value is `none`
|
count.setdefault('a', 0)
|
[
"python.library.stdtypes#dict.setdefault"
] |
VAR_STR.setdefault('VAR_STR', 0)
|
conala
|
5022066-15
|
serialise SqlAlchemy RowProxy object `row` to a json object
|
json.dumps([dict(list(row.items())) for row in rs])
|
[
"python.library.json#json.dumps",
"python.library.stdtypes#dict",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
json.dumps([dict(list(VAR_STR.items())) for VAR_STR in rs])
|
conala
|
18170459-31
|
check if dictionary `L[0].f.items()` is in dictionary `a3.f.items()`
|
set(L[0].f.items()).issubset(set(a3.f.items()))
|
[
"python.library.stdtypes#set",
"python.library.stdtypes#dict.items"
] |
set(L[0].f.items()).issubset(set(a3.f.items()))
|
conala
|
674519-53
|
convert a python dictionary `d` to a list of tuples
|
[(v, k) for k, v in list(d.items())]
|
[
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
[(v, k) for k, v in list(VAR_STR.items())]
|
conala
|
674519-26
|
convert dictionary of pairs `d` to a list of tuples
|
[(v, k) for k, v in d.items()]
|
[
"python.library.stdtypes#dict.items"
] |
[(v, k) for k, v in VAR_STR.items()]
|
conala
|
674519-5
|
convert python 2 dictionary `a` to a list of tuples where the value is the first tuple element and the key is the second tuple element
|
[(v, k) for k, v in a.items()]
|
[
"python.library.stdtypes#dict.items"
] |
[(v, k) for k, v in VAR_STR.items()]
|
conala
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.