message_type
stringclasses 2
values | message
stringlengths 2
232
⌀ | message_id
int64 0
1
| conversation_id
int64 0
2.38k
|
---|---|---|---|
instruction
|
return the column for value 38.15 in dataframe `df`
| 0 | 150 |
output
|
df.ix[:, (df.loc[0] == 38.15)].columns
| 1 | 150 |
instruction
|
merge 2 dataframes `df1` and `df2` with same values in a column 'revenue' with and index 'date'
| 0 | 151 |
output
|
df2['revenue'] = df2.CET.map(df1.set_index('date')['revenue'])
| 1 | 151 |
instruction
|
load a json data `json_string` into variable `json_data`
| 0 | 152 |
output
|
json_data = json.loads(json_string)
| 1 | 152 |
instruction
|
convert radians 1 to degrees
| 0 | 153 |
output
|
math.cos(math.radians(1))
| 1 | 153 |
instruction
|
count the number of integers in list `a`
| 0 | 154 |
output
|
sum(isinstance(x, int) for x in a)
| 1 | 154 |
instruction
|
replacing '\u200b' with '*' in a string using regular expressions
| 0 | 155 |
output
|
'used\u200b'.replace('\u200b', '*')
| 1 | 155 |
instruction
|
run function 'SudsMove' simultaneously
| 0 | 156 |
output
|
threading.Thread(target=SudsMove).start()
| 1 | 156 |
instruction
|
sum of squares values in a list `l`
| 0 | 157 |
output
|
sum(i * i for i in l)
| 1 | 157 |
instruction
|
calculate the sum of the squares of each value in list `l`
| 0 | 158 |
output
|
sum(map(lambda x: x * x, l))
| 1 | 158 |
instruction
|
Create a dictionary `d` from list `iterable`
| 0 | 159 |
output
|
d = dict(((key, value) for (key, value) in iterable))
| 1 | 159 |
instruction
|
Create a dictionary `d` from list `iterable`
| 0 | 160 |
output
|
d = {key: value for (key, value) in iterable}
| 1 | 160 |
instruction
|
Create a dictionary `d` from list of key value pairs `iterable`
| 0 | 161 |
output
|
d = {k: v for (k, v) in iterable}
| 1 | 161 |
instruction
|
round off entries in dataframe `df` column `Alabama_exp` to two decimal places, and entries in column `Credit_exp` to three decimal places
| 0 | 162 |
output
|
df.round({'Alabama_exp': 2, 'Credit_exp': 3})
| 1 | 162 |
instruction
|
Make function `WRITEFUNCTION` output nothing in curl `p`
| 0 | 163 |
output
|
p.setopt(pycurl.WRITEFUNCTION, lambda x: None)
| 1 | 163 |
instruction
|
return a random word from a word list 'words'
| 0 | 164 |
output
|
print(random.choice(words))
| 1 | 164 |
instruction
|
Find a max value of the key `count` in a nested dictionary `d`
| 0 | 165 |
output
|
max(d, key=lambda x: d[x]['count'])
| 1 | 165 |
instruction
|
get list of string elements in string `data` delimited by commas, putting `0` in place of empty strings
| 0 | 166 |
output
|
[(int(x) if x else 0) for x in data.split(',')]
| 1 | 166 |
instruction
|
split string `s` into a list of strings based on ',' then replace empty strings with zero
| 0 | 167 |
output
|
""",""".join(x or '0' for x in s.split(','))
| 1 | 167 |
instruction
|
regular expression match nothing
| 0 | 168 |
output
|
re.compile('$^')
| 1 | 168 |
instruction
|
regular expression syntax for not to match anything
| 0 | 169 |
output
|
re.compile('.\\A|.\\A*|.\\A+')
| 1 | 169 |
instruction
|
create a regular expression object with a pattern that will match nothing
| 0 | 170 |
output
|
re.compile('a^')
| 1 | 170 |
instruction
|
drop all columns in dataframe `df` that holds a maximum value bigger than 0
| 0 | 171 |
output
|
df.columns[df.max() > 0]
| 1 | 171 |
instruction
|
check if date `yourdatetime` is equal to today's date
| 0 | 172 |
output
|
yourdatetime.date() == datetime.today().date()
| 1 | 172 |
instruction
|
print bold text 'Hello'
| 0 | 173 |
output
|
print('\x1b[1m' + 'Hello')
| 1 | 173 |
instruction
|
remove 20 symbols in front of '.' in string 'unique12345678901234567890.mkv'
| 0 | 174 |
output
|
re.sub('.{20}(.mkv)', '\\1', 'unique12345678901234567890.mkv')
| 1 | 174 |
instruction
|
Define a list with string values `['a', 'c', 'b', 'obj']`
| 0 | 175 |
output
|
['a', 'c', 'b', 'obj']
| 1 | 175 |
instruction
|
substitute multiple whitespace with single whitespace in string `mystring`
| 0 | 176 |
output
|
""" """.join(mystring.split())
| 1 | 176 |
instruction
|
print a floating point number 2.345e-67 without any truncation
| 0 | 177 |
output
|
print('{:.100f}'.format(2.345e-67))
| 1 | 177 |
instruction
|
Check if key 'key1' in `dict`
| 0 | 178 |
output
|
('key1' in dict)
| 1 | 178 |
instruction
|
Check if key 'a' in `d`
| 0 | 179 |
output
|
('a' in d)
| 1 | 179 |
instruction
|
Check if key 'c' in `d`
| 0 | 180 |
output
|
('c' in d)
| 1 | 180 |
instruction
|
Check if a given key 'key1' exists in dictionary `dict`
| 0 | 181 |
output
|
if ('key1' in dict):
pass
| 1 | 181 |
instruction
|
Check if a given key `key` exists in dictionary `d`
| 0 | 182 |
output
|
if (key in d):
pass
| 1 | 182 |
instruction
|
create a django query for a list of values `1, 4, 7`
| 0 | 183 |
output
|
Blog.objects.filter(pk__in=[1, 4, 7])
| 1 | 183 |
instruction
|
read a binary file 'test/test.pdf'
| 0 | 184 |
output
|
f = open('test/test.pdf', 'rb')
| 1 | 184 |
instruction
|
insert ' ' between every three digit before '.' and replace ',' with '.' in 12345678.46
| 0 | 185 |
output
|
format(12345678.46, ',').replace(',', ' ').replace('.', ',')
| 1 | 185 |
instruction
|
Join pandas data frame `frame_1` and `frame_2` with left join by `county_ID` and right join by `countyid`
| 0 | 186 |
output
|
pd.merge(frame_1, frame_2, left_on='county_ID', right_on='countyid')
| 1 | 186 |
instruction
|
calculate ratio of sparsity in a numpy array `a`
| 0 | 187 |
output
|
np.isnan(a).sum() / np.prod(a.shape)
| 1 | 187 |
instruction
|
reverse sort items in default dictionary `cityPopulation` by the third item in each key's list of values
| 0 | 188 |
output
|
sorted(iter(cityPopulation.items()), key=lambda k_v: k_v[1][2], reverse=True)
| 1 | 188 |
instruction
|
Sort dictionary `u` in ascending order based on second elements of its values
| 0 | 189 |
output
|
sorted(list(u.items()), key=lambda v: v[1])
| 1 | 189 |
instruction
|
reverse sort dictionary `d` based on its values
| 0 | 190 |
output
|
sorted(list(d.items()), key=lambda k_v: k_v[1], reverse=True)
| 1 | 190 |
instruction
|
sorting a defaultdict `d` by value
| 0 | 191 |
output
|
sorted(list(d.items()), key=lambda k_v: k_v[1])
| 1 | 191 |
instruction
|
open a file 'bundled-resource.jpg' in the same directory as a python script
| 0 | 192 |
output
|
f = open(os.path.join(__location__, 'bundled-resource.jpg'))
| 1 | 192 |
instruction
|
open the file 'words.txt' in 'rU' mode
| 0 | 193 |
output
|
f = open('words.txt', 'rU')
| 1 | 193 |
instruction
|
divide the values with same keys of two dictionary `d1` and `d2`
| 0 | 194 |
output
|
{k: (float(d2[k]) / d1[k]) for k in d2}
| 1 | 194 |
instruction
|
divide the value for each key `k` in dict `d2` by the value for the same key `k` in dict `d1`
| 0 | 195 |
output
|
{k: (d2[k] / d1[k]) for k in list(d1.keys()) & d2}
| 1 | 195 |
instruction
|
divide values associated with each key in dictionary `d1` from values associated with the same key in dictionary `d2`
| 0 | 196 |
output
|
dict((k, float(d2[k]) / d1[k]) for k in d2)
| 1 | 196 |
instruction
|
write dataframe `df` to csv file `filename` with dates formatted as yearmonthday `%Y%m%d`
| 0 | 197 |
output
|
df.to_csv(filename, date_format='%Y%m%d')
| 1 | 197 |
instruction
|
remove a key 'key' from a dictionary `my_dict`
| 0 | 198 |
output
|
my_dict.pop('key', None)
| 1 | 198 |
instruction
|
replace NaN values in array `a` with zeros
| 0 | 199 |
output
|
b = np.where(np.isnan(a), 0, a)
| 1 | 199 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.