message_type stringclasses 2 values | message stringlengths 2 232 ⌀ | message_id int64 0 1 | conversation_id int64 0 2.38k |
|---|---|---|---|
instruction | null | 0 | 100 |
output | driver.find_element_by_xpath('xpath').click() | 1 | 100 |
instruction | count unique index values in column 'A' in pandas dataframe `ex` | 0 | 101 |
output | ex.groupby(level='A').agg(lambda x: x.index.get_level_values(1).nunique()) | 1 | 101 |
instruction | Create a pandas dataframe of values from a dictionary `d` which contains dictionaries of dictionaries | 0 | 102 |
output | pd.concat(map(pd.DataFrame, iter(d.values())), keys=list(d.keys())).stack().unstack(0) | 1 | 102 |
instruction | find out the number of non-matched elements at the same index of list `a` and list `b` | 0 | 103 |
output | sum(1 for i, j in zip(a, b) if i != j) | 1 | 103 |
instruction | make all keys lowercase in dictionary `d` | 0 | 104 |
output | d = {(a.lower(), b): v for (a, b), v in list(d.items())} | 1 | 104 |
instruction | sort list `list_` based on first element of each tuple and by the length of the second element of each tuple | 0 | 105 |
output | list_.sort(key=lambda x: [x[0], len(x[1]), x[1]]) | 1 | 105 |
instruction | trim whitespace in string `s` | 0 | 106 |
output | s.strip() | 1 | 106 |
instruction | trim whitespace (including tabs) in `s` on the left side | 0 | 107 |
output | s = s.lstrip() | 1 | 107 |
instruction | trim whitespace (including tabs) in `s` on the right side | 0 | 108 |
output | s = s.rstrip() | 1 | 108 |
instruction | trim characters ' \t\n\r' in `s` | 0 | 109 |
output | s = s.strip(' \t\n\r') | 1 | 109 |
instruction | trim whitespaces (including tabs) in string `s` | 0 | 110 |
output | print(re.sub('[\\s+]', '', s)) | 1 | 110 |
instruction | In Django, filter `Task.objects` based on all entities in ['A', 'P', 'F'] | 0 | 111 |
output | Task.objects.exclude(prerequisites__status__in=['A', 'P', 'F']) | 1 | 111 |
instruction | Change background color in Tkinter | 0 | 112 |
output | root.configure(background='black') | 1 | 112 |
instruction | convert dict `result` to numpy structured array | 0 | 113 |
output | numpy.array([(key, val) for key, val in result.items()], dtype) | 1 | 113 |
instruction | Concatenate dataframe `df_1` to dataframe `df_2` sorted by values of the column 'y' | 0 | 114 |
output | pd.concat([df_1, df_2.sort_values('y')]) | 1 | 114 |
instruction | replace the last occurence of an expression '</div>' with '</bad>' in a string `s` | 0 | 115 |
output | re.sub('(.*)</div>', '\\1</bad>', s) | 1 | 115 |
instruction | get the maximum of 'salary' and 'bonus' values in a dictionary | 0 | 116 |
output | print(max(d, key=lambda x: (d[x]['salary'], d[x]['bonus']))) | 1 | 116 |
instruction | Filter Django objects by `author` with ids `1` and `2` | 0 | 117 |
output | Book.objects.filter(author__id=1).filter(author__id=2) | 1 | 117 |
instruction | split string 'fooxyzbar' based on case-insensitive matching using string 'XYZ' | 0 | 118 |
output | re.compile('XYZ', re.IGNORECASE).split('fooxyzbar') | 1 | 118 |
instruction | get list of sums of neighboring integers in string `example` | 0 | 119 |
output | [sum(map(int, s)) for s in example.split()] | 1 | 119 |
instruction | Get all the keys from dictionary `y` whose value is `1` | 0 | 120 |
output | [i for i in y if y[i] == 1] | 1 | 120 |
instruction | converting byte string `c` in unicode string | 0 | 121 |
output | c.decode('unicode_escape') | 1 | 121 |
instruction | unpivot first 2 columns into new columns 'year' and 'value' from a pandas dataframe `x` | 0 | 122 |
output | pd.melt(x, id_vars=['farm', 'fruit'], var_name='year', value_name='value') | 1 | 122 |
instruction | add key "item3" and value "3" to dictionary `default_data ` | 0 | 123 |
output | default_data['item3'] = 3 | 1 | 123 |
instruction | add key "item3" and value "3" to dictionary `default_data ` | 0 | 124 |
output | default_data.update({'item3': 3, }) | 1 | 124 |
instruction | add key value pairs 'item4' , 4 and 'item5' , 5 to dictionary `default_data` | 0 | 125 |
output | default_data.update({'item4': 4, 'item5': 5, }) | 1 | 125 |
instruction | Get the first and last 3 elements of list `l` | 0 | 126 |
output | l[:3] + l[-3:] | 1 | 126 |
instruction | reset index to default in dataframe `df` | 0 | 127 |
output | df = df.reset_index(drop=True) | 1 | 127 |
instruction | For each index `x` from 0 to 3, append the element at index `x` of list `b` to the list at index `x` of list a. | 0 | 128 |
output | [a[x].append(b[x]) for x in range(3)] | 1 | 128 |
instruction | get canonical path of the filename `path` | 0 | 129 |
output | os.path.realpath(path) | 1 | 129 |
instruction | check if dictionary `L[0].f.items()` is in dictionary `a3.f.items()` | 0 | 130 |
output | set(L[0].f.items()).issubset(set(a3.f.items())) | 1 | 130 |
instruction | find all the indexes in a Numpy 2D array where the value is 1 | 0 | 131 |
output | zip(*np.where(a == 1)) | 1 | 131 |
instruction | null | 0 | 132 |
output | np.where(a == 1) | 1 | 132 |
instruction | Collapse hierarchical column index to level 0 in dataframe `df` | 0 | 133 |
output | df.columns = df.columns.get_level_values(0) | 1 | 133 |
instruction | create a matrix from a list `[1, 2, 3]` | 0 | 134 |
output | x = scipy.matrix([1, 2, 3]).transpose() | 1 | 134 |
instruction | add character '@' after word 'get' in string `text` | 0 | 135 |
output | text = re.sub('(\\bget\\b)', '\\1@', text) | 1 | 135 |
instruction | get a numpy array that contains the element wise minimum of three 3x1 arrays | 0 | 136 |
output | np.array([np.arange(3), np.arange(2, -1, -1), np.ones((3,))]).min(axis=0) | 1 | 136 |
instruction | add a column 'new_col' to dataframe `df` for index in range | 0 | 137 |
output | df['new_col'] = list(range(1, len(df) + 1)) | 1 | 137 |
instruction | set environment variable 'DEBUSSY' equal to 1 | 0 | 138 |
output | os.environ['DEBUSSY'] = '1' | 1 | 138 |
instruction | Get a environment variable `DEBUSSY` | 0 | 139 |
output | print(os.environ['DEBUSSY']) | 1 | 139 |
instruction | set environment variable 'DEBUSSY' to '1' | 0 | 140 |
output | os.environ['DEBUSSY'] = '1' | 1 | 140 |
instruction | update dictionary `b`, overwriting values where keys are identical, with contents of dictionary `d` | 0 | 141 |
output | b.update(d) | 1 | 141 |
instruction | get all the values in column `b` from pandas data frame `df` | 0 | 142 |
output | df['b'] | 1 | 142 |
instruction | make a line plot with errorbars, `ebar`, from data `x, y, err` and set color of the errorbars to `y` (yellow) | 0 | 143 |
output | ebar = plt.errorbar(x, y, yerr=err, ecolor='y') | 1 | 143 |
instruction | find all files with extension '.c' in directory `folder` | 0 | 144 |
output | results += [each for each in os.listdir(folder) if each.endswith('.c')] | 1 | 144 |
instruction | add unicode string '1' to UTF-8 decoded string '\xc2\xa3' | 0 | 145 |
output | print('\xc2\xa3'.decode('utf8') + '1') | 1 | 145 |
instruction | lower-case the string obtained by replacing the occurrences of regex pattern '(?<=[a-z])([A-Z])' in string `s` with eplacement '-\\1' | 0 | 146 |
output | re.sub('(?<=[a-z])([A-Z])', '-\\1', s).lower() | 1 | 146 |
instruction | null | 0 | 147 |
output | os.system('ulimit -s unlimited; some_executable') | 1 | 147 |
instruction | format a string `num` using string formatting | 0 | 148 |
output | """{0:.3g}""".format(num) | 1 | 148 |
instruction | append the first element of array `a` to array `a` | 0 | 149 |
output | numpy.append(a, a[0]) | 1 | 149 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.