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 |
---|---|---|---|---|---|
406121-90
|
flatten list `list_of_menuitems`
|
[image for menuitem in list_of_menuitems for image in menuitem]
|
[] |
[image for menuitem in VAR_STR for image in menuitem]
|
conala
|
4741537-60
|
append elements of a set `b` to a list `a`
|
a.extend(b)
|
[
"python.library.collections#collections.deque.extend"
] |
VAR_STR.extend(VAR_STR)
|
conala
|
4741537-84
|
Append elements of a set to a list in Python
|
a.extend(list(b))
|
[
"python.library.functions#list",
"python.library.collections#collections.deque.extend"
] |
a.extend(list(b))
|
conala
|
17438096-75
|
upload file using FTP
|
ftp.storlines('STOR ' + filename, open(filename, 'r'))
|
[
"python.library.urllib.request#open",
"python.library.ftplib#ftplib.FTP.storlines"
] |
ftp.storlines('STOR ' + filename, open(filename, 'r'))
|
conala
|
15049182-63
|
add one to the hidden web element with id 'XYZ' with selenium python script
|
browser.execute_script("document.getElementById('XYZ').value+='1'")
|
[] |
browser.execute_script("document.getElementById('XYZ').value+='1'")
|
conala
|
28742436-20
|
create array containing the maximum value of respective elements of array `[2, 3, 4]` and array `[1, 5, 2]`
|
np.maximum([2, 3, 4], [1, 5, 2])
|
[
"numpy.reference.generated.numpy.maximum"
] |
np.maximum([VAR_STR], [VAR_STR])
|
conala
|
34280147-9
|
print a list `l` and move first 3 elements to the end of the list
|
print(l[3:] + l[:3])
|
[] |
print(VAR_STR[3:] + VAR_STR[:3])
|
conala
|
11801309-71
|
loop over files in directory '.'
|
for fn in os.listdir('.'):
if os.path.isfile(fn):
pass
|
[
"python.library.os.path#os.path.isfile",
"python.library.os#os.listdir"
] |
for fn in os.listdir('VAR_STR'):
if os.path.isfile(fn):
pass
|
conala
|
11801309-27
|
loop over files in directory `source`
|
for (root, dirs, filenames) in os.walk(source):
for f in filenames:
pass
|
[
"python.library.os#os.walk"
] |
for root, dirs, filenames in os.walk(VAR_STR):
for f in filenames:
pass
|
conala
|
852055-44
|
Google App Engine execute GQL query 'SELECT * FROM Schedule WHERE station = $1' with parameter `foo.key()`
|
db.GqlQuery('SELECT * FROM Schedule WHERE station = $1', foo.key())
|
[
"python.library.zoneinfo#zoneinfo.ZoneInfo.key"
] |
db.GqlQuery('VAR_STR', foo.key())
|
conala
|
15325182-98
|
filter rows in pandas starting with alphabet 'f' using regular expression.
|
df.b.str.contains('^f')
|
[
"pandas.reference.api.pandas.series.str.contains"
] |
df.b.str.contains('^f')
|
conala
|
38535931-67
|
pandas: delete rows in dataframe `df` based on multiple columns values
|
df.set_index(list('BC')).drop(tuples, errors='ignore').reset_index()
|
[
"pandas.reference.api.pandas.dataframe.set_index",
"python.library.functions#list",
"pandas.reference.api.pandas.dataframe.reset_index",
"pandas.reference.api.pandas.dataframe.drop"
] |
VAR_STR.set_index(list('BC')).drop(tuples, errors='ignore').reset_index()
|
conala
|
13945749-18
|
format the variables `self.goals` and `self.penalties` using string formatting
|
"""({:d} goals, ${:d})""".format(self.goals, self.penalties)
|
[
"python.library.functions#format"
] |
"""({:d} goals, ${:d})""".format(self.goals, self.penalties)
|
conala
|
13945749-85
|
format string "({} goals, ${})" with variables `goals` and `penalties`
|
"""({} goals, ${})""".format(self.goals, self.penalties)
|
[
"python.library.functions#format"
] |
"""VAR_STR""".format(self.VAR_STR, self.VAR_STR)
|
conala
|
13945749-39
|
format string "({0.goals} goals, ${0.penalties})"
|
"""({0.goals} goals, ${0.penalties})""".format(self)
|
[
"python.library.functions#format"
] |
"""VAR_STR""".format(self)
|
conala
|
18524642-58
|
convert list of lists `L` to list of integers
|
[int(''.join(str(d) for d in x)) for x in L]
|
[
"python.library.functions#int",
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
[int(''.join(str(d) for d in x)) for x in VAR_STR]
|
conala
|
18524642-5
|
combine elements of each list in list `L` into digits of a single integer
|
[''.join(str(d) for d in x) for x in L]
|
[
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
[''.join(str(d) for d in x) for x in VAR_STR]
|
conala
|
18524642-53
|
convert a list of lists `L` to list of integers
|
L = [int(''.join([str(y) for y in x])) for x in L]
|
[
"python.library.functions#int",
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
VAR_STR = [int(''.join([str(y) for y in x])) for x in VAR_STR]
|
conala
|
7138686-35
|
write the elements of list `lines` concatenated by special character '\n' to file `myfile`
|
myfile.write('\n'.join(lines))
|
[
"python.library.stdtypes#str.join",
"python.library.os#os.write"
] |
VAR_STR.write('VAR_STR'.join(VAR_STR))
|
conala
|
1866343-84
|
removing an element from a list based on a predicate 'X' or 'N'
|
[x for x in ['AAT', 'XAC', 'ANT', 'TTA'] if 'X' not in x and 'N' not in x]
|
[] |
[x for x in ['AAT', 'XAC', 'ANT', 'TTA'] if 'VAR_STR' not in x and 'VAR_STR' not in
x]
|
conala
|
17238587-5
|
Remove duplicate words from a string `text` using regex
|
text = re.sub('\\b(\\w+)( \\1\\b)+', '\\1', text)
|
[
"python.library.re#re.sub"
] |
VAR_STR = re.sub('\\b(\\w+)( \\1\\b)+', '\\1', VAR_STR)
|
conala
|
15534223-34
|
search for string that matches regular expression pattern '(?<!Distillr)\\\\AcroTray\\.exe' in string 'C:\\SomeDir\\AcroTray.exe'
|
re.search('(?<!Distillr)\\\\AcroTray\\.exe', 'C:\\SomeDir\\AcroTray.exe')
|
[
"python.library.re#re.search"
] |
re.search('VAR_STR', 'VAR_STR')
|
conala
|
5453026-19
|
split string 'QH QD JC KD JS' into a list on white spaces
|
"""QH QD JC KD JS""".split()
|
[
"python.library.stdtypes#str.split"
] |
"""VAR_STR""".split()
|
conala
|
18168684-38
|
search for occurrences of regex pattern '>.*<' in xml string `line`
|
print(re.search('>.*<', line).group(0))
|
[
"python.library.re#re.search",
"python.library.re#re.Match.group"
] |
print(re.search('VAR_STR', VAR_STR).group(0))
|
conala
|
4914277-19
|
erase all the contents of a file `filename`
|
open(filename, 'w').close()
|
[
"python.library.urllib.request#open"
] |
open(VAR_STR, 'w').close()
|
conala
|
19068269-99
|
convert a string into datetime using the format '%Y-%m-%d %H:%M:%S.%f'
|
datetime.datetime.strptime(string_date, '%Y-%m-%d %H:%M:%S.%f')
|
[
"python.library.datetime#datetime.datetime.strptime"
] |
datetime.datetime.strptime(string_date, 'VAR_STR')
|
conala
|
20683167-59
|
find the index of a list with the first element equal to '332' within the list of lists `thelist`
|
[index for index, item in enumerate(thelist) if item[0] == '332']
|
[
"python.library.functions#enumerate"
] |
[index for index, item in enumerate(VAR_STR) if item[0] == 'VAR_STR']
|
conala
|
17138464-49
|
subscript text 'H20' with '2' as subscripted in matplotlib labels for arrays 'x' and 'y'.
|
plt.plot(x, y, label='H\u2082O')
|
[
"pandas.reference.api.pandas.dataframe.plot"
] |
plt.plot(VAR_STR, VAR_STR, label='H₂O')
|
conala
|
17138464-97
|
subscript text 'H20' with '2' as subscripted in matplotlib labels for arrays 'x' and 'y'.
|
plt.plot(x, y, label='$H_2O$')
|
[
"pandas.reference.api.pandas.dataframe.plot"
] |
plt.plot(VAR_STR, VAR_STR, label='$H_2O$')
|
conala
|
9138112-44
|
loop over a list `mylist` if sublists length equals 3
|
[x for x in mylist if len(x) == 3]
|
[
"python.library.functions#len"
] |
[x for x in VAR_STR if len(x) == 3]
|
conala
|
1807026-63
|
initialize a list `lst` of 100 objects Object()
|
lst = [Object() for _ in range(100)]
|
[
"python.library.functions#range",
"python.library.functions#object"
] |
VAR_STR = [Object() for _ in range(100)]
|
conala
|
1807026-43
|
create list `lst` containing 100 instances of object `Object`
|
lst = [Object() for i in range(100)]
|
[
"python.library.functions#range",
"python.library.functions#object"
] |
VAR_STR = [VAR_STR() for i in range(100)]
|
conala
|
19664253-74
|
get the content of child tag with`href` attribute whose parent has css `someclass`
|
self.driver.find_element_by_css_selector('.someclass a').get_attribute('href')
|
[
"python.library.test#test.support.get_attribute"
] |
self.driver.find_element_by_css_selector('.someclass a').get_attribute('VAR_STR')
|
conala
|
13793321-59
|
joining data from dataframe `df1` with data from dataframe `df2` based on matching values of column 'Date_Time' in both dataframes
|
df1.merge(df2, on='Date_Time')
|
[
"pandas.reference.api.pandas.merge"
] |
VAR_STR.merge(VAR_STR, on='VAR_STR')
|
conala
|
3367288-60
|
use `%s` operator to print variable values `str1` inside a string
|
'first string is: %s, second one is: %s' % (str1, 'geo.tif')
|
[] |
'first string is: %s, second one is: %s' % (VAR_STR, 'geo.tif')
|
conala
|
3475251-5
|
Split a string by a delimiter in python
|
[x.strip() for x in '2.MATCHES $$TEXT$$ STRING'.split('$$TEXT$$')]
|
[
"python.library.stdtypes#str.strip",
"python.library.stdtypes#str.split"
] |
[x.strip() for x in '2.MATCHES $$TEXT$$ STRING'.split('$$TEXT$$')]
|
conala
|
273192-100
|
check if directory `directory ` exists and create it if necessary
|
if (not os.path.exists(directory)):
os.makedirs(directory)
|
[
"python.library.os.path#os.path.exists",
"python.library.os#os.makedirs"
] |
if not os.path.exists(VAR_STR):
os.makedirs(VAR_STR)
|
conala
|
273192-60
|
check if a directory `path` exists and create it if necessary
|
try:
os.makedirs(path)
except OSError:
if (not os.path.isdir(path)):
raise
|
[
"python.library.os.path#os.path.isdir",
"python.library.os#os.makedirs"
] |
try:
os.makedirs(VAR_STR)
except OSError:
if not os.VAR_STR.isdir(VAR_STR):
raise
|
conala
|
273192-76
|
check if a directory `path` exists and create it if necessary
|
distutils.dir_util.mkpath(path)
|
[] |
distutils.dir_util.mkpath(VAR_STR)
|
conala
|
273192-21
|
check if a directory `path` exists and create it if necessary
|
try:
os.makedirs(path)
except OSError as exception:
if (exception.errno != errno.EEXIST):
raise
|
[
"python.library.os#os.makedirs"
] |
try:
os.makedirs(VAR_STR)
except OSError as exception:
if exception.errno != errno.EEXIST:
raise
|
conala
|
18785032-56
|
Replace a separate word 'H3' by 'H1' in a string 'text'
|
re.sub('\\bH3\\b', 'H1', text)
|
[
"python.library.re#re.sub"
] |
re.sub('\\bH3\\b', 'VAR_STR', VAR_STR)
|
conala
|
1450897-93
|
substitute ASCII letters in string 'aas30dsa20' with empty string ''
|
re.sub('\\D', '', 'aas30dsa20')
|
[
"python.library.re#re.sub"
] |
re.sub('\\D', 'VAR_STR', 'VAR_STR')
|
conala
|
1450897-99
|
get digits only from a string `aas30dsa20` using lambda function
|
"""""".join([x for x in 'aas30dsa20' if x.isdigit()])
|
[
"python.library.stdtypes#str.isdigit",
"python.library.stdtypes#str.join"
] |
"""""".join([x for x in 'VAR_STR' if x.isdigit()])
|
conala
|
4928274-56
|
get a dictionary `records` of key-value pairs in PyMongo cursor `cursor`
|
records = dict((record['_id'], record) for record in cursor)
|
[
"python.library.stdtypes#dict"
] |
VAR_STR = dict((record['_id'], record) for record in VAR_STR)
|
conala
|
20180210-37
|
Create new matrix object by concatenating data from matrix A and matrix B
|
np.concatenate((A, B))
|
[
"numpy.reference.generated.numpy.concatenate"
] |
np.concatenate((A, B))
|
conala
|
20180210-35
|
concat two matrices `A` and `B` in numpy
|
np.vstack((A, B))
|
[
"numpy.reference.generated.numpy.vstack"
] |
np.vstack((VAR_STR, VAR_STR))
|
conala
|
1555968-67
|
find the key associated with the largest value in dictionary `x` whilst key is non-zero value
|
max(k for k, v in x.items() if v != 0)
|
[
"python.library.functions#max",
"python.library.stdtypes#dict.items"
] |
max(k for k, v in VAR_STR.items() if v != 0)
|
conala
|
1555968-13
|
get the largest key whose not associated with value of 0 in dictionary `x`
|
(k for k, v in x.items() if v != 0)
|
[
"python.library.stdtypes#dict.items"
] |
(k for k, v in VAR_STR.items() if v != 0)
|
conala
|
1555968-62
|
get the largest key in a dictionary `x` with non-zero value
|
max(k for k, v in x.items() if v != 0)
|
[
"python.library.functions#max",
"python.library.stdtypes#dict.items"
] |
max(k for k, v in VAR_STR.items() if v != 0)
|
conala
|
17021863-48
|
Put the curser at beginning of the file
|
file.seek(0)
|
[
"python.library.io#io.IOBase.seek"
] |
file.seek(0)
|
conala
|
4175686-32
|
remove key 'ele' from dictionary `d`
|
del d['ele']
|
[] |
del VAR_STR['VAR_STR']
|
conala
|
5871168-82
|
Update datetime field in `MyModel` to be the existing `timestamp` plus 100 years
|
MyModel.objects.update(timestamp=F('timestamp') + timedelta(days=36524.25))
|
[
"pandas.reference.api.pandas.timedelta",
"python.library.turtle#turtle.update"
] |
VAR_STR.objects.update(VAR_STR=F('VAR_STR') + timedelta(days=36524.25))
|
conala
|
11574195-24
|
merge list `['it']` and list `['was']` and list `['annoying']` into one list
|
['it'] + ['was'] + ['annoying']
|
[] |
[VAR_STR] + [VAR_STR] + [VAR_STR]
|
conala
|
587647-44
|
increment a value with leading zeroes in a number `x`
|
str(int(x) + 1).zfill(len(x))
|
[
"python.library.functions#len",
"python.library.functions#int",
"python.library.stdtypes#str",
"python.library.stdtypes#str.zfill"
] |
str(int(VAR_STR) + 1).zfill(len(VAR_STR))
|
conala
|
17315881-13
|
check if a pandas dataframe `df`'s index is sorted
|
all(df.index[:-1] <= df.index[1:])
|
[
"python.library.functions#all"
] |
all(VAR_STR.index[:-1] <= VAR_STR.index[1:])
|
conala
|
14695134-57
|
insert data from a string `testfield` to sqlite db `c`
|
c.execute("INSERT INTO test VALUES (?, 'bar')", (testfield,))
|
[
"python.library.msilib#msilib.View.Execute"
] |
VAR_STR.execute("INSERT INTO test VALUES (?, 'bar')", (VAR_STR,))
|
conala
|
24242433-92
|
decode string "\\x89\\n" into a normal string
|
"""\\x89\\n""".decode('string_escape')
|
[
"python.library.stdtypes#bytearray.decode"
] |
"""VAR_STR""".decode('string_escape')
|
conala
|
24242433-9
|
convert a raw string `raw_string` into a normal string
|
raw_string.decode('string_escape')
|
[
"python.library.stdtypes#bytearray.decode"
] |
VAR_STR.decode('string_escape')
|
conala
|
24242433-10
|
convert a raw string `raw_byte_string` into a normal string
|
raw_byte_string.decode('unicode_escape')
|
[
"python.library.stdtypes#bytearray.decode"
] |
VAR_STR.decode('unicode_escape')
|
conala
|
22882922-50
|
split a string `s` with into all strings of repeated characters
|
[m.group(0) for m in re.finditer('(\\d)\\1*', s)]
|
[
"python.library.re#re.finditer",
"python.library.re#re.Match.group"
] |
[m.group(0) for m in re.finditer('(\\d)\\1*', VAR_STR)]
|
conala
|
4143502-27
|
scatter a plot with x, y position of `np.random.randn(100)` and face color equal to none
|
plt.scatter(np.random.randn(100), np.random.randn(100), facecolors='none')
|
[
"numpy.reference.random.generated.numpy.random.randn"
] |
plt.scatter(np.random.randn(100), np.random.randn(100), facecolors='none')
|
conala
|
4143502-6
|
do a scatter plot with empty circles
|
plt.plot(np.random.randn(100), np.random.randn(100), 'o', mfc='none')
|
[
"numpy.reference.random.generated.numpy.random.randn"
] |
plt.plot(np.random.randn(100), np.random.randn(100), 'o', mfc='none')
|
conala
|
27975069-4
|
filter rows containing key word `ball` in column `ids`
|
df[df['ids'].str.contains('ball')]
|
[
"pandas.reference.api.pandas.series.str.contains"
] |
df[df['VAR_STR'].str.contains('VAR_STR')]
|
conala
|
20461165-28
|
convert index at level 0 into a column in dataframe `df`
|
df.reset_index(level=0, inplace=True)
|
[
"pandas.reference.api.pandas.dataframe.reset_index"
] |
VAR_STR.reset_index(level=0, inplace=True)
|
conala
|
20461165-64
|
Add indexes in a data frame `df` to a column `index1`
|
df['index1'] = df.index
|
[] |
VAR_STR['VAR_STR'] = VAR_STR.index
|
conala
|
20461165-11
|
convert pandas index in a dataframe to columns
|
df.reset_index(level=['tick', 'obs'])
|
[
"pandas.reference.api.pandas.dataframe.reset_index"
] |
df.reset_index(level=['tick', 'obs'])
|
conala
|
4685571-89
|
Get reverse of list items from list 'b' using extended slicing
|
[x[::-1] for x in b]
|
[] |
[x[::-1] for x in VAR_STR]
|
conala
|
438684-58
|
convert list `list_of_ints` into a comma separated string
|
""",""".join([str(i) for i in list_of_ints])
|
[
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
""",""".join([str(i) for i in VAR_STR])
|
conala
|
8519922-8
|
Send a post request with raw data `DATA` and basic authentication with `username` and `password`
|
requests.post(url, data=DATA, headers=HEADERS_DICT, auth=(username, password))
|
[
"pygame.ref.fastevent#pygame.fastevent.post"
] |
requests.post(url, data=VAR_STR, headers=HEADERS_DICT, auth=(VAR_STR, VAR_STR))
|
conala
|
22365172-32
|
Iterate ove list `[1, 2, 3]` using list comprehension
|
print([item for item in [1, 2, 3]])
|
[] |
print([item for item in [VAR_STR]])
|
conala
|
12300912-9
|
extract all the values with keys 'x' and 'y' from a list of dictionaries `d` to list of tuples
|
[(x['x'], x['y']) for x in d]
|
[] |
[(VAR_STR['VAR_STR'], VAR_STR['VAR_STR']) for VAR_STR in VAR_STR]
|
conala
|
678236-88
|
get the filename without the extension from file 'hemanth.txt'
|
print(os.path.splitext(os.path.basename('hemanth.txt'))[0])
|
[
"python.library.os.path#os.path.basename",
"python.library.os.path#os.path.splitext"
] |
print(os.path.splitext(os.path.basename('VAR_STR'))[0])
|
conala
|
2597166-54
|
create a dictionary by adding each two adjacent elements in tuple `x` as key/value pair to it
|
dict(x[i:i + 2] for i in range(0, len(x), 2))
|
[
"python.library.functions#len",
"python.library.functions#range",
"python.library.stdtypes#dict"
] |
dict(VAR_STR[i:i + 2] for i in range(0, len(VAR_STR), 2))
|
conala
|
7895449-25
|
create a list containing flattened list `[['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']]`
|
values = sum([['A', 'B', 'C'], ['D', 'E', 'F'], ['G', 'H', 'I']], [])
|
[
"python.library.functions#sum"
] |
values = sum([VAR_STR], [])
|
conala
|
31617845-12
|
select rows in a dataframe `df` column 'closing_price' between two values 99 and 101
|
df = df[(df['closing_price'] >= 99) & (df['closing_price'] <= 101)]
|
[] |
VAR_STR = VAR_STR[(VAR_STR['VAR_STR'] >= 99) & (VAR_STR['VAR_STR'] <= 101)]
|
conala
|
25698710-50
|
replace all occurences of newlines `\n` with `<br>` in dataframe `df`
|
df.replace({'\n': '<br>'}, regex=True)
|
[
"pandas.reference.api.pandas.dataframe.replace"
] |
VAR_STR.replace({'VAR_STR': 'VAR_STR'}, regex=True)
|
conala
|
25698710-24
|
replace all occurrences of a string `\n` by string `<br>` in a pandas data frame `df`
|
df.replace({'\n': '<br>'}, regex=True)
|
[
"pandas.reference.api.pandas.dataframe.replace"
] |
VAR_STR.replace({'VAR_STR': 'VAR_STR'}, regex=True)
|
conala
|
41923858-90
|
create a list containing each two adjacent letters in string `word` as its elements
|
[(x + y) for x, y in zip(word, word[1:])]
|
[
"python.library.functions#zip"
] |
[(x + y) for x, y in zip(VAR_STR, VAR_STR[1:])]
|
conala
|
41923858-58
|
Get a list of pairs from a string `word` using lambda function
|
list(map(lambda x, y: x + y, word[:-1], word[1:]))
|
[
"python.library.functions#map",
"python.library.functions#list"
] |
list(map(lambda x, y: x + y, VAR_STR[:-1], VAR_STR[1:]))
|
conala
|
9760588-64
|
extract a url from a string `myString`
|
print(re.findall('(https?://[^\\s]+)', myString))
|
[
"python.library.re#re.findall"
] |
print(re.findall('(https?://[^\\s]+)', VAR_STR))
|
conala
|
9760588-30
|
extract a url from a string `myString`
|
print(re.search('(?P<url>https?://[^\\s]+)', myString).group('url'))
|
[
"python.library.re#re.search",
"python.library.re#re.Match.group"
] |
print(re.search('(?P<url>https?://[^\\s]+)', VAR_STR).group('url'))
|
conala
|
5843518-46
|
remove all special characters, punctuation and spaces from a string `mystring` using regex
|
re.sub('[^A-Za-z0-9]+', '', mystring)
|
[
"python.library.re#re.sub"
] |
re.sub('[^A-Za-z0-9]+', '', VAR_STR)
|
conala
|
36674519-26
|
create a DatetimeIndex containing 13 periods of the second friday of each month starting from date '2016-01-01'
|
pd.date_range('2016-01-01', freq='WOM-2FRI', periods=13)
|
[
"pandas.reference.api.pandas.date_range"
] |
pd.date_range('VAR_STR', freq='WOM-2FRI', periods=13)
|
conala
|
508657-65
|
Create multidimensional array `matrix` with 3 rows and 2 columns in python
|
matrix = [[a, b], [c, d], [e, f]]
|
[] |
VAR_STR = [[a, b], [c, d], [e, f]]
|
conala
|
1007481-89
|
replace spaces with underscore
|
mystring.replace(' ', '_')
|
[
"python.library.stdtypes#str.replace"
] |
mystring.replace(' ', '_')
|
conala
|
51520-53
|
get an absolute file path of file 'mydir/myfile.txt'
|
os.path.abspath('mydir/myfile.txt')
|
[
"python.library.os.path#os.path.abspath"
] |
os.path.abspath('VAR_STR')
|
conala
|
1249786-22
|
split string `my_string` on white spaces
|
""" """.join(my_string.split())
|
[
"python.library.stdtypes#str.join",
"python.library.stdtypes#str.split"
] |
""" """.join(VAR_STR.split())
|
conala
|
4444923-74
|
get filename without extension from file `filename`
|
os.path.splitext(filename)[0]
|
[
"python.library.os.path#os.path.splitext"
] |
os.path.splitext(VAR_STR)[0]
|
conala
|
13728486-26
|
get a list containing the sum of each element `i` in list `l` plus the previous elements
|
[sum(l[:i]) for i, _ in enumerate(l)]
|
[
"python.library.functions#enumerate",
"python.library.functions#sum"
] |
[sum(VAR_STR[:VAR_STR]) for VAR_STR, _ in enumerate(VAR_STR)]
|
conala
|
9743134-38
|
split a string `Docs/src/Scripts/temp` by `/` keeping `/` in the result
|
"""Docs/src/Scripts/temp""".replace('/', '/\x00/').split('\x00')
|
[
"python.library.stdtypes#str.replace",
"python.library.stdtypes#str.split"
] |
"""VAR_STR""".replace('VAR_STR', '/\x00/').split('\x00')
|
conala
|
32675861-45
|
copy all values in a column 'B' to a new column 'D' in a pandas data frame 'df'
|
df['D'] = df['B']
|
[] |
VAR_STR['VAR_STR'] = VAR_STR['VAR_STR']
|
conala
|
14227561-68
|
find a value within nested json 'data' where the key inside another key 'B' is unknown.
|
list(data['A']['B'].values())[0]['maindata'][0]['Info']
|
[
"python.library.functions#list",
"python.library.stdtypes#dict.values"
] |
list(VAR_STR['A']['VAR_STR'].values())[0]['maindata'][0]['Info']
|
conala
|
14858916-19
|
check characters of string `string` are true predication of function `predicate`
|
all(predicate(x) for x in string)
|
[
"python.library.functions#all"
] |
all(VAR_STR(x) for x in VAR_STR)
|
conala
|
6378889-70
|
convert string `user_input` into a list of integers `user_list`
|
user_list = [int(number) for number in user_input.split(',')]
|
[
"python.library.functions#int",
"python.library.stdtypes#str.split"
] |
VAR_STR = [int(number) for number in VAR_STR.split(',')]
|
conala
|
6378889-60
|
Get a list of integers by splitting a string `user` with comma
|
[int(s) for s in user.split(',')]
|
[
"python.library.functions#int",
"python.library.stdtypes#str.split"
] |
[int(s) for s in VAR_STR.split(',')]
|
conala
|
5212870-42
|
Sorting a Python list by two criteria
|
sorted(list, key=lambda x: (x[0], -x[1]))
|
[
"python.library.functions#sorted"
] |
sorted(list, key=lambda x: (x[0], -x[1]))
|
conala
|
403421-17
|
sort a list of objects `ut`, based on a function `cmpfun` in descending order
|
ut.sort(key=cmpfun, reverse=True)
|
[
"python.library.stdtypes#list.sort"
] |
VAR_STR.sort(key=VAR_STR, reverse=True)
|
conala
|
403421-16
|
reverse list `ut` based on the `count` attribute of each object
|
ut.sort(key=lambda x: x.count, reverse=True)
|
[
"python.library.stdtypes#list.sort"
] |
VAR_STR.sort(key=lambda x: x.VAR_STR, reverse=True)
|
conala
|
403421-6
|
sort a list of objects `ut` in reverse order by their `count` property
|
ut.sort(key=lambda x: x.count, reverse=True)
|
[
"python.library.stdtypes#list.sort"
] |
VAR_STR.sort(key=lambda x: x.VAR_STR, reverse=True)
|
conala
|
19601086-79
|
click a href button 'Send' with selenium
|
driver.find_element_by_partial_link_text('Send').click()
|
[] |
driver.find_element_by_partial_link_text('VAR_STR').click()
|
conala
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.