message_type
stringclasses 2
values | message
stringlengths 2
232
⌀ | message_id
int64 0
1
| conversation_id
int64 0
2.38k
|
---|---|---|---|
instruction
|
insert a list `k` at the front of list `a`
| 0 | 600 |
output
|
a.insert(0, k)
| 1 | 600 |
instruction
|
insert elements of list `k` into list `a` at position `n`
| 0 | 601 |
output
|
a = a[:n] + k + a[n:]
| 1 | 601 |
instruction
|
calculate the mean of the nonzero values' indices of dataframe `df`
| 0 | 602 |
output
|
np.flatnonzero(x).mean()
| 1 | 602 |
instruction
|
get date from dataframe `df` column 'dates' to column 'just_date'
| 0 | 603 |
output
|
df['just_date'] = df['dates'].dt.date
| 1 | 603 |
instruction
|
remove elements in list `b` from list `a`
| 0 | 604 |
output
|
[x for x in a if x not in b]
| 1 | 604 |
instruction
|
join elements of each tuple in list `a` into one string
| 0 | 605 |
output
|
[''.join(x) for x in a]
| 1 | 605 |
instruction
|
join items of each tuple in list of tuples `a` into a list of strings
| 0 | 606 |
output
|
list(map(''.join, a))
| 1 | 606 |
instruction
|
match blank lines in `s` with regular expressions
| 0 | 607 |
output
|
re.split('\n\\s*\n', s)
| 1 | 607 |
instruction
|
merge a list of integers `[1, 2, 3, 4, 5]` into a single integer
| 0 | 608 |
output
|
from functools import reduce
reduce(lambda x, y: 10 * x + y, [1, 2, 3, 4, 5])
| 1 | 608 |
instruction
|
Convert float 24322.34 to comma-separated string
| 0 | 609 |
output
|
"""{0:,.2f}""".format(24322.34)
| 1 | 609 |
instruction
|
pass dictionary items `data` as keyword arguments in function `my_function`
| 0 | 610 |
output
|
my_function(**data)
| 1 | 610 |
instruction
|
get line count of file 'myfile.txt'
| 0 | 611 |
output
|
sum((1 for line in open('myfile.txt')))
| 1 | 611 |
instruction
|
get line count of file `filename`
| 0 | 612 |
output
|
def bufcount(filename):
f = open(filename)
lines = 0
buf_size = (1024 * 1024)
read_f = f.read
buf = read_f(buf_size)
while buf:
lines += buf.count('\n')
buf = read_f(buf_size)
return lines
| 1 | 612 |
instruction
|
round 1123.456789 to be an integer
| 0 | 613 |
output
|
print(round(1123.456789, -1))
| 1 | 613 |
instruction
|
sort list `X` based on values from another list `Y`
| 0 | 614 |
output
|
[x for y, x in sorted(zip(Y, X))]
| 1 | 614 |
instruction
|
sorting list 'X' based on values from another list 'Y'
| 0 | 615 |
output
|
[x for y, x in sorted(zip(Y, X))]
| 1 | 615 |
instruction
|
get equivalent week number from a date `2010/6/16` using isocalendar
| 0 | 616 |
output
|
datetime.date(2010, 6, 16).isocalendar()[1]
| 1 | 616 |
instruction
|
select multiple ranges of columns 1-10, 15, 17, and 50-100 in pandas dataframe `df`
| 0 | 617 |
output
|
df.iloc[:, (np.r_[1:10, (15), (17), 50:100])]
| 1 | 617 |
instruction
|
apply two different aggregating functions `mean` and `sum` to the same column `dummy` in pandas data frame `df`
| 0 | 618 |
output
|
df.groupby('dummy').agg({'returns': [np.mean, np.sum]})
| 1 | 618 |
instruction
|
convert string `s` to lowercase
| 0 | 619 |
output
|
s.lower()
| 1 | 619 |
instruction
|
convert utf-8 string `s` to lowercase
| 0 | 620 |
output
|
s.decode('utf-8').lower()
| 1 | 620 |
instruction
| null | 0 | 621 |
output
|
ftp.retrbinary('RETR %s' % filename, file.write)
| 1 | 621 |
instruction
|
handle the `urlfetch_errors ` exception for imaplib request to url `url`
| 0 | 622 |
output
|
urlfetch.fetch(url, deadline=10 * 60)
| 1 | 622 |
instruction
|
output first 100 characters in a string `my_string`
| 0 | 623 |
output
|
print(my_string[0:100])
| 1 | 623 |
instruction
|
make matplotlib plot legend put marker in legend only once
| 0 | 624 |
output
|
legend(numpoints=1)
| 1 | 624 |
instruction
|
get set intersection between dictionaries `d1` and `d2`
| 0 | 625 |
output
|
dict((x, set(y) & set(d1.get(x, ()))) for x, y in d2.items())
| 1 | 625 |
instruction
|
convert csv file 'test.csv' into two-dimensional matrix
| 0 | 626 |
output
|
numpy.loadtxt(open('test.csv', 'rb'), delimiter=',', skiprows=1)
| 1 | 626 |
instruction
|
filter the objects in django model 'Sample' between date range `2011-01-01` and `2011-01-31`
| 0 | 627 |
output
|
Sample.objects.filter(date__range=['2011-01-01', '2011-01-31'])
| 1 | 627 |
instruction
|
filter objects month wise in django model `Sample` for year `2011`
| 0 | 628 |
output
|
Sample.objects.filter(date__year='2011', date__month='01')
| 1 | 628 |
instruction
|
create a dictionary `{'spam': 5, 'ham': 6}` into another dictionary `d` field 'dict3'
| 0 | 629 |
output
|
d['dict3'] = {'spam': 5, 'ham': 6}
| 1 | 629 |
instruction
|
apply `numpy.linalg.norm` to each row of a matrix `a`
| 0 | 630 |
output
|
numpy.apply_along_axis(numpy.linalg.norm, 1, a)
| 1 | 630 |
instruction
|
merge dictionaries form array `dicts` in a single expression
| 0 | 631 |
output
|
dict((k, v) for d in dicts for k, v in list(d.items()))
| 1 | 631 |
instruction
|
Convert escaped utf string to utf string in `your string`
| 0 | 632 |
output
|
print('your string'.decode('string_escape'))
| 1 | 632 |
instruction
|
counting the number of true booleans in a python list `[True, True, False, False, False, True]`
| 0 | 633 |
output
|
sum([True, True, False, False, False, True])
| 1 | 633 |
instruction
|
set the size of figure `fig` in inches to width height of `w`, `h`
| 0 | 634 |
output
|
fig.set_size_inches(w, h, forward=True)
| 1 | 634 |
instruction
|
format string with dict `{'5': 'you'}` with integer keys
| 0 | 635 |
output
|
'hello there %(5)s' % {'5': 'you'}
| 1 | 635 |
instruction
|
Convert a string of numbers `example_string` separated by `,` into a list of integers
| 0 | 636 |
output
|
map(int, example_string.split(','))
| 1 | 636 |
instruction
|
Convert a string of numbers 'example_string' separated by comma into a list of numbers
| 0 | 637 |
output
|
[int(s) for s in example_string.split(',')]
| 1 | 637 |
instruction
|
Flatten list `x`
| 0 | 638 |
output
|
x = [i[0] for i in x]
| 1 | 638 |
instruction
|
convert list `x` into a flat list
| 0 | 639 |
output
|
y = map(operator.itemgetter(0), x)
| 1 | 639 |
instruction
|
get a list `y` of the first element of every tuple in list `x`
| 0 | 640 |
output
|
y = [i[0] for i in x]
| 1 | 640 |
instruction
|
extract all the values of a specific key named 'values' from a list of dictionaries
| 0 | 641 |
output
|
results = [item['value'] for item in test_data]
| 1 | 641 |
instruction
|
get current datetime in ISO format
| 0 | 642 |
output
|
datetime.datetime.now().isoformat()
| 1 | 642 |
instruction
|
get UTC datetime in ISO format
| 0 | 643 |
output
|
datetime.datetime.utcnow().isoformat()
| 1 | 643 |
instruction
|
Merge all columns in dataframe `df` into one column
| 0 | 644 |
output
|
df.apply(' '.join, axis=0)
| 1 | 644 |
instruction
|
pandas subtract a row from dataframe `df2` from dataframe `df`
| 0 | 645 |
output
|
pd.DataFrame(df.values - df2.values, columns=df.columns)
| 1 | 645 |
instruction
|
read file 'myfile.txt' using universal newline mode 'U'
| 0 | 646 |
output
|
print(open('myfile.txt', 'U').read())
| 1 | 646 |
instruction
|
print line `line` from text file with 'utf-16-le' format
| 0 | 647 |
output
|
print(line.decode('utf-16-le').split())
| 1 | 647 |
instruction
|
open a text file `data.txt` in io module with encoding `utf-16-le`
| 0 | 648 |
output
|
file = io.open('data.txt', 'r', encoding='utf-16-le')
| 1 | 648 |
instruction
|
Join data of dataframe `df1` with data in dataframe `df2` based on similar values of column 'user_id' in both dataframes
| 0 | 649 |
output
|
s1 = pd.merge(df1, df2, how='inner', on=['user_id'])
| 1 | 649 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.