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 |
---|---|---|---|---|---|
8970524-33
|
search and split string 'aaa bbb ccc ddd eee fff' by delimiter '(ddd)'
|
re.split('(ddd)', 'aaa bbb ccc ddd eee fff', 1)
|
[
"python.library.re#re.split"
] |
re.split('VAR_STR', 'VAR_STR', 1)
|
conala
|
8970524-8
|
regex search and split string 'aaa bbb ccc ddd eee fff' by delimiter '(d(d)d)'
|
re.split('(d(d)d)', 'aaa bbb ccc ddd eee fff', 1)
|
[
"python.library.re#re.split"
] |
re.split('VAR_STR', 'VAR_STR', 1)
|
conala
|
20876077-34
|
unescape special characters without splitting data in array of strings `['I ', u'<', '3s U ', u'&', ' you luvz me']`
|
"""""".join(['I ', '<', '3s U ', '&', ' you luvz me'])
|
[
"python.library.stdtypes#str.join"
] |
"""""".join(['I ', '<', '3s U ', '&', ' you luvz me'])
|
conala
|
3486384-86
|
output first 100 characters in a string `my_string`
|
print(my_string[0:100])
|
[] |
print(VAR_STR[0:100])
|
conala
|
19095796-93
|
print backslash
|
print('\\')
|
[] |
print('\\')
|
conala
|
42100344-66
|
convert a dataframe `df`'s column `ID` into datetime, after removing the first and last 3 letters
|
pd.to_datetime(df.ID.str[1:-3])
|
[
"pandas.reference.api.pandas.to_datetime"
] |
pd.to_datetime(VAR_STR.VAR_STR.str[1:-3])
|
conala
|
15451958-12
|
create 3 by 3 matrix of random numbers
|
numpy.random.random((3, 3))
|
[] |
numpy.random.random((3, 3))
|
conala
|
1482308-10
|
create a list with permutations of string 'abcd'
|
list(powerset('abcd'))
|
[
"python.library.functions#list"
] |
list(powerset('VAR_STR'))
|
conala
|
13331419-85
|
prepend string 'hello' to all items in list 'a'
|
['hello{0}'.format(i) for i in a]
|
[
"python.library.functions#format"
] |
['hello{0}'.format(i) for i in VAR_STR]
|
conala
|
16114333-7
|
get the opposite diagonal of a numpy array `array`
|
np.diag(np.rot90(array))
|
[
"numpy.reference.generated.numpy.rot90",
"numpy.reference.generated.numpy.diag"
] |
np.diag(np.rot90(VAR_STR))
|
conala
|
29565452-57
|
get the average of a list values for each key in dictionary `d`)
|
[(i, sum(j) / len(j)) for i, j in list(d.items())]
|
[
"python.library.functions#len",
"python.library.functions#sum",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
[(i, sum(j) / len(j)) for i, j in list(VAR_STR.items())]
|
conala
|
29945684-49
|
get domain/host name from request object in Django
|
request.META['HTTP_HOST']
|
[] |
request.META['HTTP_HOST']
|
conala
|
4768151-85
|
sort list `bar` by each element's attribute `attrb1` and attribute `attrb2` in reverse order
|
bar.sort(key=lambda x: (x.attrb1, x.attrb2), reverse=True)
|
[
"python.library.stdtypes#list.sort"
] |
VAR_STR.sort(key=lambda x: (x.VAR_STR, x.VAR_STR), reverse=True)
|
conala
|
10541640-99
|
Represent DateTime object '10/05/2012' with format '%d/%m/%Y' into format '%Y-%m-%d'
|
datetime.datetime.strptime('10/05/2012', '%d/%m/%Y').strftime('%Y-%m-%d')
|
[
"python.library.datetime#datetime.datetime.strptime",
"python.library.datetime#datetime.datetime.strftime"
] |
datetime.datetime.strptime('VAR_STR', 'VAR_STR').strftime('VAR_STR')
|
conala
|
32874539-7
|
find a tag `option` whose `value` attribute is `state` in selenium
|
driver.find_element_by_xpath("//option[@value='" + state + "']").click()
|
[] |
driver.find_element_by_xpath("//option[@value='" + VAR_STR + "']").click()
|
conala
|
2045175-76
|
write a regex pattern to match even number of letter `A`
|
re.compile('^([^A]*)AA([^A]|AA)*$')
|
[
"python.library.re#re.compile"
] |
re.compile('^([^A]*)AA([^A]|AA)*$')
|
conala
|
34776651-9
|
group rows of pandas dataframe `df` with same 'id'
|
df.groupby('id').agg(lambda x: x.tolist())
|
[
"pandas.reference.api.pandas.dataframe.groupby",
"pandas.reference.api.pandas.dataframe.agg",
"pandas.reference.api.pandas.series.tolist"
] |
VAR_STR.groupby('VAR_STR').agg(lambda x: x.tolist())
|
conala
|
3207219-21
|
list all files of a directory `mypath`
|
onlyfiles = [f for f in listdir(mypath) if isfile(join(mypath, f))]
|
[
"python.library.os#os.listdir",
"python.library.tarfile#tarfile.TarInfo.isfile",
"python.library.stdtypes#str.join"
] |
onlyfiles = [f for f in listdir(VAR_STR) if isfile(join(VAR_STR, f))]
|
conala
|
3207219-76
|
list all files of a directory `mypath`
|
f = []
for (dirpath, dirnames, filenames) in walk(mypath):
f.extend(filenames)
break
|
[
"python.library.os#os.walk",
"python.library.collections#collections.deque.extend"
] |
f = []
for dirpath, dirnames, filenames in walk(VAR_STR):
f.extend(filenames)
break
|
conala
|
3207219-42
|
list all ".txt" files of a directory "/home/adam/"
|
print(glob.glob('/home/adam/*.txt'))
|
[] |
print(glob.glob('/home/adam/*.txt'))
|
conala
|
3207219-15
|
list all files of a directory "somedirectory"
|
os.listdir('somedirectory')
|
[
"python.library.os#os.listdir"
] |
os.listdir('VAR_STR')
|
conala
|
12557612-50
|
call parent class `Instructor` of child class constructor
|
super(Instructor, self).__init__(name, year)
|
[
"python.library.functions#super",
"python.library.logging#logging.Handler.__init__"
] |
super(VAR_STR, self).__init__(name, year)
|
conala
|
2416823-80
|
Get all the texts without tags from beautiful soup object `soup`
|
"""""".join(soup.findAll(text=True))
|
[
"python.library.re#re.findall",
"python.library.stdtypes#str.join"
] |
"""""".join(VAR_STR.findAll(text=True))
|
conala
|
2389846-77
|
format a string `num` using string formatting
|
"""{0:.3g}""".format(num)
|
[
"python.library.functions#format"
] |
"""{0:.3g}""".format(VAR_STR)
|
conala
|
9257094-100
|
change string `s` to upper case
|
s.upper()
|
[
"python.library.stdtypes#str.upper"
] |
VAR_STR.upper()
|
conala
|
40987319-40
|
extract the first four rows of the column `ID` from a pandas dataframe `df`
|
df.groupby('ID').head(4)
|
[
"pandas.reference.api.pandas.dataframe.groupby",
"pandas.reference.api.pandas.dataframe.head"
] |
VAR_STR.groupby('VAR_STR').head(4)
|
conala
|
42548362-27
|
Convert escaped utf string to utf string in `your string`
|
print('your string'.decode('string_escape'))
|
[
"python.library.stdtypes#bytearray.decode"
] |
print('VAR_STR'.decode('string_escape'))
|
conala
|
17713873-84
|
sort list `['14:10:01', '03:12:08']`
|
sorted(['14:10:01', '03:12:08'])
|
[
"python.library.functions#sorted"
] |
sorted([VAR_STR])
|
conala
|
35269374-86
|
count the number of True values associated with key 'success' in dictionary `d`
|
sum(1 if d['success'] else 0 for d in s)
|
[
"python.library.functions#sum"
] |
sum(1 if VAR_STR['VAR_STR'] else 0 for VAR_STR in s)
|
conala
|
35269374-25
|
get the sum of values associated with the key ‘success’ for a list of dictionaries `s`
|
sum(d['success'] for d in s)
|
[
"python.library.functions#sum"
] |
sum(d['success'] for d in VAR_STR)
|
conala
|
13093727-42
|
replace unicode character '\u2022' in string 'str' with '*'
|
str.decode('utf-8').replace('\u2022', '*').encode('utf-8')
|
[
"python.library.stdtypes#str.encode",
"python.library.stdtypes#str.replace",
"pandas.reference.api.pandas.series.str.decode"
] |
VAR_STR.decode('utf-8').replace('VAR_STR', 'VAR_STR').encode('utf-8')
|
conala
|
13093727-83
|
replace unicode characters ''\u2022' in string 'str' with '*'
|
str.decode('utf-8').replace('\u2022', '*')
|
[
"python.library.stdtypes#str.replace",
"pandas.reference.api.pandas.series.str.decode"
] |
str.decode('utf-8').replace('•', '*')
|
conala
|
4362586-5
|
sum a list of numbers `list_of_nums`
|
sum(list_of_nums)
|
[
"python.library.functions#sum"
] |
sum(VAR_STR)
|
conala
|
41246071-1
|
Spawn a process to run python script `myscript.py` in C++
|
system('python myscript.py')
|
[
"python.library.os#os.system"
] |
system('python myscript.py')
|
conala
|
1348026-75
|
create file 'x' if file 'x' does not exist
|
fd = os.open('x', os.O_WRONLY | os.O_CREAT | os.O_EXCL)
|
[
"python.library.os#os.open"
] |
fd = os.open('VAR_STR', os.O_WRONLY | os.O_CREAT | os.O_EXCL)
|
conala
|
6429638-16
|
split a string `s` into integers
|
l = (int(x) for x in s.split())
|
[
"python.library.functions#int",
"python.library.stdtypes#str.split"
] |
l = (int(x) for x in VAR_STR.split())
|
conala
|
6429638-63
|
split a string `42 0` by white spaces.
|
"""42 0""".split()
|
[
"python.library.stdtypes#str.split"
] |
"""VAR_STR""".split()
|
conala
|
6429638-62
|
How to split a string into integers in Python?
|
map(int, '42 0'.split())
|
[
"python.library.functions#map",
"python.library.stdtypes#str.split"
] |
map(int, '42 0'.split())
|
conala
|
973473-86
|
getting a list of all subdirectories in the directory `directory`
|
os.walk(directory)
|
[
"python.library.os#os.walk"
] |
os.walk(VAR_STR)
|
conala
|
973473-48
|
get a list of all subdirectories in the directory `directory`
|
[x[0] for x in os.walk(directory)]
|
[
"python.library.os#os.walk"
] |
[x[0] for x in os.walk(VAR_STR)]
|
conala
|
579856-6
|
combine two sequences into a dictionary
|
dict(zip(keys, values))
|
[
"python.library.functions#zip",
"python.library.stdtypes#dict"
] |
dict(zip(keys, values))
|
conala
|
13860026-30
|
update the dictionary `mydic` with dynamic keys `i` and values with key 'name' from dictionary `o`
|
mydic.update({i: o['name']})
|
[
"python.library.stdtypes#dict.update"
] |
VAR_STR.update({VAR_STR: VAR_STR['VAR_STR']})
|
conala
|
9759820-64
|
get a list of variables from module 'adfix.py' in current module.
|
print([item for item in dir(adfix) if not item.startswith('__')])
|
[
"python.library.functions#dir",
"python.library.stdtypes#str.startswith"
] |
print([item for item in dir(adfix) if not item.startswith('__')])
|
conala
|
12717716-47
|
update dictionary `b`, overwriting values where keys are identical, with contents of dictionary `d`
|
b.update(d)
|
[
"python.library.stdtypes#dict.update"
] |
VAR_STR.update(VAR_STR)
|
conala
|
6532881-46
|
make a row-by-row copy `y` of array `x`
|
y = [row[:] for row in x]
|
[] |
VAR_STR = [row[:] for row in VAR_STR]
|
conala
|
16888888-32
|
read excel file `file_name` using pandas
|
dfs = pd.read_excel(file_name, sheetname=None)
|
[
"pandas.reference.api.pandas.read_excel"
] |
dfs = pd.read_excel(VAR_STR, sheetname=None)
|
conala
|
13840883-15
|
Find all words containing letters between A and Z in string `formula`
|
re.findall('\\b[A-Z]', formula)
|
[
"python.library.re#re.findall"
] |
re.findall('\\b[A-Z]', VAR_STR)
|
conala
|
247724-56
|
How can I launch an instance of an application using Python?
|
os.system('start excel.exe <path/to/file>')
|
[
"python.library.os#os.system"
] |
os.system('start excel.exe <path/to/file>')
|
conala
|
974678-36
|
create a flat dictionary by summing values associated with similar keys in each dictionary of list `dictlist`
|
dict((key, sum(d[key] for d in dictList)) for key in dictList[0])
|
[
"python.library.stdtypes#dict",
"python.library.functions#sum"
] |
dict((key, sum(d[key] for d in dictList)) for key in dictList[0])
|
conala
|
8425046-90
|
Remove all items from a dictionary `d` where the values are less than `1`
|
d = dict((k, v) for k, v in d.items() if v > 0)
|
[
"python.library.stdtypes#dict",
"python.library.stdtypes#dict.items"
] |
VAR_STR = dict((k, v) for k, v in VAR_STR.items() if v > 0)
|
conala
|
8425046-64
|
Filter dictionary `d` to have items with value greater than 0
|
d = {k: v for k, v in list(d.items()) if v > 0}
|
[
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
VAR_STR = {k: v for k, v in list(VAR_STR.items()) if v > 0}
|
conala
|
8993904-11
|
split string 'fooxyzbar' based on case-insensitive matching using string 'XYZ'
|
re.compile('XYZ', re.IGNORECASE).split('fooxyzbar')
|
[
"python.library.re#re.compile",
"python.library.re#re.split"
] |
re.compile('VAR_STR', re.IGNORECASE).split('VAR_STR')
|
conala
|
3945750-54
|
BeautifulSoup find tag 'div' with styling 'width=300px;' in HTML string `soup`
|
soup.findAll('div', style='width=300px;')
|
[
"python.library.re#re.findall"
] |
VAR_STR.findAll('VAR_STR', style='VAR_STR')
|
conala
|
15080500-99
|
send a signal `signal.SIGUSR1` to the current process
|
os.kill(os.getpid(), signal.SIGUSR1)
|
[
"python.library.os#os.getpid",
"python.library.os#os.kill"
] |
os.kill(os.getpid(), signal.SIGUSR1)
|
conala
|
3844801-14
|
check if all elements in list `myList` are identical
|
all(x == myList[0] for x in myList)
|
[
"python.library.functions#all"
] |
all(x == VAR_STR[0] for x in VAR_STR)
|
conala
|
4302166-0
|
format number of spaces between strings `Python`, `:` and `Very Good` to be `20`
|
print('%*s : %*s' % (20, 'Python', 20, 'Very Good'))
|
[] |
print('%*s : %*s' % (20, 'VAR_STR', 20, 'VAR_STR'))
|
conala
|
7555335-11
|
How to convert a string from CP-1251 to UTF-8?
|
d.decode('cp1251').encode('utf8')
|
[
"python.library.stdtypes#str.encode",
"python.library.stdtypes#bytearray.decode"
] |
d.decode('cp1251').encode('utf8')
|
conala
|
2544710-74
|
get rid of None values in dictionary `kwargs`
|
res = {k: v for k, v in list(kwargs.items()) if v is not None}
|
[
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
res = {k: v for k, v in list(VAR_STR.items()) if v is not None}
|
conala
|
2544710-4
|
get rid of None values in dictionary `kwargs`
|
res = dict((k, v) for k, v in kwargs.items() if v is not None)
|
[
"python.library.stdtypes#dict",
"python.library.stdtypes#dict.items"
] |
res = dict((k, v) for k, v in VAR_STR.items() if v is not None)
|
conala
|
6726636-88
|
concatenate a list of strings `['a', 'b', 'c']`
|
"""""".join(['a', 'b', 'c'])
|
[
"python.library.stdtypes#str.join"
] |
"""""".join([VAR_STR])
|
conala
|
8315209-12
|
sending http headers to `client`
|
client.send('HTTP/1.0 200 OK\r\n')
|
[
"python.library.http.client#http.client.HTTPConnection.send"
] |
VAR_STR.send('HTTP/1.0 200 OK\r\n')
|
conala
|
172439-45
|
split a multi-line string `inputString` into separate strings
|
inputString.split('\n')
|
[
"python.library.stdtypes#str.split"
] |
VAR_STR.split('\n')
|
conala
|
172439-30
|
Split a multi-line string ` a \n b \r\n c ` by new line character `\n`
|
' a \n b \r\n c '.split('\n')
|
[
"python.library.stdtypes#str.split"
] |
' a \n b \r\n c '.split('VAR_STR')
|
conala
|
13954222-2
|
concatenate elements of list `b` by a colon ":"
|
""":""".join(str(x) for x in b)
|
[
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
"""VAR_STR""".join(str(x) for x in VAR_STR)
|
conala
|
13567345-100
|
Calculate sum over all rows of 2D numpy array
|
a.sum(axis=1)
|
[
"python.library.functions#sum"
] |
a.sum(axis=1)
|
conala
|
13550423-44
|
concatenate items of list `l` with a space ' '
|
print(' '.join(map(str, l)))
|
[
"python.library.functions#map",
"python.library.stdtypes#str.join"
] |
print(' '.join(map(str, VAR_STR)))
|
conala
|
25651990-82
|
run script 'hello.py' with argument 'htmlfilename.htm' on terminal using python executable
|
subprocess.call(['python.exe', 'hello.py', 'htmlfilename.htm'])
|
[
"python.library.subprocess#subprocess.call"
] |
subprocess.call(['python.exe', 'VAR_STR', 'VAR_STR'])
|
conala
|
698223-79
|
How can I parse a time string containing milliseconds in it with python?
|
time.strptime('30/03/09 16:31:32.123', '%d/%m/%y %H:%M:%S.%f')
|
[
"python.library.time#time.strptime"
] |
time.strptime('30/03/09 16:31:32.123', '%d/%m/%y %H:%M:%S.%f')
|
conala
|
6633523-61
|
convert a string `my_string` with dot and comma into a float number `my_float`
|
my_float = float(my_string.replace(',', ''))
|
[
"python.library.functions#float",
"python.library.stdtypes#str.replace"
] |
VAR_STR = float(VAR_STR.replace(',', ''))
|
conala
|
6633523-78
|
convert a string `123,456.908` with dot and comma into a floating number
|
float('123,456.908'.replace(',', ''))
|
[
"python.library.functions#float",
"python.library.stdtypes#str.replace"
] |
float('VAR_STR'.replace(',', ''))
|
conala
|
3108285-59
|
set pythonpath in python script.
|
sys.path.append('/path/to/whatever')
|
[
"numpy.reference.generated.numpy.append"
] |
sys.path.append('/path/to/whatever')
|
conala
|
2195340-19
|
split string 'Words, words, words.' using a regex '(\\W+)'
|
re.split('(\\W+)', 'Words, words, words.')
|
[
"python.library.re#re.split"
] |
re.split('VAR_STR', 'VAR_STR')
|
conala
|
17977584-11
|
open a file `Output.txt` in append mode
|
file = open('Output.txt', 'a')
|
[
"python.library.urllib.request#open"
] |
file = open('VAR_STR', 'a')
|
conala
|
15405636-62
|
argparse add argument with flag '--version' and version action of '%(prog)s 2.0' to parser `parser`
|
parser.add_argument('--version', action='version', version='%(prog)s 2.0')
|
[
"python.library.argparse#argparse.ArgumentParser.add_argument"
] |
VAR_STR.add_argument('VAR_STR', action='version', version='VAR_STR')
|
conala
|
17665809-31
|
remove key 'c' from dictionary `d`
|
{i: d[i] for i in d if i != 'c'}
|
[] |
{i: VAR_STR[i] for i in VAR_STR if i != 'VAR_STR'}
|
conala
|
41861705-8
|
Create new DataFrame object by merging columns "key" of dataframes `split_df` and `csv_df` and rename the columns from dataframes `split_df` and `csv_df` with suffix `_left` and `_right` respectively
|
pd.merge(split_df, csv_df, on=['key'], suffixes=('_left', '_right'))
|
[
"pandas.reference.api.pandas.merge"
] |
pd.merge(VAR_STR, VAR_STR, on=['VAR_STR'], suffixes=('VAR_STR', 'VAR_STR'))
|
conala
|
10697757-85
|
Split a string `s` by space with `4` splits
|
s.split(' ', 4)
|
[
"python.library.stdtypes#str.split"
] |
VAR_STR.split(' ', 4)
|
conala
|
5404068-69
|
read keyboard-input
|
input('Enter your input:')
|
[
"python.library.functions#input"
] |
input('Enter your input:')
|
conala
|
16344756-59
|
enable debug mode on Flask application `app`
|
app.run(debug=True)
|
[
"python.library.pdb#pdb.run"
] |
VAR_STR.run(debug=True)
|
conala
|
40133826-8
|
python save list `mylist` to file object 'save.txt'
|
pickle.dump(mylist, open('save.txt', 'wb'))
|
[
"python.library.pickle#pickle.dump",
"python.library.urllib.request#open"
] |
pickle.dump(VAR_STR, open('VAR_STR', 'wb'))
|
conala
|
2173087-86
|
Create 3d array of zeroes of size `(3,3,3)`
|
numpy.zeros((3, 3, 3))
|
[
"numpy.reference.generated.numpy.zeros"
] |
numpy.zeros((3, 3, 3))
|
conala
|
6266727-11
|
cut off the last word of a sentence `content`
|
""" """.join(content.split(' ')[:-1])
|
[
"python.library.stdtypes#str.join",
"python.library.stdtypes#str.split"
] |
""" """.join(VAR_STR.split(' ')[:-1])
|
conala
|
30385151-65
|
convert scalar `x` to array
|
x = np.asarray(x).reshape(1, -1)[(0), :]
|
[
"numpy.reference.generated.numpy.asarray",
"numpy.reference.generated.numpy.reshape"
] |
VAR_STR = np.asarray(VAR_STR).reshape(1, -1)[(0), :]
|
conala
|
15856127-74
|
sum all elements of nested list `L`
|
sum(sum(i) if isinstance(i, list) else i for i in L)
|
[
"python.library.functions#sum",
"python.library.functions#isinstance"
] |
sum(sum(i) if isinstance(i, list) else i for i in VAR_STR)
|
conala
|
5010536-34
|
Multiple each value by `2` for all keys in a dictionary `my_dict`
|
my_dict.update((x, y * 2) for x, y in list(my_dict.items()))
|
[
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
VAR_STR.update((x, y * 2) for x, y in list(VAR_STR.items()))
|
conala
|
13745648-71
|
running bash script 'sleep.sh'
|
subprocess.call('sleep.sh', shell=True)
|
[
"python.library.subprocess#subprocess.call"
] |
subprocess.call('VAR_STR', shell=True)
|
conala
|
44778-8
|
Join elements of list `l` with a comma `,`
|
""",""".join(l)
|
[
"python.library.stdtypes#str.join"
] |
"""VAR_STR""".join(VAR_STR)
|
conala
|
44778-82
|
make a comma-separated string from a list `myList`
|
myList = ','.join(map(str, myList))
|
[
"python.library.functions#map",
"python.library.stdtypes#str.join"
] |
VAR_STR = ','.join(map(str, VAR_STR))
|
conala
|
18454570-61
|
remove substring 'bag,' from a string 'lamp, bag, mirror'
|
print('lamp, bag, mirror'.replace('bag,', ''))
|
[
"python.library.stdtypes#str.replace"
] |
print('VAR_STR'.replace('VAR_STR', ''))
|
conala
|
4357787-45
|
Reverse the order of words, delimited by `.`, in string `s`
|
""".""".join(s.split('.')[::-1])
|
[
"python.library.stdtypes#str.join",
"python.library.stdtypes#str.split"
] |
"""VAR_STR""".join(VAR_STR.split('VAR_STR')[::-1])
|
conala
|
21787496-34
|
convert epoch time represented as milliseconds `s` to string using format '%Y-%m-%d %H:%M:%S.%f'
|
datetime.datetime.fromtimestamp(s).strftime('%Y-%m-%d %H:%M:%S.%f')
|
[
"python.library.datetime#datetime.datetime.fromtimestamp",
"python.library.datetime#datetime.datetime.strftime"
] |
datetime.datetime.fromtimestamp(VAR_STR).strftime('VAR_STR')
|
conala
|
21787496-31
|
parse milliseconds epoch time '1236472051807' to format '%Y-%m-%d %H:%M:%S'
|
time.strftime('%Y-%m-%d %H:%M:%S', time.gmtime(1236472051807 / 1000.0))
|
[
"python.library.time#time.gmtime",
"python.library.time#time.strftime"
] |
time.strftime('VAR_STR', time.gmtime(1236472051807 / 1000.0))
|
conala
|
15352457-25
|
sum elements at index `column` of each list in list `data`
|
print(sum(row[column] for row in data))
|
[
"python.library.functions#sum"
] |
print(sum(row[VAR_STR] for row in VAR_STR))
|
conala
|
15352457-58
|
sum columns of a list `array`
|
[sum(row[i] for row in array) for i in range(len(array[0]))]
|
[
"python.library.functions#len",
"python.library.functions#range",
"python.library.functions#sum"
] |
[sum(row[i] for row in VAR_STR) for i in range(len(VAR_STR[0]))]
|
conala
|
11533274-85
|
combine list of dictionaries `dicts` with the same keys in each list to a single dictionary
|
dict((k, [d[k] for d in dicts]) for k in dicts[0])
|
[
"python.library.stdtypes#dict"
] |
dict((k, [d[k] for d in VAR_STR]) for k in VAR_STR[0])
|
conala
|
11533274-2
|
Merge a nested dictionary `dicts` into a flat dictionary by concatenating nested values with the same key `k`
|
{k: [d[k] for d in dicts] for k in dicts[0]}
|
[] |
{VAR_STR: [d[VAR_STR] for d in VAR_STR] for VAR_STR in VAR_STR[0]}
|
conala
|
14026704-65
|
How do I get the url parameter in a Flask view
|
request.args['myParam']
|
[] |
request.args['myParam']
|
conala
|
2354166-0
|
Insert directory 'apps' into directory `__file__`
|
sys.path.insert(1, os.path.join(os.path.dirname(__file__), 'apps'))
|
[
"python.library.os.path#os.path.dirname",
"python.library.os.path#os.path.join"
] |
sys.path.insert(1, os.path.join(os.path.dirname(VAR_STR), 'VAR_STR'))
|
conala
|
2354166-42
|
modify sys.path for python module `subdir`
|
sys.path.append(os.path.join(os.path.dirname(__file__), 'subdir'))
|
[
"python.library.os.path#os.path.dirname",
"python.library.os.path#os.path.join"
] |
sys.path.append(os.path.join(os.path.dirname(__file__), 'VAR_STR'))
|
conala
|
20211942-18
|
Insert a 'None' value into a SQLite3 table.
|
db.execute("INSERT INTO present VALUES('test2', ?, 10)", (None,))
|
[
"python.library.msilib#msilib.View.Execute"
] |
db.execute("INSERT INTO present VALUES('test2', ?, 10)", (None,))
|
conala
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.