message_type
stringclasses 2
values | message
stringlengths 2
232
⌀ | message_id
int64 0
1
| conversation_id
int64 0
2.38k
|
---|---|---|---|
instruction
|
check if list `a` is empty
| 0 | 900 |
output
|
if (not a):
pass
| 1 | 900 |
instruction
|
check if list `seq` is empty
| 0 | 901 |
output
|
if (not seq):
pass
| 1 | 901 |
instruction
|
check if list `li` is empty
| 0 | 902 |
output
|
if (len(li) == 0):
pass
| 1 | 902 |
instruction
|
create a list containing the indices of elements greater than 4 in list `a`
| 0 | 903 |
output
|
[i for i, v in enumerate(a) if v > 4]
| 1 | 903 |
instruction
|
reverse list `yourdata`
| 0 | 904 |
output
|
sorted(yourdata, reverse=True)
| 1 | 904 |
instruction
|
sort list of nested dictionaries `yourdata` in reverse based on values associated with each dictionary's key 'subkey'
| 0 | 905 |
output
|
sorted(yourdata, key=lambda d: d.get('key', {}).get('subkey'), reverse=True)
| 1 | 905 |
instruction
|
sort list of nested dictionaries `yourdata` in reverse order of 'key' and 'subkey'
| 0 | 906 |
output
|
yourdata.sort(key=lambda e: e['key']['subkey'], reverse=True)
| 1 | 906 |
instruction
|
remove decimal points in pandas data frame using round
| 0 | 907 |
output
|
df.round()
| 1 | 907 |
instruction
|
Get data from matplotlib plot
| 0 | 908 |
output
|
gca().get_lines()[n].get_xydata()
| 1 | 908 |
instruction
|
get the maximum 2 values per row in array `A`
| 0 | 909 |
output
|
A[:, -2:]
| 1 | 909 |
instruction
|
Get value for "username" parameter in GET request in Django
| 0 | 910 |
output
|
request.GET.get('username', '')
| 1 | 910 |
instruction
|
pretty-print ordered dictionary `o`
| 0 | 911 |
output
|
pprint(dict(list(o.items())))
| 1 | 911 |
instruction
|
Confirm urls in Django properly
| 0 | 912 |
output
|
url('^$', include('sms.urls')),
| 1 | 912 |
instruction
|
Configure url in django properly
| 0 | 913 |
output
|
url('^', include('sms.urls')),
| 1 | 913 |
instruction
|
get the tuple in list `a_list` that has the largest item in the second index
| 0 | 914 |
output
|
max_item = max(a_list, key=operator.itemgetter(1))
| 1 | 914 |
instruction
|
find tuple in list of tuples `a_list` with the largest second element
| 0 | 915 |
output
|
max(a_list, key=operator.itemgetter(1))
| 1 | 915 |
instruction
|
resample series `s` into 3 months bins and sum each bin
| 0 | 916 |
output
|
s.resample('3M', how='sum')
| 1 | 916 |
instruction
|
extract elements at indices (1, 2, 5) from a list `a`
| 0 | 917 |
output
|
[a[i] for i in (1, 2, 5)]
| 1 | 917 |
instruction
|
filter lines from a text file 'textfile' which contain a word 'apple'
| 0 | 918 |
output
|
[line for line in open('textfile') if 'apple' in line]
| 1 | 918 |
instruction
|
convert a date string `s` to a datetime object
| 0 | 919 |
output
|
datetime.datetime.strptime(s, '%Y-%m-%dT%H:%M:%SZ')
| 1 | 919 |
instruction
|
reading tab-delimited csv file `filename` with pandas on mac
| 0 | 920 |
output
|
pandas.read_csv(filename, sep='\t', lineterminator='\r')
| 1 | 920 |
instruction
|
replace only first occurence of string `TEST` from a string `longlongTESTstringTEST`
| 0 | 921 |
output
|
'longlongTESTstringTEST'.replace('TEST', '?', 1)
| 1 | 921 |
instruction
|
zip file `pdffile` using its basename as directory name
| 0 | 922 |
output
|
archive.write(pdffile, os.path.basename(pdffile))
| 1 | 922 |
instruction
|
create a dictionary of pairs from a list of tuples `myListOfTuples`
| 0 | 923 |
output
|
dict(x[1:] for x in reversed(myListOfTuples))
| 1 | 923 |
instruction
|
subtract elements of list `List1` from elements of list `List2`
| 0 | 924 |
output
|
[(x1 - x2) for x1, x2 in zip(List1, List2)]
| 1 | 924 |
instruction
|
check if string `string` starts with a number
| 0 | 925 |
output
|
string[0].isdigit()
| 1 | 925 |
instruction
|
Check if string `strg` starts with any of the elements in list ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9')
| 0 | 926 |
output
|
strg.startswith(('0', '1', '2', '3', '4', '5', '6', '7', '8', '9'))
| 1 | 926 |
instruction
|
print script's directory
| 0 | 927 |
output
|
print(os.path.dirname(os.path.realpath(__file__)))
| 1 | 927 |
instruction
|
split string `text` by the occurrences of regex pattern '(?<=\\?|!|\\.)\\s{0,2}(?=[A-Z]|$)'
| 0 | 928 |
output
|
re.split('(?<=\\?|!|\\.)\\s{0,2}(?=[A-Z]|$)', text)
| 1 | 928 |
instruction
|
Make a scatter plot using unpacked values of list `li`
| 0 | 929 |
output
|
plt.scatter(*zip(*li))
| 1 | 929 |
instruction
|
rearrange tuple of tuples `t`
| 0 | 930 |
output
|
tuple(zip(*t))
| 1 | 930 |
instruction
|
Get average for every three columns in `df` dataframe
| 0 | 931 |
output
|
df.groupby(np.arange(len(df.columns)) // 3, axis=1).mean()
| 1 | 931 |
instruction
|
convert a list `L` of ascii values to a string
| 0 | 932 |
output
|
"""""".join(chr(i) for i in L)
| 1 | 932 |
instruction
|
count the number of pairs in dictionary `d` whose value equal to `chosen_value`
| 0 | 933 |
output
|
sum(x == chosen_value for x in list(d.values()))
| 1 | 933 |
instruction
|
count the number of values in `d` dictionary that are predicate to function `some_condition`
| 0 | 934 |
output
|
sum(1 for x in list(d.values()) if some_condition(x))
| 1 | 934 |
instruction
|
convert double 0.00582811585976 to float
| 0 | 935 |
output
|
struct.unpack('f', struct.pack('f', 0.00582811585976))
| 1 | 935 |
instruction
|
convert datetime.date `dt` to utc timestamp
| 0 | 936 |
output
|
timestamp = (dt - datetime(1970, 1, 1)).total_seconds()
| 1 | 936 |
instruction
|
sort column `m` in panda dataframe `df`
| 0 | 937 |
output
|
df.sort('m')
| 1 | 937 |
instruction
|
Sort a data `a` in descending order based on the `modified` attribute of elements using lambda function
| 0 | 938 |
output
|
a = sorted(a, key=lambda x: x.modified, reverse=True)
| 1 | 938 |
instruction
|
print the truth value of `a`
| 0 | 939 |
output
|
print(bool(a))
| 1 | 939 |
instruction
|
rename `last` row index label in dataframe `df` to `a`
| 0 | 940 |
output
|
df = df.rename(index={last: 'a'})
| 1 | 940 |
instruction
|
Fit Kmeans function to a one-dimensional array `x` by reshaping it to be a multidimensional array of single values
| 0 | 941 |
output
|
km.fit(x.reshape(-1, 1))
| 1 | 941 |
instruction
|
Sort a list of strings 'words' such that items starting with 's' come first.
| 0 | 942 |
output
|
sorted(words, key=lambda x: 'a' + x if x.startswith('s') else 'b' + x)
| 1 | 942 |
instruction
|
open the login site 'http://somesite.com/adminpanel/index.php' in the browser
| 0 | 943 |
output
|
webbrowser.open('http://somesite.com/adminpanel/index.php')
| 1 | 943 |
instruction
|
fetch all elements in a dictionary `parent_dict`, falling between two keys 2 and 4
| 0 | 944 |
output
|
dict((k, v) for k, v in parent_dict.items() if 2 < k < 4)
| 1 | 944 |
instruction
|
fetch all elements in a dictionary 'parent_dict' where the key is between the range of 2 to 4
| 0 | 945 |
output
|
dict((k, v) for k, v in parent_dict.items() if k > 2 and k < 4)
| 1 | 945 |
instruction
|
sort two lists `list1` and `list2` together using lambda function
| 0 | 946 |
output
|
[list(x) for x in zip(*sorted(zip(list1, list2), key=lambda pair: pair[0]))]
| 1 | 946 |
instruction
|
get the number of values in list `j` that is greater than 5
| 0 | 947 |
output
|
sum(((i > 5) for i in j))
| 1 | 947 |
instruction
|
get the number of values in list `j` that is greater than 5
| 0 | 948 |
output
|
len([1 for i in j if (i > 5)])
| 1 | 948 |
instruction
|
get the number of values in list `j` that is greater than `i`
| 0 | 949 |
output
|
j = np.array(j)
sum((j > i))
| 1 | 949 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.