Dataset Viewer
message_type
stringclasses 2
values | message
stringlengths 2
232
⌀ | message_id
int64 0
1
| conversation_id
int64 0
2.38k
|
---|---|---|---|
instruction
|
Concatenate elements of a list 'x' of multiple integers to a single integer
| 0 | 0 |
output
|
sum(d * 10 ** i for i, d in enumerate(x[::-1]))
| 1 | 0 |
instruction
|
convert a list of integers into a single integer
| 0 | 1 |
output
|
r = int(''.join(map(str, x)))
| 1 | 1 |
instruction
|
convert a DateTime string back to a DateTime object of format '%Y-%m-%d %H:%M:%S.%f'
| 0 | 2 |
output
|
datetime.strptime('2010-11-13 10:33:54.227806', '%Y-%m-%d %H:%M:%S.%f')
| 1 | 2 |
instruction
|
get the average of a list values for each key in dictionary `d`)
| 0 | 3 |
output
|
[(i, sum(j) / len(j)) for i, j in list(d.items())]
| 1 | 3 |
instruction
|
zip two lists `[1, 2]` and `[3, 4]` into a list of two tuples containing elements at the same index in each list
| 0 | 4 |
output
|
zip([1, 2], [3, 4])
| 1 | 4 |
instruction
|
prepend string 'hello' to all items in list 'a'
| 0 | 5 |
output
|
['hello{0}'.format(i) for i in a]
| 1 | 5 |
instruction
|
regex for repeating words in a string `s`
| 0 | 6 |
output
|
re.sub('(?<!\\S)((\\S+)(?:\\s+\\2))(?:\\s+\\2)+(?!\\S)', '\\1', s)
| 1 | 6 |
instruction
|
normalize a pandas dataframe `df` by row
| 0 | 7 |
output
|
df.div(df.sum(axis=1), axis=0)
| 1 | 7 |
instruction
|
swap values in a tuple/list inside a list `mylist`
| 0 | 8 |
output
|
map(lambda t: (t[1], t[0]), mylist)
| 1 | 8 |
instruction
|
Swap values in a tuple/list in list `mylist`
| 0 | 9 |
output
|
[(t[1], t[0]) for t in mylist]
| 1 | 9 |
instruction
| null | 0 | 10 |
output
|
driver.find_element_by_xpath("//p[@id, 'one']/following-sibling::p")
| 1 | 10 |
instruction
|
find all occurrences of the pattern '\\[[^\\]]*\\]|\\([^\\)]*\\)|"[^"]*"|\\S+' within `strs`
| 0 | 11 |
output
|
re.findall('\\[[^\\]]*\\]|\\([^\\)]*\\)|"[^"]*"|\\S+', strs)
| 1 | 11 |
instruction
|
generate the combinations of 3 from a set `{1, 2, 3, 4}`
| 0 | 12 |
output
|
print(list(itertools.combinations({1, 2, 3, 4}, 3)))
| 1 | 12 |
instruction
|
add multiple columns `hour`, `weekday`, `weeknum` to pandas data frame `df` from lambda function `lambdafunc`
| 0 | 13 |
output
|
df[['hour', 'weekday', 'weeknum']] = df.apply(lambdafunc, axis=1)
| 1 | 13 |
instruction
|
BeautifulSoup search string 'Elsie' inside tag 'a'
| 0 | 14 |
output
|
soup.find_all('a', string='Elsie')
| 1 | 14 |
instruction
|
Convert a datetime object `my_datetime` into readable format `%B %d, %Y`
| 0 | 15 |
output
|
my_datetime.strftime('%B %d, %Y')
| 1 | 15 |
instruction
|
parse string `s` to int when string contains a number
| 0 | 16 |
output
|
int(''.join(c for c in s if c.isdigit()))
| 1 | 16 |
instruction
|
add dictionary `{'class': {'section': 5}}` to key 'Test' of dictionary `dic`
| 0 | 17 |
output
|
dic['Test'].update({'class': {'section': 5}})
| 1 | 17 |
instruction
|
transforming the string `s` into dictionary
| 0 | 18 |
output
|
dict(map(int, x.split(':')) for x in s.split(','))
| 1 | 18 |
instruction
| null | 0 | 19 |
output
|
driver.find_element_by_xpath("//div[@id='a']//a[@class='click']")
| 1 | 19 |
instruction
|
find rows matching `(0,1)` in a 2 dimensional numpy array `vals`
| 0 | 20 |
output
|
np.where((vals == (0, 1)).all(axis=1))
| 1 | 20 |
instruction
| null | 0 | 21 |
output
|
SomeModel.objects.filter(id=id).delete()
| 1 | 21 |
instruction
|
build a dictionary containing the conversion of each list in list `[['two', 2], ['one', 1]]` to a key/value pair as its items
| 0 | 22 |
output
|
dict([['two', 2], ['one', 1]])
| 1 | 22 |
instruction
|
convert list `l` to dictionary having each two adjacent elements as key/value pair
| 0 | 23 |
output
|
dict(zip(l[::2], l[1::2]))
| 1 | 23 |
instruction
|
assign float 9.8 to variable `GRAVITY`
| 0 | 24 |
output
|
GRAVITY = 9.8
| 1 | 24 |
instruction
|
separate numbers from characters in string "30m1000n20m"
| 0 | 25 |
output
|
re.findall('(([0-9]+)([A-Z]))', '20M10000N80M')
| 1 | 25 |
instruction
|
separate numbers and characters in string '20M10000N80M'
| 0 | 26 |
output
|
re.findall('([0-9]+|[A-Z])', '20M10000N80M')
| 1 | 26 |
instruction
|
separate numbers and characters in string '20M10000N80M'
| 0 | 27 |
output
|
re.findall('([0-9]+)([A-Z])', '20M10000N80M')
| 1 | 27 |
instruction
|
Get a list of words from a string `Hello world, my name is...James the 2nd!` removing punctuation
| 0 | 28 |
output
|
re.compile('\\w+').findall('Hello world, my name is...James the 2nd!')
| 1 | 28 |
instruction
|
Convert string '03:55' into datetime.time object
| 0 | 29 |
output
|
datetime.datetime.strptime('03:55', '%H:%M').time()
| 1 | 29 |
instruction
|
request url 'https://www.reporo.com/' without verifying SSL certificates
| 0 | 30 |
output
|
requests.get('https://www.reporo.com/', verify=False)
| 1 | 30 |
instruction
|
Extract values not equal to 0 from numpy array `a`
| 0 | 31 |
output
|
a[a != 0]
| 1 | 31 |
instruction
|
map two lists `keys` and `values` into a dictionary
| 0 | 32 |
output
|
new_dict = {k: v for k, v in zip(keys, values)}
| 1 | 32 |
instruction
|
map two lists `keys` and `values` into a dictionary
| 0 | 33 |
output
|
dict((k, v) for k, v in zip(keys, values))
| 1 | 33 |
instruction
|
map two lists `keys` and `values` into a dictionary
| 0 | 34 |
output
|
dict([(k, v) for k, v in zip(keys, values)])
| 1 | 34 |
instruction
|
find the string matches within parenthesis from a string `s` using regex
| 0 | 35 |
output
|
m = re.search('\\[(\\w+)\\]', s)
| 1 | 35 |
instruction
|
Enable the SO_REUSEADDR socket option in socket object `s` to fix the error `only one usage of each socket address is normally permitted`
| 0 | 36 |
output
|
s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
| 1 | 36 |
instruction
|
append the sum of each tuple pair in the grouped list `list1` and list `list2` elements to list `list3`
| 0 | 37 |
output
|
list3 = [(a + b) for a, b in zip(list1, list2)]
| 1 | 37 |
instruction
|
converting hex string `s` to its integer representations
| 0 | 38 |
output
|
[ord(c) for c in s.decode('hex')]
| 1 | 38 |
instruction
|
sort list `student_tuples` by second element of each tuple in ascending and third element of each tuple in descending
| 0 | 39 |
output
|
print(sorted(student_tuples, key=lambda t: (-t[2], t[0])))
| 1 | 39 |
instruction
|
get list of duplicated elements in range of 3
| 0 | 40 |
output
|
[y for x in range(3) for y in [x, x]]
| 1 | 40 |
instruction
|
read the contents of the file 'file.txt' into `txt`
| 0 | 41 |
output
|
txt = open('file.txt').read()
| 1 | 41 |
instruction
|
divide each element in list `myList` by integer `myInt`
| 0 | 42 |
output
|
myList[:] = [(x / myInt) for x in myList]
| 1 | 42 |
instruction
| null | 0 | 43 |
output
|
"""Name: {0[person.name]}""".format({'person.name': 'Joe'})
| 1 | 43 |
instruction
|
replace white spaces in dataframe `df` with '_'
| 0 | 44 |
output
|
df.replace(' ', '_', regex=True)
| 1 | 44 |
instruction
|
convert date `my_date` to datetime
| 0 | 45 |
output
|
datetime.datetime.combine(my_date, datetime.time.min)
| 1 | 45 |
instruction
|
convert tuple `tst` to string `tst2`
| 0 | 46 |
output
|
tst2 = str(tst)
| 1 | 46 |
instruction
|
get modified time of file `file`
| 0 | 47 |
output
|
time.ctime(os.path.getmtime(file))
| 1 | 47 |
instruction
|
get creation time of file `file`
| 0 | 48 |
output
|
time.ctime(os.path.getctime(file))
| 1 | 48 |
instruction
|
get modification time of file `filename`
| 0 | 49 |
output
|
t = os.path.getmtime(filename)
| 1 | 49 |
End of preview. Expand
in Data Studio
- Downloads last month
- 4