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 |
---|---|---|---|---|---|
16418415-99
|
Divide elements in list `a` from elements at the same index in list `b`
|
[(x / y) for x, y in zip(a, b)]
|
[
"python.library.functions#zip"
] |
[(x / y) for x, y in zip(VAR_STR, VAR_STR)]
|
conala
|
7568627-60
|
Unpack each value in list `x` to its placeholder '%' in string '%.2f'
|
""", """.join(['%.2f'] * len(x))
|
[
"python.library.functions#len",
"python.library.stdtypes#str.join"
] |
""", """.join(['VAR_STR'] * len(VAR_STR))
|
conala
|
21164910-6
|
delete all columns in DataFrame `df` that do not hold a non-zero value in its records
|
df.loc[:, ((df != 0).any(axis=0))]
|
[
"pandas.reference.api.pandas.dataframe.loc",
"python.library.functions#any"
] |
VAR_STR.loc[:, ((VAR_STR != 0).any(axis=0))]
|
conala
|
5844672-30
|
Delete an element `key` from a dictionary `d`
|
del d[key]
|
[] |
del VAR_STR[VAR_STR]
|
conala
|
5844672-73
|
Delete an element 0 from a dictionary `a`
|
{i: a[i] for i in a if (i != 0)}
|
[] |
{i: VAR_STR[i] for i in VAR_STR if i != 0}
|
conala
|
5844672-74
|
Delete an element "hello" from a dictionary `lol`
|
lol.pop('hello')
|
[
"python.library.stdtypes#dict.pop"
] |
VAR_STR.pop('VAR_STR')
|
conala
|
5844672-98
|
Delete an element with key `key` dictionary `r`
|
del r[key]
|
[] |
del VAR_STR[VAR_STR]
|
conala
|
12182744-50
|
python pandas: apply a function with arguments to a series
|
my_series.apply(your_function, args=(2, 3, 4), extra_kw=1)
|
[
"pandas.reference.api.pandas.series.apply"
] |
my_series.apply(your_function, args=(2, 3, 4), extra_kw=1)
|
conala
|
21691126-12
|
find element by css selector "input[onclick*='1 Bedroom Deluxe']"
|
driver.find_element_by_css_selector("input[onclick*='1 Bedroom Deluxe']")
|
[] |
driver.find_element_by_css_selector('VAR_STR')
|
conala
|
29902714-77
|
get value at index `[2, 0]` in dataframe `df`
|
df.iloc[2, 0]
|
[
"pandas.reference.api.pandas.dataframe.loc"
] |
VAR_STR.iloc[VAR_STR]
|
conala
|
10666163-6
|
check if the third element of all the lists in a list "items" is equal to zero.
|
any(item[2] == 0 for item in items)
|
[
"python.library.functions#any"
] |
any(item[2] == 0 for item in VAR_STR)
|
conala
|
10666163-14
|
Find all the lists from a lists of list 'items' if third element in all sub-lists is '0'
|
[x for x in items if x[2] == 0]
|
[] |
[x for x in VAR_STR if x[2] == 0]
|
conala
|
9889635-12
|
find all substrings in `mystring` beginning and ending with square brackets
|
re.findall('\\[(.*?)\\]', mystring)
|
[
"python.library.re#re.findall"
] |
re.findall('\\[(.*?)\\]', VAR_STR)
|
conala
|
3877491-18
|
Delete third row in a numpy array `x`
|
x = numpy.delete(x, 2, axis=1)
|
[
"numpy.reference.generated.numpy.delete"
] |
VAR_STR = numpy.delete(VAR_STR, 2, axis=1)
|
conala
|
3877491-16
|
delete first row of array `x`
|
x = numpy.delete(x, 0, axis=0)
|
[
"numpy.reference.generated.numpy.delete"
] |
VAR_STR = numpy.delete(VAR_STR, 0, axis=0)
|
conala
|
20837786-15
|
request URL `url` using http header `{'referer': my_referer}`
|
requests.get(url, headers={'referer': my_referer})
|
[
"python.library.webbrowser#webbrowser.get"
] |
requests.get(VAR_STR, headers={VAR_STR})
|
conala
|
27867754-13
|
get the widget which has currently the focus in tkinter instance `window2`
|
print(('focus object class:', window2.focus_get().__class__))
|
[] |
print(('focus object class:', VAR_STR.focus_get().__class__))
|
conala
|
7996940-71
|
What is the best way to sort list with custom sorting parameters in Python?
|
li1.sort(key=lambda x: not x.startswith('b.'))
|
[
"python.library.stdtypes#str.startswith",
"python.library.stdtypes#list.sort"
] |
li1.sort(key=lambda x: not x.startswith('b.'))
|
conala
|
7173850-2
|
get user input using message 'Enter name here: ' and insert it to the first placeholder in string 'Hello, {0}, how do you do?'
|
print('Hello, {0}, how do you do?'.format(input('Enter name here: ')))
|
[
"python.library.functions#input",
"python.library.functions#format"
] |
print('VAR_STR'.format(input('Enter name here: ')))
|
conala
|
10258584-10
|
Get all texts and tags from a tag `strong` from etree tag `some_tag` using lxml
|
print(etree.tostring(some_tag.find('strong')))
|
[
"python.library.xml.etree.elementtree#xml.etree.ElementTree.tostring",
"python.library.xml.etree.elementtree#xml.etree.ElementTree.Element.find"
] |
print(etree.tostring(VAR_STR.find('VAR_STR')))
|
conala
|
237079-99
|
get modified time of file `file`
|
time.ctime(os.path.getmtime(file))
|
[
"python.library.os.path#os.path.getmtime",
"python.library.time#time.ctime"
] |
time.ctime(os.path.getmtime(VAR_STR))
|
conala
|
237079-26
|
get creation time of file `file`
|
time.ctime(os.path.getctime(file))
|
[
"python.library.os.path#os.path.getctime",
"python.library.time#time.ctime"
] |
time.ctime(os.path.getctime(VAR_STR))
|
conala
|
237079-17
|
get modification time of file `filename`
|
t = os.path.getmtime(filename)
|
[
"python.library.os.path#os.path.getmtime"
] |
t = os.path.getmtime(VAR_STR)
|
conala
|
237079-40
|
get modification time of file `path`
|
os.path.getmtime(path)
|
[
"python.library.os.path#os.path.getmtime"
] |
os.VAR_STR.getmtime(VAR_STR)
|
conala
|
237079-48
|
get modified time of file `file`
|
print(('last modified: %s' % time.ctime(os.path.getmtime(file))))
|
[
"python.library.os.path#os.path.getmtime",
"python.library.time#time.ctime"
] |
print('last modified: %s' % time.ctime(os.path.getmtime(VAR_STR)))
|
conala
|
237079-32
|
get the creation time of file `file`
|
print(('created: %s' % time.ctime(os.path.getctime(file))))
|
[
"python.library.os.path#os.path.getctime",
"python.library.time#time.ctime"
] |
print('created: %s' % time.ctime(os.path.getctime(VAR_STR)))
|
conala
|
237079-78
|
get the creation time of file `path_to_file`
|
return os.path.getctime(path_to_file)
|
[
"python.library.os.path#os.path.getctime"
] |
return os.path.getctime(VAR_STR)
|
conala
|
11064917-93
|
generate a string of numbers separated by comma which is divisible by `4` with remainder `1` or `2`.
|
""",""".join(str(i) for i in range(100) if i % 4 in (1, 2))
|
[
"python.library.functions#range",
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
""",""".join(str(i) for i in range(100) if i % 4 in (1, 2))
|
conala
|
26724275-54
|
remove first directory from path '/First/Second/Third/Fourth/Fifth'
|
os.path.join(*x.split(os.path.sep)[2:])
|
[
"python.library.os.path#os.path.join",
"python.library.os.path#os.path.split"
] |
os.path.join(*x.split(os.path.sep)[2:])
|
conala
|
3501382-87
|
check if `x` is an integer
|
isinstance(x, int)
|
[
"python.library.functions#isinstance"
] |
isinstance(VAR_STR, int)
|
conala
|
3501382-37
|
check if `x` is an integer
|
(type(x) == int)
|
[
"python.library.functions#type"
] |
type(VAR_STR) == int
|
conala
|
18938276-57
|
convert nested list of lists `[['tom', 'cat'], ['jerry', 'mouse'], ['spark', 'dog']]` into a list of tuples
|
list(map(tuple, [['tom', 'cat'], ['jerry', 'mouse'], ['spark', 'dog']]))
|
[
"python.library.functions#map",
"python.library.functions#list"
] |
list(map(tuple, [VAR_STR]))
|
conala
|
5229425-29
|
print a digit `your_number` with exactly 2 digits after decimal
|
print('{0:.2f}'.format(your_number))
|
[
"python.library.functions#format"
] |
print('{0:.2f}'.format(VAR_STR))
|
conala
|
20477190-38
|
get biggest 3 values from each column of the pandas dataframe `data`
|
data.apply(lambda x: sorted(x, 3))
|
[
"python.library.functions#sorted",
"pandas.reference.api.pandas.series.apply"
] |
VAR_STR.apply(lambda x: sorted(x, 3))
|
conala
|
42731970-80
|
replace periods `.` that are not followed by periods or spaces with a period and a space `. `
|
re.sub('\\.(?=[^ .])', '. ', para)
|
[
"python.library.re#re.sub"
] |
re.sub('\\.(?=[^ .])', '. ', para)
|
conala
|
3392354-94
|
append values `[3, 4]` to a set `a`
|
a.update([3, 4])
|
[
"python.library.turtle#turtle.update"
] |
VAR_STR.update([VAR_STR])
|
conala
|
9210525-51
|
convert hex string `s` to decimal
|
i = int(s, 16)
|
[
"python.library.functions#int"
] |
i = int(VAR_STR, 16)
|
conala
|
9210525-67
|
convert hex string "0xff" to decimal
|
int('0xff', 16)
|
[
"python.library.functions#int"
] |
int('VAR_STR', 16)
|
conala
|
9210525-47
|
convert hex string "FFFF" to decimal
|
int('FFFF', 16)
|
[
"python.library.functions#int"
] |
int('VAR_STR', 16)
|
conala
|
9210525-85
|
convert hex string '0xdeadbeef' to decimal
|
ast.literal_eval('0xdeadbeef')
|
[
"python.library.ast#ast.literal_eval"
] |
ast.literal_eval('VAR_STR')
|
conala
|
9210525-67
|
convert hex string 'deadbeef' to decimal
|
int('deadbeef', 16)
|
[
"python.library.functions#int"
] |
int('VAR_STR', 16)
|
conala
|
16866261-93
|
Strip all non-ASCII characters from a unicode string, `\xa3\u20ac\xa3\u20ac`
|
print(set(re.sub('[\x00-\x7f]', '', '\xa3\u20ac\xa3\u20ac')))
|
[
"python.library.re#re.sub",
"python.library.stdtypes#set"
] |
print(set(re.sub('[\x00-\x7f]', '', 'VAR_STR')))
|
conala
|
16866261-39
|
Get all non-ascii characters in a unicode string `\xa3100 is worth more than \u20ac100`
|
print(re.sub('[\x00-\x7f]', '', '\xa3100 is worth more than \u20ac100'))
|
[
"python.library.re#re.sub"
] |
print(re.sub('[\x00-\x7f]', '', 'VAR_STR'))
|
conala
|
9841303-32
|
removing duplicate characters from a string variable "foo"
|
"""""".join(set(foo))
|
[
"python.library.stdtypes#set",
"python.library.stdtypes#str.join"
] |
"""""".join(set(VAR_STR))
|
conala
|
4481724-87
|
convert a list of characters `['a', 'b', 'c', 'd']` into a string
|
"""""".join(['a', 'b', 'c', 'd'])
|
[
"python.library.stdtypes#str.join"
] |
"""""".join([VAR_STR])
|
conala
|
35015693-21
|
join elements of each tuple in list `a` into one string
|
[''.join(x) for x in a]
|
[
"python.library.stdtypes#str.join"
] |
[''.join(x) for x in VAR_STR]
|
conala
|
35015693-23
|
join items of each tuple in list of tuples `a` into a list of strings
|
list(map(''.join, a))
|
[
"python.library.functions#map",
"python.library.functions#list"
] |
list(map(''.join, VAR_STR))
|
conala
|
11009155-40
|
split string "jvm.args= -Dappdynamics.com=true, -Dsomeotherparam=false," on the first occurrence of delimiter '='
|
"""jvm.args= -Dappdynamics.com=true, -Dsomeotherparam=false,""".split('=', 1)
|
[
"python.library.stdtypes#str.split"
] |
"""VAR_STR""".split('VAR_STR', 1)
|
conala
|
20970279-77
|
get the middle two characters of a string 'state' in a pandas dataframe `df`
|
df['state'].apply(lambda x: x[len(x) / 2 - 1:len(x) / 2 + 1])
|
[
"python.library.functions#len",
"pandas.reference.api.pandas.series.apply"
] |
VAR_STR['VAR_STR'].apply(lambda x: x[len(x) / 2 - 1:len(x) / 2 + 1])
|
conala
|
23668427-2
|
join multiple dataframes `d1`, `d2`, and `d3` on column 'name'
|
df1.merge(df2, on='name').merge(df3, on='name')
|
[
"pandas.reference.api.pandas.merge"
] |
df1.merge(df2, on='VAR_STR').merge(df3, on='VAR_STR')
|
conala
|
42765620-65
|
How to sort a dictionary in python by value when the value is a list and I want to sort it by the first index of that list
|
sorted(list(data.items()), key=lambda x: x[1][0])
|
[
"python.library.functions#sorted",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
sorted(list(data.items()), key=lambda x: x[1][0])
|
conala
|
12804801-42
|
sort query set by number of characters in a field `length` in django model `MyModel`
|
MyModel.objects.extra(select={'length': 'Length(name)'}).order_by('length')
|
[
"python.library.zipfile#zipfile.ZipInfo.extra"
] |
VAR_STR.objects.extra(select={'VAR_STR': 'Length(name)'}).order_by('VAR_STR')
|
conala
|
13838405-78
|
sort column `m` in panda dataframe `df`
|
df.sort('m')
|
[
"pandas.reference.api.pandas.index.sort"
] |
VAR_STR.sort('VAR_STR')
|
conala
|
20154303-58
|
read a ragged csv file `D:/Temp/tt.csv` using `names` parameter in pandas
|
pd.read_csv('D:/Temp/tt.csv', names=list('abcdef'))
|
[
"pandas.reference.api.pandas.read_csv",
"python.library.functions#list"
] |
pd.read_csv('VAR_STR', VAR_STR=list('abcdef'))
|
conala
|
9236926-97
|
Concatenating two one-dimensional NumPy arrays 'a' and 'b'.
|
numpy.concatenate([a, b])
|
[
"numpy.reference.generated.numpy.concatenate"
] |
numpy.concatenate([VAR_STR, VAR_STR])
|
conala
|
18224991-15
|
assign float 9.8 to variable `GRAVITY`
|
GRAVITY = 9.8
|
[] |
VAR_STR = 9.8
|
conala
|
372102-55
|
create a regular expression object with the pattern '\xe2\x80\x93'
|
re.compile('\xe2\x80\x93')
|
[
"python.library.re#re.compile"
] |
re.compile('VAR_STR')
|
conala
|
4552380-10
|
SQLAlchemy select records of columns of table `my_table` in addition to current date column
|
print(select([my_table, func.current_date()]).execute())
|
[
"python.library.select#select.select",
"python.library.msilib#msilib.View.Execute"
] |
print(select([VAR_STR, func.current_date()]).execute())
|
conala
|
38457059-97
|
change NaN values in dataframe `df` using preceding values in the frame
|
df.fillna(method='ffill', inplace=True)
|
[
"pandas.reference.api.pandas.dataframe.fillna"
] |
VAR_STR.fillna(method='ffill', inplace=True)
|
conala
|
12765833-84
|
counting the number of true booleans in a python list `[True, True, False, False, False, True]`
|
sum([True, True, False, False, False, True])
|
[
"python.library.functions#sum"
] |
sum([VAR_STR])
|
conala
|
31522361-37
|
replacing '\u200b' with '*' in a string using regular expressions
|
'used\u200b'.replace('\u200b', '*')
|
[
"python.library.stdtypes#str.replace"
] |
"""used""".replace('VAR_STR', 'VAR_STR')
|
conala
|
14111705-53
|
display a grayscale image from array of pixels `imageArray`
|
imshow(imageArray, cmap='Greys_r')
|
[
"matplotlib._as_gen.matplotlib.pyplot.imshow"
] |
imshow(VAR_STR, cmap='Greys_r')
|
conala
|
23354124-66
|
unpivot first 2 columns into new columns 'year' and 'value' from a pandas dataframe `x`
|
pd.melt(x, id_vars=['farm', 'fruit'], var_name='year', value_name='value')
|
[
"pandas.reference.api.pandas.melt"
] |
pd.melt(VAR_STR, id_vars=['farm', 'fruit'], var_name='VAR_STR', value_name='VAR_STR')
|
conala
|
31771758-13
|
add unicode string '1' to UTF-8 decoded string '\xc2\xa3'
|
print('\xc2\xa3'.decode('utf8') + '1')
|
[
"python.library.stdtypes#bytearray.decode"
] |
print('VAR_STR'.decode('utf8') + 'VAR_STR')
|
conala
|
20774910-90
|
convert unicode string `s` into string literals
|
print(s.encode('unicode_escape'))
|
[
"python.library.stdtypes#str.encode"
] |
print(VAR_STR.encode('unicode_escape'))
|
conala
|
12791501-50
|
Initialize a list of empty lists `x` of size 3
|
x = [[] for i in range(3)]
|
[
"python.library.functions#range"
] |
VAR_STR = [[] for i in range(3)]
|
conala
|
5384570-34
|
count the number of items in a generator/iterator `it`
|
sum(1 for i in it)
|
[
"python.library.functions#sum"
] |
sum(1 for i in VAR_STR)
|
conala
|
16734590-48
|
convert nested list 'Cards' into a flat list
|
[a for c in Cards for b in c for a in b]
|
[] |
[a for c in VAR_STR for b in c for a in b]
|
conala
|
10996140-0
|
remove specific elements in a numpy array `a`
|
numpy.delete(a, index)
|
[
"numpy.reference.generated.numpy.delete"
] |
numpy.delete(VAR_STR, index)
|
conala
|
4587915-52
|
get a list of all items in list `j` with values greater than `5`
|
[x for x in j if x >= 5]
|
[] |
[x for x in VAR_STR if x >= 5]
|
conala
|
38987-80
|
merge dictionaries form array `dicts` in a single expression
|
dict((k, v) for d in dicts for k, v in list(d.items()))
|
[
"python.library.stdtypes#dict",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
dict((k, v) for d in VAR_STR for k, v in list(d.items()))
|
conala
|
28431359-82
|
decode url-encoded string `some_string` to its character equivalents
|
urllib.parse.unquote(urllib.parse.unquote(some_string))
|
[
"python.library.urllib.parse#urllib.parse.unquote"
] |
urllib.parse.unquote(urllib.parse.unquote(VAR_STR))
|
conala
|
28431359-67
|
decode a double URL encoded string
'FireShot3%2B%25282%2529.png' to
'FireShot3+(2).png'
|
urllib.parse.unquote(urllib.parse.unquote('FireShot3%2B%25282%2529.png'))
|
[
"python.library.urllib.parse#urllib.parse.unquote"
] |
urllib.parse.unquote(urllib.parse.unquote('VAR_STR'))
|
conala
|
2597932-72
|
join list of numbers `[1,2,3,4] ` to string of numbers.
|
"""""".join([1, 2, 3, 4])
|
[
"python.library.stdtypes#str.join"
] |
"""""".join([1, 2, 3, 4])
|
conala
|
849674-71
|
start a new thread for `myfunction` with parameters 'MyStringHere' and 1
|
thread.start_new_thread(myfunction, ('MyStringHere', 1))
|
[
"python.library._thread#_thread.start_new_thread"
] |
thread.start_new_thread(VAR_STR, ('VAR_STR', 1))
|
conala
|
849674-100
|
start a new thread for `myfunction` with parameters 'MyStringHere' and 1
|
thread.start_new_thread(myfunction, ('MyStringHere', 1))
|
[
"python.library._thread#_thread.start_new_thread"
] |
thread.start_new_thread(VAR_STR, ('VAR_STR', 1))
|
conala
|
12492137-8
|
python sum of ascii values of all characters in a string `string`
|
sum(map(ord, string))
|
[
"python.library.functions#map",
"python.library.functions#sum"
] |
sum(map(ord, VAR_STR))
|
conala
|
12883376-74
|
remove first word in string `s`
|
s.split(' ', 1)[1]
|
[
"python.library.stdtypes#str.split"
] |
VAR_STR.split(' ', 1)[1]
|
conala
|
1679798-8
|
open a file "$file" under Unix
|
os.system('start "$file"')
|
[
"python.library.os#os.system"
] |
os.system('start "$file"')
|
conala
|
27146262-46
|
create variable key/value pairs with argparse
|
parser.add_argument('--conf', nargs=2, action='append')
|
[
"python.library.argparse#argparse.ArgumentParser.add_argument"
] |
parser.add_argument('--conf', nargs=2, action='append')
|
conala
|
18789262-62
|
convert the zip of range `(1, 5)` and range `(7, 11)` into a dictionary
|
dict(zip(list(range(1, 5)), list(range(7, 11))))
|
[
"python.library.functions#range",
"python.library.functions#list",
"python.library.functions#zip",
"python.library.stdtypes#dict"
] |
dict(zip(list(range(VAR_STR)), list(range(VAR_STR))))
|
conala
|
18265935-5
|
create a list of integers between 2 values `11` and `17`
|
list(range(11, 17))
|
[
"python.library.functions#range",
"python.library.functions#list"
] |
list(range(11, 17))
|
conala
|
26727314-83
|
argparse associate zero or more arguments with flag 'file'
|
parser.add_argument('file', nargs='*')
|
[
"python.library.argparse#argparse.ArgumentParser.add_argument"
] |
parser.add_argument('VAR_STR', nargs='*')
|
conala
|
16658068-0
|
print a character that has unicode value `\u25b2`
|
print('\u25b2'.encode('utf-8'))
|
[
"python.library.stdtypes#str.encode"
] |
print('VAR_STR'.encode('utf-8'))
|
conala
|
7154739-87
|
set every two-stride far element to -1 starting from second element in array `a`
|
a[1::2] = -1
|
[] |
VAR_STR[1::2] = -1
|
conala
|
6561653-2
|
Get an item from a list of dictionary `lst` which has maximum value in the key `score` using lambda function
|
max(lst, key=lambda x: x['score'])
|
[
"python.library.functions#max"
] |
max(VAR_STR, key=lambda x: x['VAR_STR'])
|
conala
|
17223174-79
|
SQLAlchemy count the number of rows with distinct values in column `name` of table `Tag`
|
session.query(Tag).distinct(Tag.name).group_by(Tag.name).count()
|
[
"django.ref.models.querysets#django.db.models.Count.distinct",
"python.library.stdtypes#str.count"
] |
session.query(VAR_STR).distinct(VAR_STR.VAR_STR).group_by(VAR_STR.VAR_STR).count()
|
conala
|
6889785-68
|
get a list of items form nested list `li` where third element of each item contains string 'ar'
|
[x for x in li if 'ar' in x[2]]
|
[] |
[x for x in VAR_STR if 'VAR_STR' in x[2]]
|
conala
|
3847472-86
|
get index of character 'b' in list '['a', 'b']'
|
['a', 'b'].index('b')
|
[
"python.library.stdtypes#str.index"
] |
['a', 'VAR_STR'].index('VAR_STR')
|
conala
|
10857924-28
|
remove null columns in a dataframe `df`
|
df = df.dropna(axis=1, how='all')
|
[
"pandas.reference.api.pandas.dataframe.dropna"
] |
VAR_STR = VAR_STR.dropna(axis=1, how='all')
|
conala
|
17558552-75
|
Log info message 'Log message' with attributes `{'app_name': 'myapp'}`
|
logging.info('Log message', extra={'app_name': 'myapp'})
|
[
"python.library.logging#logging.info"
] |
logging.info('VAR_STR', extra={VAR_STR})
|
conala
|
42060144-97
|
Merge column 'word' in dataframe `df2` with column 'word' on dataframe `df1`
|
df1.merge(df2, how='left', on='word')
|
[
"pandas.reference.api.pandas.merge"
] |
VAR_STR.merge(VAR_STR, how='left', on='VAR_STR')
|
conala
|
42211584-15
|
get the maximum of 'salary' and 'bonus' values in a dictionary
|
print(max(d, key=lambda x: (d[x]['salary'], d[x]['bonus'])))
|
[
"python.library.functions#max"
] |
print(max(d, key=lambda x: (d[x]['VAR_STR'], d[x]['VAR_STR'])))
|
conala
|
1197600-71
|
match blank lines in `s` with regular expressions
|
re.split('\n\\s*\n', s)
|
[
"python.library.re#re.split"
] |
re.split('\n\\s*\n', VAR_STR)
|
conala
|
11755208-97
|
replace carriage return in string `somestring` with empty string ''
|
somestring.replace('\\r', '')
|
[
"python.library.stdtypes#str.replace"
] |
VAR_STR.replace('\\r', 'VAR_STR')
|
conala
|
21947035-29
|
print string "ABC" as hex literal
|
"""ABC""".encode('hex')
|
[
"python.library.stdtypes#str.encode"
] |
"""ABC""".encode('hex')
|
conala
|
21361604-32
|
sort a list `L` by number after second '.'
|
print(sorted(L, key=lambda x: int(x.split('.')[2])))
|
[
"python.library.functions#sorted",
"python.library.functions#int",
"python.library.stdtypes#str.split"
] |
print(sorted(VAR_STR, key=lambda x: int(x.split('VAR_STR')[2])))
|
conala
|
11114358-38
|
Filter duplicate entries w.r.t. value in 'id' from a list of dictionaries 'L'
|
list(dict((x['id'], x) for x in L).values())
|
[
"python.library.stdtypes#dict",
"python.library.functions#list",
"python.library.stdtypes#dict.values"
] |
list(dict((x['VAR_STR'], x) for x in VAR_STR).values())
|
conala
|
6376886-84
|
create list of 'size' empty strings
|
strs = ['' for x in range(size)]
|
[
"python.library.functions#range"
] |
strs = ['' for x in range(VAR_STR)]
|
conala
|
28684154-81
|
Copy list `old_list` and name it `new_list`
|
new_list = [x[:] for x in old_list]
|
[] |
VAR_STR = [x[:] for x in VAR_STR]
|
conala
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.