question_id
stringlengths
7
12
nl
stringlengths
4
200
cmd
stringlengths
2
232
oracle_man
sequence
canonical_cmd
stringlengths
2
228
cmd_name
stringclasses
1 value
21018612-78
download to a directory '/path/to/dir/filename.ext' from source 'http://example.com/file.ext'
urllib.request.urlretrieve('http://example.com/file.ext', '/path/to/dir/filename.ext')
[ "python.library.urllib.request#urllib.request.urlretrieve" ]
urllib.request.urlretrieve('VAR_STR', 'VAR_STR')
conala
20986631-1
scroll to the bottom of a web page using selenium webdriver
driver.execute_script('window.scrollTo(0, Y)')
[]
driver.execute_script('window.scrollTo(0, Y)')
conala
20986631-45
scroll a to the bottom of a web page using selenium webdriver
driver.execute_script('window.scrollTo(0, document.body.scrollHeight);')
[]
driver.execute_script('window.scrollTo(0, document.body.scrollHeight);')
conala
3662142-4
remove tags from a string `mystring`
re.sub('<[^>]*>', '', mystring)
[ "python.library.re#re.sub" ]
re.sub('<[^>]*>', '', VAR_STR)
conala
25678689-75
append array of strings `['x', 'x', 'x']` into one string
"""""".join(['x', 'x', 'x'])
[ "python.library.stdtypes#str.join" ]
"""""".join([VAR_STR])
conala
3252590-78
Find all the items from a dictionary `D` if the key contains the string `Light`
[(k, v) for k, v in D.items() if 'Light' in k]
[ "python.library.stdtypes#dict.items" ]
[(k, v) for k, v in VAR_STR.items() if 'VAR_STR' in k]
conala
18448469-27
create a list `result` containing elements form list `list_a` if first element of list `list_a` is in list `list_b`
result = [x for x in list_a if x[0] in list_b]
[]
VAR_STR = [x for x in VAR_STR if x[0] in VAR_STR]
conala
4127344-57
transforming the string `s` into dictionary
dict(map(int, x.split(':')) for x in s.split(','))
[ "python.library.functions#map", "python.library.stdtypes#dict", "python.library.stdtypes#str.split" ]
dict(map(int, x.split(':')) for x in VAR_STR.split(','))
conala
6086047-89
get output of script `proc`
print(proc.communicate()[0])
[ "python.library.subprocess#subprocess.Popen.communicate" ]
print(VAR_STR.communicate()[0])
conala
18722196-70
set UTC offset by 9 hrs ahead for date '2013/09/11 00:17'
dateutil.parser.parse('2013/09/11 00:17 +0900')
[ "python.library.email.parser#email.parser.Parser.parse" ]
dateutil.parser.parse('2013/09/11 00:17 +0900')
conala
1358977-73
Return a subplot axes positioned by the grid definition `1,1,1` using matpotlib
fig.add_subplot(1, 1, 1)
[ "matplotlib.figure_api#matplotlib.figure.FigureBase.add_subplot" ]
fig.add_subplot(1, 1, 1)
conala
18689823-5
replace nan values in a pandas data frame with the average of columns
df.apply(lambda x: x.fillna(x.mean()), axis=0)
[ "pandas.reference.api.pandas.dataframe.apply", "pandas.reference.api.pandas.dataframe.fillna", "pandas.reference.api.pandas.dataframe.mean" ]
df.apply(lambda x: x.fillna(x.mean()), axis=0)
conala
2972212-34
Creating an empty list `l`
l = []
[]
VAR_STR = []
conala
2972212-64
Creating an empty list `l`
l = list()
[ "python.library.functions#list" ]
VAR_STR = list()
conala
2972212-86
Creating an empty list
list()
[ "python.library.functions#list" ]
list()
conala
2972212-96
Creating an empty list
[]
[]
[]
conala
16412563-51
sort dictionary of dictionaries `dic` according to the key 'Fisher'
sorted(list(dic.items()), key=lambda x: x[1]['Fisher'], reverse=True)
[ "python.library.functions#sorted", "python.library.functions#list", "python.library.stdtypes#dict.items" ]
sorted(list(VAR_STR.items()), key=lambda x: x[1]['VAR_STR'], reverse=True)
conala
9573244-39
check if the string `myString` is empty
if (not myString): pass
[]
if not VAR_STR: pass
conala
9573244-74
check if string `some_string` is empty
if (not some_string): pass
[]
if not VAR_STR: pass
conala
9573244-79
check if string `my_string` is empty
if (not my_string): pass
[]
if not VAR_STR: pass
conala
9573244-4
check if string `my_string` is empty
if some_string: pass
[]
if some_string: pass
conala
12402561-84
set font size of axis legend of plot `plt` to 'xx-small'
plt.setp(legend.get_title(), fontsize='xx-small')
[ "matplotlib.legend_api#matplotlib.legend.Legend.get_title", "matplotlib._as_gen.matplotlib.artist.setp" ]
VAR_STR.setp(legend.get_title(), fontsize='VAR_STR')
conala
7633274-73
Get a list of words from a string `Hello world, my name is...James the 2nd!` removing punctuation
re.compile('\\w+').findall('Hello world, my name is...James the 2nd!')
[ "python.library.re#re.compile", "python.library.re#re.findall" ]
re.compile('\\w+').findall('VAR_STR')
conala
22625616-82
list all files in a current directory
glob.glob('*')
[]
glob.glob('*')
conala
22625616-43
List all the files that doesn't contain the name `hello`
glob.glob('[!hello]*.txt')
[]
glob.glob('[!hello]*.txt')
conala
22625616-69
List all the files that matches the pattern `hello*.txt`
glob.glob('hello*.txt')
[]
glob.glob('VAR_STR')
conala
2911754-43
upload binary file `myfile.txt` with ftplib
ftp.storbinary('STOR myfile.txt', open('myfile.txt', 'rb'))
[ "python.library.urllib.request#open", "python.library.ftplib#ftplib.FTP.storbinary" ]
ftp.storbinary('STOR myfile.txt', open('VAR_STR', 'rb'))
conala
41552839-94
convert and escape string "\\xc3\\x85あ" to UTF-8 code
"""\\xc3\\x85あ""".encode('utf-8').decode('unicode_escape')
[ "python.library.stdtypes#str.encode", "python.library.stdtypes#bytearray.decode" ]
"""\\xc3\\x85あ""".encode('utf-8').decode('unicode_escape')
conala
41552839-27
encode string "\\xc3\\x85あ" to bytes
"""\\xc3\\x85あ""".encode('utf-8')
[ "python.library.stdtypes#str.encode" ]
"""\\xc3\\x85あ""".encode('utf-8')
conala
28773683-11
combine dataframe `df1` and dataframe `df2` by index number
pd.merge(df1, df2, left_index=True, right_index=True, how='outer')
[ "pandas.reference.api.pandas.merge" ]
pd.merge(VAR_STR, VAR_STR, left_index=True, right_index=True, how='outer')
conala
28773683-66
Combine two Pandas dataframes with the same index
pandas.concat([df1, df2], axis=1)
[ "pandas.reference.api.pandas.concat" ]
pandas.concat([df1, df2], axis=1)
conala
20894525-98
replace parentheses and all data within it with empty string '' in column 'name' of dataframe `df`
df['name'].str.replace('\\(.*\\)', '')
[ "python.library.stdtypes#str.replace" ]
VAR_STR['VAR_STR'].str.replace('\\(.*\\)', 'VAR_STR')
conala
41313232-31
delete items from list `my_list` if the item exist in list `to_dell`
my_list = [[x for x in sublist if x not in to_del] for sublist in my_list]
[]
VAR_STR = [[x for x in sublist if x not in to_del] for sublist in VAR_STR]
conala
4682088-12
invoke perl script './uireplace.pl' using perl interpeter '/usr/bin/perl' and send argument `var` to it
subprocess.call(['/usr/bin/perl', './uireplace.pl', var])
[ "python.library.subprocess#subprocess.call" ]
subprocess.call(['VAR_STR', 'VAR_STR', VAR_STR])
conala
5245058-99
filter lines from a text file 'textfile' which contain a word 'apple'
[line for line in open('textfile') if 'apple' in line]
[ "python.library.urllib.request#open" ]
[line for line in open('VAR_STR') if 'VAR_STR' in line]
conala
17149561-2
Check if the value of the key "name" is "Test" in a list of dictionaries `label`
any(d['name'] == 'Test' for d in label)
[ "python.library.functions#any" ]
any(d['VAR_STR'] == 'VAR_STR' for d in VAR_STR)
conala
32950347-8
get value in string `line` matched by regex pattern '\\bLOG_ADDR\\s+(\\S+)'
print(re.search('\\bLOG_ADDR\\s+(\\S+)', line).group(1))
[ "python.library.re#re.search", "python.library.re#re.Match.group" ]
print(re.search('VAR_STR', VAR_STR).group(1))
conala
14991195-10
remove all null values from columns 'three', 'four' and 'five' of dataframe `df2`
df2.dropna(subset=['three', 'four', 'five'], how='all')
[ "pandas.reference.api.pandas.dataframe.dropna" ]
VAR_STR.dropna(subset=['VAR_STR', 'VAR_STR', 'VAR_STR'], how='all')
conala
902408-3
insert variables `(var1, var2, var3)` into sql statement 'INSERT INTO table VALUES (?, ?, ?)'
cursor.execute('INSERT INTO table VALUES (?, ?, ?)', (var1, var2, var3))
[ "python.library.sqlite3#sqlite3.Cursor.execute" ]
cursor.execute('VAR_STR', (VAR_STR))
conala
902408-38
Execute a sql statement using variables `var1`, `var2` and `var3`
cursor.execute('INSERT INTO table VALUES (%s, %s, %s)', (var1, var2, var3))
[ "python.library.sqlite3#sqlite3.Cursor.execute" ]
cursor.execute('INSERT INTO table VALUES (%s, %s, %s)', (VAR_STR, VAR_STR, VAR_STR))
conala
902408-71
How to use variables in SQL statement in Python?
cursor.execute('INSERT INTO table VALUES (%s, %s, %s)', (var1, var2, var3))
[ "python.library.sqlite3#sqlite3.Cursor.execute" ]
cursor.execute('INSERT INTO table VALUES (%s, %s, %s)', (var1, var2, var3))
conala
23931444-78
Selenium `driver` click a hyperlink with the pattern "a[href^='javascript']"
driver.find_element_by_css_selector("a[href^='javascript']").click()
[]
VAR_STR.find_element_by_css_selector('VAR_STR').click()
conala
13793973-44
Print string `t` with proper unicode representations
print(t.decode('unicode_escape'))
[ "python.library.stdtypes#bytearray.decode" ]
print(VAR_STR.decode('unicode_escape'))
conala
33824334-79
convert list `lst` of key, value pairs into a dictionary
dict([(e[0], int(e[1])) for e in lst])
[ "python.library.functions#int", "python.library.stdtypes#dict" ]
dict([(e[0], int(e[1])) for e in VAR_STR])
conala
14041791-87
Print a string `card` with string formatting
print('I have: {0.price}'.format(card))
[ "python.library.functions#format" ]
print('I have: {0.price}'.format(VAR_STR))
conala
969285-80
None
datetime.datetime.strptime('2007-03-04T21:08:12', '%Y-%m-%dT%H:%M:%S')
[ "python.library.datetime#datetime.datetime.strptime" ]
datetime.datetime.strptime('2007-03-04T21:08:12', '%Y-%m-%dT%H:%M:%S')
conala
2764586-55
get current requested url
self.request.url
[]
self.request.url
conala
2424412-78
convert list of strings `str_list` into list of integers
[int(i) for i in str_list]
[ "python.library.functions#int" ]
[int(i) for i in VAR_STR]
conala
2424412-99
convert a list with string `['1', '2', '3']` into list with integers
map(int, ['1', '2', '3'])
[ "python.library.functions#map" ]
map(int, [VAR_STR])
conala
2424412-2
convert list with str into list with int
list(map(int, ['1', '2', '3']))
[ "python.library.functions#map", "python.library.functions#list" ]
list(map(int, ['1', '2', '3']))
conala
33680914-50
Return values for column `C` after group by on column `A` and `B` in dataframe `df`
df.groupby(['A', 'B'])['C'].unique()
[ "pandas.reference.api.pandas.dataframe.groupby", "pandas.reference.api.pandas.core.groupby.seriesgroupby.unique" ]
VAR_STR.groupby(['VAR_STR', 'VAR_STR'])['VAR_STR'].unique()
conala
19939084-58
plot point marker '.' on series `ts`
ts.plot(marker='.')
[ "pandas.reference.api.pandas.dataframe.plot" ]
VAR_STR.plot(marker='VAR_STR')
conala
15459217-11
Add header `('Cookie', 'cookiename=cookie value')` to mechanize browser `br`
br.addheaders = [('Cookie', 'cookiename=cookie value')]
[]
VAR_STR.addheaders = [(VAR_STR)]
conala
33065588-27
execute a command `command ` in the terminal from a python script
os.system(command)
[ "python.library.os#os.system" ]
os.system(VAR_STR)
conala
4716533-82
attach debugger pdb to class `ForkedPdb`
ForkedPdb().set_trace()
[ "python.library.bdb#bdb.set_trace" ]
VAR_STR().set_trace()
conala
26897536-42
drop all columns in dataframe `df` that holds a maximum value bigger than 0
df.columns[df.max() > 0]
[ "pandas.reference.api.pandas.dataframe.max" ]
VAR_STR.columns[VAR_STR.max() > 0]
conala
1720421-45
concatenate lists `listone` and `listtwo`
(listone + listtwo)
[]
VAR_STR + VAR_STR
conala
1720421-49
iterate items in lists `listone` and `listtwo`
for item in itertools.chain(listone, listtwo): pass
[ "python.library.itertools#itertools.chain" ]
for item in itertools.chain(VAR_STR, VAR_STR): pass
conala
9637838-45
convert date string `s` in format pattern '%d/%m/%Y' into a timestamp
time.mktime(datetime.datetime.strptime(s, '%d/%m/%Y').timetuple())
[ "python.library.datetime#datetime.datetime.strptime", "python.library.time#time.mktime", "python.library.datetime#datetime.datetime.timetuple" ]
time.mktime(datetime.datetime.strptime(VAR_STR, 'VAR_STR').timetuple())
conala
9637838-89
convert string '01/12/2011' to an integer timestamp
int(datetime.datetime.strptime('01/12/2011', '%d/%m/%Y').strftime('%s'))
[ "python.library.datetime#datetime.datetime.strptime", "python.library.functions#int", "python.library.datetime#datetime.datetime.strftime" ]
int(datetime.datetime.strptime('VAR_STR', '%d/%m/%Y').strftime('%s'))
conala
6490560-12
move the last item in list `a` to the beginning
a = a[-1:] + a[:-1]
[]
VAR_STR = VAR_STR[-1:] + VAR_STR[:-1]
conala
14961014-3
Remove the string value `item` from a list of strings `my_sequence`
[item for item in my_sequence if item != 'item']
[]
[VAR_STR for VAR_STR in VAR_STR if VAR_STR != 'VAR_STR']
conala
19112735-16
print each first value from a list of tuples `mytuple` with string formatting
print(', ,'.join([str(i[0]) for i in mytuple]))
[ "python.library.stdtypes#str", "python.library.stdtypes#str.join" ]
print(', ,'.join([str(i[0]) for i in VAR_STR]))
conala
12337583-90
Serialize dictionary `data` and its keys to a JSON formatted string
json.dumps({str(k): v for k, v in data.items()})
[ "python.library.json#json.dumps", "python.library.stdtypes#str", "python.library.stdtypes#dict.items" ]
json.dumps({str(k): v for k, v in VAR_STR.items()})
conala
32464280-95
remove dollar sign '$' from second to last column data in dataframe 'df' and convert the data into floats
df[df.columns[1:]].replace('[\\$,]', '', regex=True).astype(float)
[ "pandas.reference.api.pandas.dataframe.astype", "pandas.reference.api.pandas.dataframe.replace" ]
VAR_STR[VAR_STR.columns[1:]].replace('[\\$,]', '', regex=True).astype(float)
conala
199059-12
insert spaces before capital letters in string `text`
re.sub('([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))', '\\1 ', text)
[ "python.library.re#re.sub" ]
re.sub('([a-z](?=[A-Z])|[A-Z](?=[A-Z][a-z]))', '\\1 ', VAR_STR)
conala
27946742-34
Get all the sentences from a string `text` using regex
re.split('\\.\\s', text)
[ "python.library.re#re.split" ]
re.split('\\.\\s', VAR_STR)
conala
27946742-72
Regular expression in Python sentence extractor
re.split('\\.\\s', re.sub('\\.\\s*$', '', text))
[ "python.library.re#re.sub", "python.library.re#re.split" ]
re.split('\\.\\s', re.sub('\\.\\s*$', '', text))
conala
4576115-20
convert a list 'a' to a dictionary where each even element represents the key to the dictionary, and the following odd element is the value
b = {a[i]: a[i + 1] for i in range(0, len(a), 2)}
[ "python.library.functions#len", "python.library.functions#range" ]
b = {VAR_STR[i]: VAR_STR[i + 1] for i in range(0, len(VAR_STR), 2)}
conala
31888871-4
replace value 0 with 'Female' and value 1 with 'Male' in column 'sex' of dataframe `data`
data['sex'].replace([0, 1], ['Female', 'Male'], inplace=True)
[ "python.library.stdtypes#str.replace" ]
VAR_STR['VAR_STR'].replace([0, 1], ['VAR_STR', 'VAR_STR'], inplace=True)
conala
16766643-79
convert date string 'January 11, 2010' into day of week
datetime.datetime.strptime('January 11, 2010', '%B %d, %Y').strftime('%A')
[ "python.library.datetime#datetime.datetime.strptime", "python.library.datetime#datetime.datetime.strftime" ]
datetime.datetime.strptime('VAR_STR', '%B %d, %Y').strftime('%A')
conala
16766643-43
Convert Date String to Day of Week
datetime.datetime.strptime('January 11, 2010', '%B %d, %Y').strftime('%a')
[ "python.library.datetime#datetime.datetime.strptime", "python.library.datetime#datetime.datetime.strftime" ]
datetime.datetime.strptime('January 11, 2010', '%B %d, %Y').strftime('%a')
conala
2813806-71
check if key 'stackoverflow' and key 'google' are presented in dictionary `sites`
set(['stackoverflow', 'google']).issubset(sites)
[ "python.library.stdtypes#set", "python.library.stdtypes#frozenset.issubset" ]
set(['VAR_STR', 'VAR_STR']).issubset(VAR_STR)
conala
36623789-63
convert unicode text from list `elems` with index 0 to normal text 'utf-8'
elems[0].getText().encode('utf-8')
[ "python.library.gettext#gettext.gettext", "python.library.stdtypes#str.encode" ]
VAR_STR[0].getText().encode('VAR_STR')
conala
7238226-76
Convert a datetime object `dt` to microtime
time.mktime(dt.timetuple()) + dt.microsecond / 1000000.0
[ "python.library.time#time.mktime", "python.library.datetime#datetime.datetime.timetuple" ]
time.mktime(VAR_STR.timetuple()) + VAR_STR.microsecond / 1000000.0
conala
82831-64
check whether a file `fname` exists
os.path.isfile(fname)
[ "python.library.os.path#os.path.isfile" ]
os.path.isfile(VAR_STR)
conala
82831-96
check whether file "/path/to/file" exists
my_file = Path('/path/to/file') if my_file.is_file(): pass
[ "python.library.zipfile#zipfile.Path.is_file", "matplotlib.path_api#matplotlib.path.Path" ]
my_file = Path('VAR_STR') if my_file.is_file(): pass
conala
82831-55
check whether file `file_path` exists
os.path.exists(file_path)
[ "python.library.os.path#os.path.exists" ]
os.path.exists(VAR_STR)
conala
82831-86
check whether a file "/etc/password.txt" exists
print(os.path.isfile('/etc/password.txt'))
[ "python.library.os.path#os.path.isfile" ]
print(os.path.isfile('VAR_STR'))
conala
82831-46
check whether a file "/etc" exists
print(os.path.isfile('/etc'))
[ "python.library.os.path#os.path.isfile" ]
print(os.path.isfile('VAR_STR'))
conala
82831-2
check whether a path "/does/not/exist" exists
print(os.path.exists('/does/not/exist'))
[ "python.library.os.path#os.path.exists" ]
print(os.path.exists('VAR_STR'))
conala
82831-53
check whether a file "/does/not/exist" exists
print(os.path.isfile('/does/not/exist'))
[ "python.library.os.path#os.path.isfile" ]
print(os.path.isfile('VAR_STR'))
conala
82831-40
check whether a path "/etc" exists
print(os.path.exists('/etc'))
[ "python.library.os.path#os.path.exists" ]
print(os.path.exists('VAR_STR'))
conala
82831-24
check whether a path "/etc/password.txt" exists
print(os.path.exists('/etc/password.txt'))
[ "python.library.os.path#os.path.exists" ]
print(os.path.exists('VAR_STR'))
conala
19328874-69
print line `line` from text file with 'utf-16-le' format
print(line.decode('utf-16-le').split())
[ "python.library.stdtypes#bytearray.decode", "python.library.stdtypes#str.split" ]
print(VAR_STR.decode('VAR_STR').split())
conala
19328874-21
open a text file `data.txt` in io module with encoding `utf-16-le`
file = io.open('data.txt', 'r', encoding='utf-16-le')
[ "python.library.io#io.open" ]
file = io.open('VAR_STR', 'r', encoding='VAR_STR')
conala
14180866-79
create a list with the sum of respective elements of the tuples of list `l`
[sum(x) for x in zip(*l)]
[ "python.library.functions#zip", "python.library.functions#sum" ]
[sum(x) for x in zip(*VAR_STR)]
conala
14180866-73
sum each value in a list `l` of tuples
map(sum, zip(*l))
[ "python.library.functions#zip", "python.library.functions#map" ]
map(sum, zip(*VAR_STR))
conala
187455-29
count the number of elements in array `myArray`
len(myArray)
[ "python.library.functions#len" ]
len(VAR_STR)
conala
42180455-54
BeautifulSoup select 'div' elements with an id attribute value ending with sub-string '_answer' in HTML parsed string `soup`
soup.select('div[id$=_answer]')
[ "python.library.select#select.select" ]
VAR_STR.select('div[id$=_answer]')
conala
1064335-63
kill a process with id `process.pid`
os.kill(process.pid, signal.SIGKILL)
[ "python.library.os#os.kill" ]
os.kill(process.pid, signal.SIGKILL)
conala
42950-17
Get Last Day of the first month in 2002
calendar.monthrange(2002, 1)
[ "python.library.calendar#calendar.monthrange" ]
calendar.monthrange(2002, 1)
conala
42950-48
Get Last Day of the second month in 2002
calendar.monthrange(2008, 2)
[ "python.library.calendar#calendar.monthrange" ]
calendar.monthrange(2008, 2)
conala
42950-64
Get Last Day of the second month in 2100
calendar.monthrange(2100, 2)
[ "python.library.calendar#calendar.monthrange" ]
calendar.monthrange(2100, 2)
conala
42950-85
Get Last Day of the month `month` in year `year`
calendar.monthrange(year, month)[1]
[ "python.library.calendar#calendar.monthrange" ]
calendar.monthrange(VAR_STR, VAR_STR)[1]
conala
42950-60
Get Last Day of the second month in year 2012
monthrange(2012, 2)
[ "python.library.calendar#calendar.monthrange" ]
monthrange(2012, 2)
conala
42950-91
Get Last Day of the first month in year 2000
(datetime.date(2000, 2, 1) - datetime.timedelta(days=1))
[ "python.library.datetime#datetime.timedelta", "python.library.datetime#datetime.date" ]
datetime.date(2000, 2, 1) - datetime.timedelta(days=1)
conala
15286401-73
print the string `Total score for`, the value of the variable `name`, the string `is` and the value of the variable `score` in one print call.
print(('Total score for', name, 'is', score))
[]
print(('VAR_STR', VAR_STR, 'VAR_STR', VAR_STR))
conala
15286401-49
print multiple arguments 'name' and 'score'.
print('Total score for {} is {}'.format(name, score))
[ "python.library.functions#format" ]
print('Total score for {} is {}'.format(VAR_STR, VAR_STR))
conala
15286401-39
print a string using multiple strings `name` and `score`
print('Total score for %s is %s ' % (name, score))
[]
print('Total score for %s is %s ' % (VAR_STR, VAR_STR))
conala