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 |
---|---|---|---|---|---|
38704545-19
|
binarize the values in columns of list `order` in a pandas data frame
|
pd.concat([df, pd.get_dummies(df, '', '').astype(int)], axis=1)[order]
|
[
"pandas.reference.api.pandas.get_dummies",
"pandas.reference.api.pandas.concat",
"pandas.reference.api.pandas.index.astype"
] |
pd.concat([df, pd.get_dummies(df, '', '').astype(int)], axis=1)[VAR_STR]
|
conala
|
4363072-10
|
Parse string '21/11/06 16:30' according to format '%d/%m/%y %H:%M'
|
datetime.strptime('21/11/06 16:30', '%d/%m/%y %H:%M')
|
[
"python.library.datetime#datetime.datetime.strptime"
] |
datetime.strptime('VAR_STR', 'VAR_STR')
|
conala
|
6018916-82
|
Get the value with the maximum length in each column in array `foo`
|
[max(len(str(x)) for x in line) for line in zip(*foo)]
|
[
"python.library.functions#zip",
"python.library.functions#len",
"python.library.functions#max",
"python.library.stdtypes#str"
] |
[max(len(str(x)) for x in line) for line in zip(*VAR_STR)]
|
conala
|
6633678-69
|
finding words in string `s` after keyword 'name'
|
re.search('name (.*)', s)
|
[
"python.library.re#re.search"
] |
re.search('name (.*)', VAR_STR)
|
conala
|
38147447-67
|
set data in column 'value' of dataframe `df` equal to first element of each list
|
df['value'] = df['value'].str[0]
|
[] |
VAR_STR['VAR_STR'] = VAR_STR['VAR_STR'].str[0]
|
conala
|
38147447-11
|
get element at index 0 of each list in column 'value' of dataframe `df`
|
df['value'] = df['value'].str.get(0)
|
[
"pandas.reference.api.pandas.series.str.get"
] |
VAR_STR['VAR_STR'] = VAR_STR['VAR_STR'].str.get(0)
|
conala
|
38147447-21
|
remove square bracket '[]' from pandas dataframe `df` column 'value'
|
df['value'] = df['value'].str.strip('[]')
|
[
"python.library.stdtypes#str.strip"
] |
VAR_STR['VAR_STR'] = VAR_STR['VAR_STR'].str.strip('VAR_STR')
|
conala
|
18649884-25
|
Get a list from two strings `12345` and `ab` with values as each character concatenated
|
[(x + y) for x in '12345' for y in 'ab']
|
[] |
[(x + y) for x in 'VAR_STR' for y in 'VAR_STR']
|
conala
|
4690094-53
|
sort keys of dictionary 'd' based on their values
|
sorted(d, key=lambda k: d[k][1])
|
[
"python.library.functions#sorted"
] |
sorted(VAR_STR, key=lambda k: VAR_STR[k][1])
|
conala
|
16537636-23
|
sort list `student_tuples` by second element of each tuple in ascending and third element of each tuple in descending
|
print(sorted(student_tuples, key=lambda t: (-t[2], t[0])))
|
[
"python.library.functions#sorted"
] |
print(sorted(VAR_STR, key=lambda t: (-t[2], t[0])))
|
conala
|
18022241-97
|
convert a list of lists `list_of_lists` into a list of strings keeping empty sub-lists as empty string ''
|
[''.join(l) for l in list_of_lists]
|
[
"python.library.stdtypes#str.join"
] |
['VAR_STR'.join(l) for l in VAR_STR]
|
conala
|
35097130-6
|
sort objects in `Articles` in descending order of counts of `likes`
|
Article.objects.annotate(like_count=Count('likes')).order_by('-like_count')
|
[
"python.library.stdtypes#str.count",
"matplotlib._as_gen.matplotlib.pyplot.annotate"
] |
Article.objects.annotate(like_count=Count('VAR_STR')).order_by('-like_count')
|
conala
|
8244915-81
|
divide each element in list `myList` by integer `myInt`
|
myList[:] = [(x / myInt) for x in myList]
|
[] |
VAR_STR[:] = [(x / VAR_STR) for x in VAR_STR]
|
conala
|
20677660-40
|
format string with dict `{'5': 'you'}` with integer keys
|
'hello there %(5)s' % {'5': 'you'}
|
[] |
'hello there %(5)s' % {VAR_STR}
|
conala
|
13252333-55
|
Check if all elements in list `lst` are tupples of long and int
|
all(isinstance(x, int) for x in lst)
|
[
"python.library.functions#isinstance",
"python.library.functions#all"
] |
all(isinstance(x, int) for x in VAR_STR)
|
conala
|
13252333-39
|
check if all elements in a list 'lst' are the same type 'int'
|
all(isinstance(x, int) for x in lst)
|
[
"python.library.functions#isinstance",
"python.library.functions#all"
] |
all(isinstance(x, VAR_STR) for x in VAR_STR)
|
conala
|
7742752-61
|
sort a dictionary `y` by value then by key
|
sorted(list(y.items()), key=lambda x: (x[1], x[0]), 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], x[0]), reverse=True)
|
conala
|
36454494-31
|
get mean of columns `2, 5, 6, 7, 8` for all rows in dataframe `df`
|
df.iloc[:, ([2, 5, 6, 7, 8])].mean(axis=1)
|
[
"pandas.reference.api.pandas.dataframe.mean",
"pandas.reference.api.pandas.dataframe.loc"
] |
VAR_STR.iloc[:, ([2, 5, 6, 7, 8])].mean(axis=1)
|
conala
|
12905999-80
|
Create a key `key` if it does not exist in dict `dic` and append element `value` to value.
|
dic.setdefault(key, []).append(value)
|
[
"python.library.stdtypes#dict.setdefault",
"numpy.reference.generated.numpy.append"
] |
VAR_STR.setdefault(VAR_STR, []).append(VAR_STR)
|
conala
|
31676133-11
|
Convert each list in list `main_list` into a tuple
|
map(list, zip(*main_list))
|
[
"python.library.functions#zip",
"python.library.functions#map"
] |
map(list, zip(*VAR_STR))
|
conala
|
15769246-18
|
print list of items `myList`
|
print('\n'.join(str(p) for p in myList))
|
[
"python.library.stdtypes#str",
"python.library.stdtypes#str.join"
] |
print('\n'.join(str(p) for p in VAR_STR))
|
conala
|
13079852-67
|
stack two dataframes next to each other in pandas
|
pd.concat([GOOG, AAPL], keys=['GOOG', 'AAPL'], axis=1)
|
[
"pandas.reference.api.pandas.concat"
] |
pd.concat([GOOG, AAPL], keys=['GOOG', 'AAPL'], axis=1)
|
conala
|
37855490-47
|
add dictionary `{'class': {'section': 5}}` to key 'Test' of dictionary `dic`
|
dic['Test'].update({'class': {'section': 5}})
|
[
"python.library.stdtypes#dict.update"
] |
VAR_STR['VAR_STR'].update({VAR_STR})
|
conala
|
6323296-29
|
replace everything that is not an alphabet or a digit with '' in 's'.
|
re.sub('[\\W_]+', '', s)
|
[
"python.library.re#re.sub"
] |
re.sub('[\\W_]+', 'VAR_STR', VAR_STR)
|
conala
|
15571267-95
|
set size of `figure` to landscape A4 i.e. `11.69, 8.27` inches
|
figure(figsize=(11.69, 8.27))
|
[
"matplotlib.figure_api#matplotlib.figure.Figure"
] |
VAR_STR(figsize=(11.69, 8.27))
|
conala
|
23422542-68
|
django jinja slice list `mylist` by '3:8'
|
{{(mylist | slice): '3:8'}}
|
[] |
{{(VAR_STR | slice): 'VAR_STR'}}
|
conala
|
10562778-75
|
replace character 'a' with character 'e' and character 's' with character '3' in file `contents`
|
newcontents = contents.replace('a', 'e').replace('s', '3')
|
[
"python.library.stdtypes#str.replace"
] |
newcontents = VAR_STR.replace('VAR_STR', 'VAR_STR').replace('VAR_STR', 'VAR_STR')
|
conala
|
6612769-92
|
unpack keys and values of a dictionary `d` into two lists
|
keys, values = zip(*list(d.items()))
|
[
"python.library.functions#zip",
"python.library.functions#list",
"python.library.stdtypes#dict.items"
] |
keys, values = zip(*list(VAR_STR.items()))
|
conala
|
4644025-48
|
Sort a list 'lst' in descending order.
|
sorted(lst, reverse=True)
|
[
"python.library.functions#sorted"
] |
sorted(VAR_STR, reverse=True)
|
conala
|
28253102-16
|
Get the dot product of matrix `[1,0,0,1,0,0]` and matrix `[[0,1],[1,1],[1,0],[1,0],[1,1],[0,1]]`
|
np.dot([1, 0, 0, 1, 0, 0], [[0, 1], [1, 1], [1, 0], [1, 0], [1, 1], [0, 1]])
|
[
"numpy.reference.generated.numpy.dot"
] |
np.dot([1, 0, 0, 1, 0, 0], [[0, 1], [1, 1], [1, 0], [1, 0], [1, 1], [0, 1]])
|
conala
|
30651487-40
|
get a random item from list `choices`
|
random_choice = random.choice(choices)
|
[
"python.library.random#random.choice"
] |
random_choice = random.choice(VAR_STR)
|
conala
|
4901483-87
|
apply jinja2 filters `forceescape` and `linebreaks` on variable `my_variable`
|
{{my_variable | forceescape | linebreaks}}
|
[] |
{{VAR_STR | VAR_STR | VAR_STR}}
|
conala
|
17888152-82
|
parse string `s` to int when string contains a number
|
int(''.join(c for c in s if c.isdigit()))
|
[
"python.library.functions#int",
"python.library.stdtypes#str.isdigit",
"python.library.stdtypes#str.join"
] |
int(''.join(c for c in VAR_STR if c.isdigit()))
|
conala
|
16138015-5
|
check if any elements in one list `list1` are in another list `list2`
|
len(set(list1).intersection(list2)) > 0
|
[
"python.library.functions#len",
"python.library.stdtypes#set",
"python.library.stdtypes#frozenset.intersection"
] |
len(set(VAR_STR).intersection(VAR_STR)) > 0
|
conala
|
11354544-77
|
strip and split each line `line` on white spaces
|
line.strip().split(' ')
|
[
"python.library.stdtypes#str.strip",
"python.library.stdtypes#str.split"
] |
VAR_STR.strip().split(' ')
|
conala
|
8215686-82
|
Insert records in bulk from "table1" of "master" DB to "table1" of sqlite3 `cursor` object
|
cursor.execute('INSERT OR REPLACE INTO master.table1 SELECT * FROM table1')
|
[
"python.library.sqlite3#sqlite3.Cursor.execute"
] |
VAR_STR.execute('INSERT OR REPLACE INTO master.table1 SELECT * FROM table1')
|
conala
|
17331290-99
|
check if string `str` is palindrome
|
str(n) == str(n)[::-1]
|
[
"python.library.stdtypes#str"
] |
VAR_STR(n) == VAR_STR(n)[::-1]
|
conala
|
7458689-47
|
Remove duplicates elements from list `sequences` and sort it in ascending order
|
sorted(set(itertools.chain.from_iterable(sequences)))
|
[
"python.library.itertools#itertools.chain.from_iterable",
"python.library.functions#sorted",
"python.library.stdtypes#set"
] |
sorted(set(itertools.chain.from_iterable(VAR_STR)))
|
conala
|
8901996-28
|
decode utf-8 code `x` into a raw unicode literal
|
print(str(x).decode('raw_unicode_escape'))
|
[
"python.library.stdtypes#str",
"pandas.reference.api.pandas.series.str.decode"
] |
print(str(VAR_STR).decode('raw_unicode_escape'))
|
conala
|
28767642-83
|
Compare if each value in list `a` is less than respective index value in list `b`
|
all(i < j for i, j in zip(a, b))
|
[
"python.library.functions#zip",
"python.library.functions#all"
] |
all(i < j for i, j in zip(VAR_STR, VAR_STR))
|
conala
|
575819-43
|
create a list containing keys of dictionary `d` and sort it alphabetically
|
sorted(d, key=d.get)
|
[
"python.library.functions#sorted"
] |
sorted(VAR_STR, key=VAR_STR.get)
|
conala
|
577234-9
|
extend dictionary `a` with key/value pairs of dictionary `b`
|
a.update(b)
|
[
"python.library.stdtypes#dict.update"
] |
VAR_STR.update(VAR_STR)
|
conala
|
3559559-67
|
Delete character "M" from a string `s` using python
|
s = s.replace('M', '')
|
[
"python.library.stdtypes#str.replace"
] |
VAR_STR = VAR_STR.replace('VAR_STR', '')
|
conala
|
3559559-70
|
How to delete a character from a string using python?
|
newstr = oldstr.replace('M', '')
|
[
"python.library.stdtypes#str.replace"
] |
newstr = oldstr.replace('M', '')
|
conala
|
22904654-17
|
save xlsxwriter file in 'app/smth1/smth2/Expenses01.xlsx' path and assign to variable `workbook`
|
workbook = xlsxwriter.Workbook('app/smth1/smth2/Expenses01.xlsx')
|
[] |
VAR_STR = xlsxwriter.Workbook('VAR_STR')
|
conala
|
22904654-42
|
save xlsxwriter file to 'C:/Users/Steven/Documents/demo.xlsx' path
|
workbook = xlsxwriter.Workbook('C:/Users/Steven/Documents/demo.xlsx')
|
[] |
workbook = xlsxwriter.Workbook('VAR_STR')
|
conala
|
4230000-64
|
creating a 5x6 matrix filled with `None` and save it as `x`
|
x = [[None for _ in range(5)] for _ in range(6)]
|
[
"python.library.functions#range"
] |
VAR_STR = [[None for _ in range(5)] for _ in range(6)]
|
conala
|
17484631-67
|
insert ' ' between every three digit before '.' and replace ',' with '.' in 12345678.46
|
format(12345678.46, ',').replace(',', ' ').replace('.', ',')
|
[
"python.library.functions#format",
"python.library.stdtypes#str.replace"
] |
format(12345678.46, 'VAR_STR').replace('VAR_STR', ' ').replace('VAR_STR', 'VAR_STR')
|
conala
|
23823206-75
|
upload uploaded file from path '/upload' to Google cloud storage 'my_bucket' bucket
|
upload_url = blobstore.create_upload_url('/upload', gs_bucket_name='my_bucket')
|
[] |
upload_url = blobstore.create_upload_url('VAR_STR', gs_bucket_name='VAR_STR')
|
conala
|
1908741-46
|
Group the values from django model `Article` with group by value `pub_date` and annotate by `title`
|
Article.objects.values('pub_date').annotate(article_count=Count('title'))
|
[
"python.library.stdtypes#dict.values",
"python.library.stdtypes#str.count"
] |
VAR_STR.objects.values('VAR_STR').annotate(article_count=Count('VAR_STR'))
|
conala
|
16228248-100
|
Retrieve list of values from dictionary 'd'
|
list(d.values())
|
[
"python.library.functions#list",
"python.library.stdtypes#dict.values"
] |
list(VAR_STR.values())
|
conala
|
7522533-5
|
Convert a string into a list
|
list('hello')
|
[
"python.library.functions#list"
] |
list('hello')
|
conala
|
4843173-34
|
check if type of variable `s` is a string
|
isinstance(s, str)
|
[
"python.library.functions#isinstance"
] |
isinstance(VAR_STR, str)
|
conala
|
4843173-74
|
check if type of a variable `s` is string
|
isinstance(s, str)
|
[
"python.library.functions#isinstance"
] |
isinstance(VAR_STR, str)
|
conala
|
1093322-99
|
check python version
|
sys.version
|
[] |
sys.version
|
conala
|
1093322-38
|
check python version
|
sys.version_info
|
[] |
sys.version_info
|
conala
|
8916302-70
|
select all rows from pandas DataFrame 'df' where the value in column 'A' is greater than 1 or less than -1 in column 'B'.
|
df[(df['A'] > 1) | (df['B'] < -1)]
|
[] |
VAR_STR[(VAR_STR['VAR_STR'] > 1) | (VAR_STR['VAR_STR'] < -1)]
|
conala
|
14859458-75
|
check if all values in the columns of a numpy matrix `a` are same
|
np.all(a == a[(0), :], axis=0)
|
[
"numpy.reference.generated.numpy.all"
] |
np.all(VAR_STR == VAR_STR[(0), :], axis=0)
|
conala
|
2951701-85
|
replace `0` with `2` in the list `[0, 1, 0, 3]`
|
[(a if a else 2) for a in [0, 1, 0, 3]]
|
[] |
[(a if a else 2) for a in [VAR_STR]]
|
conala
|
22712292-60
|
Save array at index 0, index 1 and index 8 of array `np` to tmp file `tmp`
|
np.savez(tmp, *[getarray[0], getarray[1], getarray[8]])
|
[
"numpy.reference.generated.numpy.savez"
] |
VAR_STR.savez(VAR_STR, *[getarray[0], getarray[1], getarray[8]])
|
conala
|
930397-17
|
Getting the last element of list `some_list`
|
some_list[(-1)]
|
[] |
VAR_STR[-1]
|
conala
|
930397-2
|
Getting the second to last element of list `some_list`
|
some_list[(-2)]
|
[] |
VAR_STR[-2]
|
conala
|
930397-12
|
gets the `n` th-to-last element in list `some_list`
|
some_list[(- n)]
|
[] |
VAR_STR[-VAR_STR]
|
conala
|
930397-75
|
get the last element in list `alist`
|
alist[(-1)]
|
[] |
VAR_STR[-1]
|
conala
|
930397-92
|
get the last element in list `astr`
|
astr[(-1)]
|
[] |
VAR_STR[-1]
|
conala
|
30747705-14
|
Produce a string that is suitable as Unicode literal from string 'M\\N{AMPERSAND}M\\N{APOSTROPHE}s'
|
'M\\N{AMPERSAND}M\\N{APOSTROPHE}s'.encode().decode('unicode-escape')
|
[
"python.library.stdtypes#str.encode",
"python.library.stdtypes#bytearray.decode"
] |
"""VAR_STR""".encode().decode('unicode-escape')
|
conala
|
30747705-97
|
Parse a unicode string `M\\N{AMPERSAND}M\\N{APOSTROPHE}s`
|
'M\\N{AMPERSAND}M\\N{APOSTROPHE}s'.decode('unicode-escape')
|
[
"python.library.stdtypes#bytearray.decode"
] |
"""VAR_STR""".decode('unicode-escape')
|
conala
|
11692613-80
|
sum values in list of dictionaries `example_list` with key 'gold'
|
sum(item['gold'] for item in example_list)
|
[
"python.library.functions#sum"
] |
sum(item['VAR_STR'] for item in VAR_STR)
|
conala
|
11692613-33
|
get a sum of all values from key `gold` in a list of dictionary `example_list`
|
sum([item['gold'] for item in example_list])
|
[
"python.library.functions#sum"
] |
sum([item['VAR_STR'] for item in VAR_STR])
|
conala
|
11692613-31
|
Get all the values in key `gold` summed from a list of dictionary `myLIst`
|
sum(item['gold'] for item in myLIst)
|
[
"python.library.functions#sum"
] |
sum(item['VAR_STR'] for item in VAR_STR)
|
conala
|
17097236-34
|
replace '-' in pandas dataframe `df` with `np.nan`
|
df.replace('-', np.nan)
|
[
"pandas.reference.api.pandas.dataframe.replace"
] |
VAR_STR.replace('VAR_STR', np.nan)
|
conala
|
5255657-81
|
disable logging while running unit tests in python django
|
logging.disable(logging.CRITICAL)
|
[
"python.library.logging#logging.disable"
] |
logging.disable(logging.CRITICAL)
|
conala
|
18524112-81
|
normalize the dataframe `df` along the rows
|
np.sqrt(np.square(df).sum(axis=1))
|
[
"numpy.reference.generated.numpy.square",
"numpy.reference.generated.numpy.sqrt",
"python.library.functions#sum"
] |
np.sqrt(np.square(VAR_STR).sum(axis=1))
|
conala
|
7371935-12
|
Sort a string `s` in lexicographic order
|
sorted(s, key=str.upper)
|
[
"python.library.functions#sorted"
] |
sorted(VAR_STR, key=str.upper)
|
conala
|
7371935-89
|
sort string `s` in lexicographic order
|
sorted(sorted(s), key=str.upper)
|
[
"python.library.functions#sorted"
] |
sorted(sorted(VAR_STR), key=str.upper)
|
conala
|
7371935-26
|
get a sorted list of the characters of string `s` in lexicographic order, with lowercase letters first
|
sorted(s, key=str.lower)
|
[
"python.library.functions#sorted"
] |
sorted(VAR_STR, key=str.lower)
|
conala
|
15666169-3
|
insert a new field 'geolocCountry' on an existing document 'b' using pymongo
|
db.Doc.update({'_id': b['_id']}, {'$set': {'geolocCountry': myGeolocCountry}})
|
[
"python.library.turtle#turtle.update"
] |
db.Doc.update({'_id': VAR_STR['_id']}, {'$set': {'VAR_STR': myGeolocCountry}})
|
conala
|
2527892-27
|
pars a string 'http://example.org/#comments' to extract hashtags into an array
|
re.findall('#(\\w+)', 'http://example.org/#comments')
|
[
"python.library.re#re.findall"
] |
re.findall('#(\\w+)', 'VAR_STR')
|
conala
|
34438901-83
|
assign the index of the last occurence of `x` in list `s` to the variable `last`
|
last = len(s) - s[::-1].index(x) - 1
|
[
"python.library.functions#len",
"python.library.stdtypes#str.index"
] |
VAR_STR = len(VAR_STR) - VAR_STR[::-1].index(VAR_STR) - 1
|
conala
|
29530232-39
|
check if datafram `df` has any NaN vlaues
|
df.isnull().values.any()
|
[
"pandas.reference.api.pandas.dataframe.isnull",
"pandas.reference.api.pandas.dataframe.any"
] |
VAR_STR.isnull().values.any()
|
conala
|
9497290-5
|
sum all elements of two-dimensions list `[[1, 2, 3, 4], [2, 4, 5, 6]]]`
|
sum([sum(x) for x in [[1, 2, 3, 4], [2, 4, 5, 6]]])
|
[
"python.library.functions#sum"
] |
sum([sum(x) for x in [VAR_STR])
|
conala
|
29035168-66
|
Print a dictionary `{'user': {'name': 'Markus'}}` with string formatting
|
"""Hello {user[name]}""".format(**{'user': {'name': 'Markus'}})
|
[
"python.library.functions#format"
] |
"""Hello {user[name]}""".format(**{VAR_STR})
|
conala
|
4112265-53
|
zip lists `[1, 2], [3, 4], [5, 6]` in a list
|
zip(*[[1, 2], [3, 4], [5, 6]])
|
[
"python.library.functions#zip"
] |
zip(*[[VAR_STR]])
|
conala
|
4112265-19
|
zip lists in a list [[1, 2], [3, 4], [5, 6]]
|
zip(*[[1, 2], [3, 4], [5, 6]])
|
[
"python.library.functions#zip"
] |
zip(*[[1, 2], [3, 4], [5, 6]])
|
conala
|
21188504-9
|
Add 100 to each element of column "x" in dataframe `a`
|
a['x'].apply(lambda x, y: x + y, args=(100,))
|
[
"pandas.reference.api.pandas.dataframe.apply"
] |
VAR_STR['VAR_STR'].apply(lambda VAR_STR, y: VAR_STR + y, args=(100,))
|
conala
|
1397827-4
|
get a list of of elements resulting from splitting user input by commas and stripping white space from each resulting string `s`
|
[s.strip() for s in input().split(',')]
|
[
"python.library.functions#input",
"python.library.stdtypes#str.strip",
"python.library.stdtypes#str.split"
] |
[VAR_STR.strip() for VAR_STR in input().split(',')]
|
conala
|
4267019-49
|
encode `u'X\xc3\xbcY\xc3\x9f'` as unicode and decode with utf-8
|
'X\xc3\xbcY\xc3\x9f'.encode('raw_unicode_escape').decode('utf-8')
|
[
"python.library.stdtypes#str.encode",
"python.library.stdtypes#bytearray.decode"
] |
"""XüYÃ""".encode('raw_unicode_escape').decode('utf-8')
|
conala
|
4830535-51
|
Jinja parse datetime object `car.date_of_manufacture` to use format pattern `datetime`
|
{{car.date_of_manufacture | datetime}}
|
[] |
{{car.date_of_manufacture | VAR_STR}}
|
conala
|
4830535-54
|
Get the date object `date_of_manufacture` of object `car` in string format '%Y-%m-%d'
|
{{car.date_of_manufacture.strftime('%Y-%m-%d')}}
|
[
"python.library.time#time.strftime"
] |
{{VAR_STR.VAR_STR.strftime('VAR_STR')}}
|
conala
|
4170655-54
|
convert a DateTime string back to a DateTime object of format '%Y-%m-%d %H:%M:%S.%f'
|
datetime.strptime('2010-11-13 10:33:54.227806', '%Y-%m-%d %H:%M:%S.%f')
|
[
"python.library.datetime#datetime.datetime.strptime"
] |
datetime.strptime('2010-11-13 10:33:54.227806', 'VAR_STR')
|
conala
|
34962104-52
|
Pandas: How can I use the apply() function for a single column?
|
df['a'] = df['a'].apply(lambda x: x + 1)
|
[
"pandas.reference.api.pandas.series.apply"
] |
df['a'] = df['a'].apply(lambda x: x + 1)
|
conala
|
11479392-70
|
Get a list `myList` from 1 to 10
|
myList = [i for i in range(10)]
|
[
"python.library.functions#range"
] |
VAR_STR = [i for i in range(10)]
|
conala
|
9039961-94
|
find the mean of elements in list `l`
|
sum(l) / float(len(l))
|
[
"python.library.functions#len",
"python.library.functions#float",
"python.library.functions#sum"
] |
sum(VAR_STR) / float(len(VAR_STR))
|
conala
|
34410358-72
|
split string 'happy_hats_for_cats' using string '_for_'
|
re.split('_for_', 'happy_hats_for_cats')
|
[
"python.library.re#re.split"
] |
re.split('VAR_STR', 'VAR_STR')
|
conala
|
34410358-16
|
Split string 'sad_pandas_and_happy_cats_for_people' based on string 'and', 'or' or 'for'
|
re.split('_(?:for|or|and)_', 'sad_pandas_and_happy_cats_for_people')
|
[
"python.library.re#re.split"
] |
re.split('_(?:for|or|and)_', 'VAR_STR')
|
conala
|
34410358-18
|
Split a string `l` by multiple words `for` or `or` or `and`
|
[re.split('_(?:f?or|and)_', s) for s in l]
|
[
"python.library.re#re.split"
] |
[re.split('_(?:f?or|and)_', s) for s in VAR_STR]
|
conala
|
647515-26
|
get the path of Python executable under windows
|
os.path.dirname(sys.executable)
|
[
"python.library.os.path#os.path.dirname"
] |
os.path.dirname(sys.executable)
|
conala
|
18391059-36
|
how to format a list of arguments `my_args` into a string
|
'Hello %s' % ', '.join(my_args)
|
[
"python.library.stdtypes#str.join"
] |
'Hello %s' % ', '.join(VAR_STR)
|
conala
|
2990121-19
|
loop through 0 to 10 with step 2
|
for i in range(0, 10, 2):
pass
|
[
"python.library.functions#range"
] |
for i in range(0, 10, 2):
pass
|
conala
|
2990121-50
|
loop through `mylist` with step 2
|
for i in mylist[::2]:
pass
|
[] |
for i in VAR_STR[::2]:
pass
|
conala
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.