message_type stringclasses 2 values | message stringlengths 2 232 ⌀ | message_id int64 0 1 | conversation_id int64 0 2.38k |
|---|---|---|---|
instruction | sort list `lst` based on each element's number of occurrences | 0 | 400 |
output | sorted(lst, key=lambda x: (-1 * c[x], lst.index(x))) | 1 | 400 |
instruction | Get the value with the maximum length in each column in array `foo` | 0 | 401 |
output | [max(len(str(x)) for x in line) for line in zip(*foo)] | 1 | 401 |
instruction | get the count of each unique value in column `Country` of dataframe `df` and store in column `Sum of Accidents` | 0 | 402 |
output | df.Country.value_counts().reset_index(name='Sum of Accidents') | 1 | 402 |
instruction | calculat the difference between each row and the row previous to it in dataframe `data` | 0 | 403 |
output | data.set_index('Date').diff() | 1 | 403 |
instruction | append values `[3, 4]` to a set `a` | 0 | 404 |
output | a.update([3, 4]) | 1 | 404 |
instruction | set every two-stride far element to -1 starting from second element in array `a` | 0 | 405 |
output | a[1::2] = -1 | 1 | 405 |
instruction | Get rank of rows from highest to lowest of dataframe `df`, grouped by value in column `group`, according to value in column `value` | 0 | 406 |
output | df.groupby('group')['value'].rank(ascending=False) | 1 | 406 |
instruction | convert js date object 'Tue, 22 Nov 2011 06:00:00 GMT' to python datetime | 0 | 407 |
output | datetime.strptime('Tue, 22 Nov 2011 06:00:00 GMT', '%a, %d %b %Y %H:%M:%S %Z') | 1 | 407 |
instruction | Convert a binary value '1633837924' to string | 0 | 408 |
output | struct.pack('<I', 1633837924) | 1 | 408 |
instruction | append string `foo` to list `list` | 0 | 409 |
output | list.append('foo') | 1 | 409 |
instruction | insert string `foo` at position `0` of list `list` | 0 | 410 |
output | list.insert(0, 'foo') | 1 | 410 |
instruction | convert keys in dictionary `thedict` into case insensitive | 0 | 411 |
output | theset = set(k.lower() for k in thedict) | 1 | 411 |
instruction | pad 'dog' up to a length of 5 characters with 'x' | 0 | 412 |
output | """{s:{c}^{n}}""".format(s='dog', n=5, c='x') | 1 | 412 |
instruction | check if type of variable `s` is a string | 0 | 413 |
output | isinstance(s, str) | 1 | 413 |
instruction | check if type of a variable `s` is string | 0 | 414 |
output | isinstance(s, str) | 1 | 414 |
instruction | Convert list of dictionaries `L` into a flat dictionary | 0 | 415 |
output | dict(pair for d in L for pair in list(d.items())) | 1 | 415 |
instruction | merge a list of dictionaries in list `L` into a single dict | 0 | 416 |
output | {k: v for d in L for k, v in list(d.items())} | 1 | 416 |
instruction | sort a pandas data frame according to column `Peak` in ascending and `Weeks` in descending order | 0 | 417 |
output | df.sort_values(['Peak', 'Weeks'], ascending=[True, False], inplace=True) | 1 | 417 |
instruction | sort a pandas data frame by column `Peak` in ascending and `Weeks` in descending order | 0 | 418 |
output | df.sort(['Peak', 'Weeks'], ascending=[True, False], inplace=True) | 1 | 418 |
instruction | run the code contained in string "print('Hello')" | 0 | 419 |
output | eval("print('Hello')") | 1 | 419 |
instruction | creating a list of dictionaries [{'A': 1, 'C': 4, 'B': 2, 'D': 4}, {'A': 1, 'C': 4, 'B': 1, 'D': 5}] | 0 | 420 |
output | [{'A': 1, 'C': 4, 'B': 2, 'D': 4}, {'A': 1, 'C': 4, 'B': 1, 'D': 5}] | 1 | 420 |
instruction | null | 0 | 421 |
output | [{'A': 1, 'C': 4, 'B': 2, 'D': 4}, {'A': 1, 'C': 4, 'B': 1, 'D': 5}] | 1 | 421 |
instruction | get all possible combination of items from 2-dimensional list `a` | 0 | 422 |
output | list(itertools.product(*a)) | 1 | 422 |
instruction | Get sum of values of columns 'Y1961', 'Y1962', 'Y1963' after group by on columns "Country" and "Item_code" in dataframe `df`. | 0 | 423 |
output | df.groupby(['Country', 'Item_Code'])[['Y1961', 'Y1962', 'Y1963']].sum() | 1 | 423 |
instruction | create list `done` containing permutations of each element in list `[a, b, c, d]` with variable `x` as tuples | 0 | 424 |
output | done = [(el, x) for el in [a, b, c, d]] | 1 | 424 |
instruction | remove Nan values from array `x` | 0 | 425 |
output | x = x[numpy.logical_not(numpy.isnan(x))] | 1 | 425 |
instruction | remove first directory from path '/First/Second/Third/Fourth/Fifth' | 0 | 426 |
output | os.path.join(*x.split(os.path.sep)[2:]) | 1 | 426 |
instruction | Replace `;` with `:` in a string `line` | 0 | 427 |
output | line = line.replace(';', ':') | 1 | 427 |
instruction | call bash command 'tar c my_dir | md5sum' with pipe | 0 | 428 |
output | subprocess.call('tar c my_dir | md5sum', shell=True) | 1 | 428 |
instruction | Convert a hex string `437c2123 ` according to ascii value. | 0 | 429 |
output | """437c2123""".decode('hex') | 1 | 429 |
instruction | Get a list of all fields in class `User` that are marked `required` | 0 | 430 |
output | [k for k, v in User._fields.items() if v.required] | 1 | 430 |
instruction | remove column by index `[:, 0:2]` in dataframe `df` | 0 | 431 |
output | df = df.ix[:, 0:2] | 1 | 431 |
instruction | change a string of integers `x` separated by spaces to a list of int | 0 | 432 |
output | x = map(int, x.split()) | 1 | 432 |
instruction | convert a string of integers `x` separated by spaces to a list of integers | 0 | 433 |
output | x = [int(i) for i in x.split()] | 1 | 433 |
instruction | find element by css selector "input[onclick*='1 Bedroom Deluxe']" | 0 | 434 |
output | driver.find_element_by_css_selector("input[onclick*='1 Bedroom Deluxe']") | 1 | 434 |
instruction | null | 0 | 435 |
output | re.sub('[^a-zA-Z0-9-_*.]', '', my_string) | 1 | 435 |
instruction | display a pdf file that has been downloaded as `my_pdf.pdf` | 0 | 436 |
output | webbrowser.open('file:///my_pdf.pdf') | 1 | 436 |
instruction | replace backslashes in string `result` with empty string '' | 0 | 437 |
output | result = result.replace('\\', '') | 1 | 437 |
instruction | remove backslashes from string `result` | 0 | 438 |
output | result.replace('\\', '') | 1 | 438 |
instruction | replace value '-' in any column of pandas dataframe to "NaN" | 0 | 439 |
output | df.replace('-', 'NaN') | 1 | 439 |
instruction | convert datetime object to date object in python | 0 | 440 |
output | datetime.datetime.now().date() | 1 | 440 |
instruction | null | 0 | 441 |
output | datetime.datetime.now().date() | 1 | 441 |
instruction | get all sub-elements of an element `a` in an elementtree | 0 | 442 |
output | [elem.tag for elem in a.iter()] | 1 | 442 |
instruction | get all sub-elements of an element tree `a` excluding the root element | 0 | 443 |
output | [elem.tag for elem in a.iter() if elem is not a] | 1 | 443 |
instruction | null | 0 | 444 |
output | """2.7.0_bf4fda703454""".split('_') | 1 | 444 |
instruction | move dictionaries in list `lst` to the end of the list if value of key 'language' in each dictionary is not equal to 'en' | 0 | 445 |
output | sorted(lst, key=lambda x: x['language'] != 'en') | 1 | 445 |
instruction | check if all values of a dictionary `your_dict` are zero `0` | 0 | 446 |
output | all(value == 0 for value in list(your_dict.values())) | 1 | 446 |
instruction | produce a pivot table as dataframe using column 'Y' in datafram `df` to form the axes of the resulting dataframe | 0 | 447 |
output | df.pivot_table('Y', rows='X', cols='X2') | 1 | 447 |
instruction | call `doSomething()` in a try-except without handling the exception | 0 | 448 |
output | try:
doSomething()
except:
pass | 1 | 448 |
instruction | call `doSomething()` in a try-except without handling the exception | 0 | 449 |
output | try:
doSomething()
except Exception:
pass | 1 | 449 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.