message_type
stringclasses 2
values | message
stringlengths 2
232
⌀ | message_id
int64 0
1
| conversation_id
int64 0
2.38k
|
---|---|---|---|
instruction
|
sort a list of tuples `a` by the sum of second and third element of each tuple
| 0 | 750 |
output
|
sorted(a, key=lambda x: (sum(x[1:3]), x[0]), reverse=True)
| 1 | 750 |
instruction
|
sorting a list of tuples `lst` by the sum of the second elements onwards, and third element of the tuple
| 0 | 751 |
output
|
sorted(lst, key=lambda x: (sum(x[1:]), x[0]))
| 1 | 751 |
instruction
|
sort the list of tuples `lst` by the sum of every value except the first and by the first value in reverse order
| 0 | 752 |
output
|
sorted(lst, key=lambda x: (sum(x[1:]), x[0]), reverse=True)
| 1 | 752 |
instruction
|
add header 'WWWAuthenticate' in a flask app with value 'Basic realm="test"'
| 0 | 753 |
output
|
response.headers['WWW-Authenticate'] = 'Basic realm="test"'
| 1 | 753 |
instruction
|
clear session key 'mykey'
| 0 | 754 |
output
|
del request.session['mykey']
| 1 | 754 |
instruction
|
convert date string '24052010' to date object in format '%d%m%Y'
| 0 | 755 |
output
|
datetime.datetime.strptime('24052010', '%d%m%Y').date()
| 1 | 755 |
instruction
|
Replace non-ASCII characters in string `text` with a single space
| 0 | 756 |
output
|
re.sub('[^\\x00-\\x7F]+', ' ', text)
| 1 | 756 |
instruction
| null | 0 | 757 |
output
|
numpy.array([[1, 2], [3, 4]])
| 1 | 757 |
instruction
|
Get a list `myList` from 1 to 10
| 0 | 758 |
output
|
myList = [i for i in range(10)]
| 1 | 758 |
instruction
|
use regex pattern '((.+?)\\2+)' to split string '44442(2)2(2)44'
| 0 | 759 |
output
|
[m[0] for m in re.compile('((.+?)\\2+)').findall('44442(2)2(2)44')]
| 1 | 759 |
instruction
|
use regular expression '((\\d)(?:[()]*\\2*[()]*)*)' to split string `s`
| 0 | 760 |
output
|
[i[0] for i in re.findall('((\\d)(?:[()]*\\2*[()]*)*)', s)]
| 1 | 760 |
instruction
|
remove the space between subplots in matplotlib.pyplot
| 0 | 761 |
output
|
fig.subplots_adjust(wspace=0, hspace=0)
| 1 | 761 |
instruction
|
Reverse list `x`
| 0 | 762 |
output
|
x[::-1]
| 1 | 762 |
instruction
| null | 0 | 763 |
output
|
json.dumps({'apple': 'cat', 'banana': 'dog', 'pear': 'fish'})
| 1 | 763 |
instruction
|
write a list of strings `row` to csv object `csvwriter`
| 0 | 764 |
output
|
csvwriter.writerow(row)
| 1 | 764 |
instruction
|
Jinja2 formate date `item.date` accorto pattern 'Y M d'
| 0 | 765 |
output
|
{{(item.date | date): 'Y M d'}}
| 1 | 765 |
instruction
|
Split a string `text` with comma, question mark or exclamation by non-consuming regex using look-behind
| 0 | 766 |
output
|
re.split('(?<=[\\.\\?!]) ', text)
| 1 | 766 |
instruction
|
create a regular expression object with the pattern '\xe2\x80\x93'
| 0 | 767 |
output
|
re.compile('\xe2\x80\x93')
| 1 | 767 |
instruction
|
declare an array `variable`
| 0 | 768 |
output
|
variable = []
| 1 | 768 |
instruction
|
declare an array with element 'i'
| 0 | 769 |
output
|
intarray = array('i')
| 1 | 769 |
instruction
|
given list `to_reverse`, reverse the all sublists and the list itself
| 0 | 770 |
output
|
[sublist[::-1] for sublist in to_reverse[::-1]]
| 1 | 770 |
instruction
| null | 0 | 771 |
output
|
re.sub('[^0-9a-zA-Z]+', '*', 'h^&ell`.,|o w]{+orld')
| 1 | 771 |
instruction
|
unescape special characters without splitting data in array of strings `['I ', u'<', '3s U ', u'&', ' you luvz me']`
| 0 | 772 |
output
|
"""""".join(['I ', '<', '3s U ', '&', ' you luvz me'])
| 1 | 772 |
instruction
|
disable logging while running unit tests in python django
| 0 | 773 |
output
|
logging.disable(logging.CRITICAL)
| 1 | 773 |
instruction
|
adding url `url` to mysql row
| 0 | 774 |
output
|
cursor.execute('INSERT INTO index(url) VALUES(%s)', (url,))
| 1 | 774 |
instruction
|
convert column of date objects 'DateObj' in pandas dataframe `df` to strings in new column 'DateStr'
| 0 | 775 |
output
|
df['DateStr'] = df['DateObj'].dt.strftime('%d%m%Y')
| 1 | 775 |
instruction
|
split string `s` by '@' and get the first element
| 0 | 776 |
output
|
s.split('@')[0]
| 1 | 776 |
instruction
|
drop rows of dataframe `df` whose index is smaller than the value of `start_remove` or bigger than the value of`end_remove`
| 0 | 777 |
output
|
df.query('index < @start_remove or index > @end_remove')
| 1 | 777 |
instruction
|
Drop the rows in pandas timeseries `df` from the row containing index `start_remove` to the row containing index `end_remove`
| 0 | 778 |
output
|
df.loc[(df.index < start_remove) | (df.index > end_remove)]
| 1 | 778 |
instruction
|
Get the number of NaN values in each column of dataframe `df`
| 0 | 779 |
output
|
df.isnull().sum()
| 1 | 779 |
instruction
|
reset index of dataframe `df`so that existing index values are transferred into `df`as columns
| 0 | 780 |
output
|
df.reset_index(inplace=True)
| 1 | 780 |
instruction
|
generate a list containing values associated with the key 'value' of each dictionary inside list `list_of_dicts`
| 0 | 781 |
output
|
[x['value'] for x in list_of_dicts]
| 1 | 781 |
instruction
| null | 0 | 782 |
output
|
[d['value'] for d in l]
| 1 | 782 |
instruction
| null | 0 | 783 |
output
|
[d['value'] for d in l if 'value' in d]
| 1 | 783 |
instruction
|
convert numpy array into python list structure
| 0 | 784 |
output
|
np.array([[1, 2, 3], [4, 5, 6]]).tolist()
| 1 | 784 |
instruction
|
converting string '(1,2,3,4)' to a tuple
| 0 | 785 |
output
|
ast.literal_eval('(1,2,3,4)')
| 1 | 785 |
instruction
|
keep a list `dataList` of lists sorted as it is created by second element
| 0 | 786 |
output
|
dataList.sort(key=lambda x: x[1])
| 1 | 786 |
instruction
|
remove duplicated items from list of lists `testdata`
| 0 | 787 |
output
|
list(map(list, set(map(lambda i: tuple(i), testdata))))
| 1 | 787 |
instruction
|
uniqueness for list of lists `testdata`
| 0 | 788 |
output
|
[list(i) for i in set(tuple(i) for i in testdata)]
| 1 | 788 |
instruction
|
in django, check if a user is in a group 'Member'
| 0 | 789 |
output
|
return user.groups.filter(name='Member').exists()
| 1 | 789 |
instruction
|
check if a user `user` is in a group from list of groups `['group1', 'group2']`
| 0 | 790 |
output
|
return user.groups.filter(name__in=['group1', 'group2']).exists()
| 1 | 790 |
instruction
|
Change log level dynamically to 'DEBUG' without restarting the application
| 0 | 791 |
output
|
logging.getLogger().setLevel(logging.DEBUG)
| 1 | 791 |
instruction
|
Concat each values in a tuple `(34.2424, -64.2344, 76.3534, 45.2344)` to get a string
| 0 | 792 |
output
|
"""""".join(str(i) for i in (34.2424, -64.2344, 76.3534, 45.2344))
| 1 | 792 |
instruction
|
swap each pair of characters in string `s`
| 0 | 793 |
output
|
"""""".join([s[x:x + 2][::-1] for x in range(0, len(s), 2)])
| 1 | 793 |
instruction
|
save current figure to file 'graph.png' with resolution of 1000 dpi
| 0 | 794 |
output
|
plt.savefig('graph.png', dpi=1000)
| 1 | 794 |
instruction
|
delete items from list `my_list` if the item exist in list `to_dell`
| 0 | 795 |
output
|
my_list = [[x for x in sublist if x not in to_del] for sublist in my_list]
| 1 | 795 |
instruction
|
find all the elements that consists value '1' in a list of tuples 'a'
| 0 | 796 |
output
|
[item for item in a if 1 in item]
| 1 | 796 |
instruction
|
find all elements in a list of tuples `a` where the first element of each tuple equals 1
| 0 | 797 |
output
|
[item for item in a if item[0] == 1]
| 1 | 797 |
instruction
|
Get the index value in list `p_list` using enumerate in list comprehension
| 0 | 798 |
output
|
{p.id: {'id': p.id, 'position': ind} for ind, p in enumerate(p_list)}
| 1 | 798 |
instruction
| null | 0 | 799 |
output
|
[dict(y) for y in set(tuple(x.items()) for x in d)]
| 1 | 799 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.