rewritten_intent
stringlengths 4
183
⌀ | question_id
int64 1.48k
42.8M
| snippet
stringlengths 2
232
| intent
stringlengths 11
122
|
---|---|---|---|
Concatenate elements of a list 'x' of multiple integers to a single integer | 41,067,960 | sum(d * 10 ** i for i, d in enumerate(x[::-1])) | How to convert a list of multiple integers into a single integer? |
convert a list of integers into a single integer | 41,067,960 | r = int(''.join(map(str, x))) | How to convert a list of multiple integers into a single integer? |
convert a DateTime string back to a DateTime object of format '%Y-%m-%d %H:%M:%S.%f' | 4,170,655 | datetime.strptime('2010-11-13 10:33:54.227806', '%Y-%m-%d %H:%M:%S.%f') | how to convert a datetime string back to datetime object? |
get the average of a list values for each key in dictionary `d`) | 29,565,452 | [(i, sum(j) / len(j)) for i, j in list(d.items())] | Averaging the values in a dictionary based on the key |
zip two lists `[1, 2]` and `[3, 4]` into a list of two tuples containing elements at the same index in each list | 13,704,860 | zip([1, 2], [3, 4]) | zip lists in python |
prepend string 'hello' to all items in list 'a' | 13,331,419 | ['hello{0}'.format(i) for i in a] | Prepend the same string to all items in a list |
regex for repeating words in a string `s` | 25,474,338 | re.sub('(?<!\\S)((\\S+)(?:\\s+\\2))(?:\\s+\\2)+(?!\\S)', '\\1', s) | regex for repeating words in a string in Python |
normalize a pandas dataframe `df` by row | 18,594,469 | df.div(df.sum(axis=1), axis=0) | Normalizing a pandas DataFrame by row |
swap values in a tuple/list inside a list `mylist` | 13,384,841 | map(lambda t: (t[1], t[0]), mylist) | swap values in a tuple/list inside a list in python? |
Swap values in a tuple/list in list `mylist` | 13,384,841 | [(t[1], t[0]) for t in mylist] | swap values in a tuple/list inside a list in python? |
null | 23,887,592 | driver.find_element_by_xpath("//p[@id, 'one']/following-sibling::p") | Find next sibling element in Python Selenium? |
find all occurrences of the pattern '\\[[^\\]]*\\]|\\([^\\)]*\\)|"[^"]*"|\\S+' within `strs` | 17,352,321 | re.findall('\\[[^\\]]*\\]|\\([^\\)]*\\)|"[^"]*"|\\S+', strs) | Python splitting string by parentheses |
generate the combinations of 3 from a set `{1, 2, 3, 4}` | 10,115,967 | print(list(itertools.combinations({1, 2, 3, 4}, 3))) | What's the most memory efficient way to generate the combinations of a set in python? |
add multiple columns `hour`, `weekday`, `weeknum` to pandas data frame `df` from lambda function `lambdafunc` | 30,026,815 | df[['hour', 'weekday', 'weeknum']] = df.apply(lambdafunc, axis=1) | Add Multiple Columns to Pandas Dataframe from Function |
BeautifulSoup search string 'Elsie' inside tag 'a' | 31,958,637 | soup.find_all('a', string='Elsie') | BeautifulSoup - search by text inside a tag |
Convert a datetime object `my_datetime` into readable format `%B %d, %Y` | 2,158,347 | my_datetime.strftime('%B %d, %Y') | How do I turn a python datetime into a string, with readable format date? |
parse string `s` to int when string contains a number | 17,888,152 | int(''.join(c for c in s if c.isdigit())) | Parse string to int when string contains a number + extra characters |
add dictionary `{'class': {'section': 5}}` to key 'Test' of dictionary `dic` | 37,855,490 | dic['Test'].update({'class': {'section': 5}}) | adding new key inside a new key and assigning value in python dictionary |
transforming the string `s` into dictionary | 4,127,344 | dict(map(int, x.split(':')) for x in s.split(',')) | Transforming the string representation of a dictionary into a real dictionary |
null | 19,035,186 | driver.find_element_by_xpath("//div[@id='a']//a[@class='click']") | How to select element with Selenium Python xpath |
find rows matching `(0,1)` in a 2 dimensional numpy array `vals` | 25,823,608 | np.where((vals == (0, 1)).all(axis=1)) | Find matching rows in 2 dimensional numpy array |
null | 3,805,958 | SomeModel.objects.filter(id=id).delete() | How to delete a record in Django models? |
build a dictionary containing the conversion of each list in list `[['two', 2], ['one', 1]]` to a key/value pair as its items | 6,900,955 | dict([['two', 2], ['one', 1]]) | python convert list to dictionary |
convert list `l` to dictionary having each two adjacent elements as key/value pair | 6,900,955 | dict(zip(l[::2], l[1::2])) | python convert list to dictionary |
assign float 9.8 to variable `GRAVITY` | 18,224,991 | GRAVITY = 9.8 | how to set global const variables in python |
separate numbers from characters in string "30m1000n20m" | 15,103,484 | re.findall('(([0-9]+)([A-Z]))', '20M10000N80M') | How to use regular expression to separate numbers and characters in strings like "30M1000N20M" |
separate numbers and characters in string '20M10000N80M' | 15,103,484 | re.findall('([0-9]+|[A-Z])', '20M10000N80M') | How to use regular expression to separate numbers and characters in strings like "30M1000N20M" |
separate numbers and characters in string '20M10000N80M' | 15,103,484 | re.findall('([0-9]+)([A-Z])', '20M10000N80M') | How to use regular expression to separate numbers and characters in strings like "30M1000N20M" |
Get a list of words from a string `Hello world, my name is...James the 2nd!` removing punctuation | 7,633,274 | re.compile('\\w+').findall('Hello world, my name is...James the 2nd!') | Extracting words from a string, removing punctuation and returning a list with separated words in Python |
Convert string '03:55' into datetime.time object | 14,295,673 | datetime.datetime.strptime('03:55', '%H:%M').time() | Convert string into datetime.time object |
request url 'https://www.reporo.com/' without verifying SSL certificates | 28,667,684 | requests.get('https://www.reporo.com/', verify=False) | Python Requests getting SSLerror |
Extract values not equal to 0 from numpy array `a` | 5,927,180 | a[a != 0] | removing data from a numpy.array |
map two lists `keys` and `values` into a dictionary | 209,840 | new_dict = {k: v for k, v in zip(keys, values)} | Map two lists into a dictionary in Python |
map two lists `keys` and `values` into a dictionary | 209,840 | dict((k, v) for k, v in zip(keys, values)) | Map two lists into a dictionary in Python |
map two lists `keys` and `values` into a dictionary | 209,840 | dict([(k, v) for k, v in zip(keys, values)]) | Map two lists into a dictionary in Python |
find the string matches within parenthesis from a string `s` using regex | 8,569,201 | m = re.search('\\[(\\w+)\\]', s) | Get the string within brackets in Python |
Enable the SO_REUSEADDR socket option in socket object `s` to fix the error `only one usage of each socket address is normally permitted` | 12,362,542 | s.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1) | Python server "Only one usage of each socket address is normally permitted" |
append the sum of each tuple pair in the grouped list `list1` and list `list2` elements to list `list3` | 11,703,064 | list3 = [(a + b) for a, b in zip(list1, list2)] | How do i add two lists' elements into one list? |
converting hex string `s` to its integer representations | 7,595,148 | [ord(c) for c in s.decode('hex')] | Python - Converting Hex to INT/CHAR |
sort list `student_tuples` by second element of each tuple in ascending and third element of each tuple in descending | 16,537,636 | print(sorted(student_tuples, key=lambda t: (-t[2], t[0]))) | How to sort in decreasing value first then increasing in second value |
get list of duplicated elements in range of 3 | 3,925,465 | [y for x in range(3) for y in [x, x]] | Repeating elements in list comprehension |
read the contents of the file 'file.txt' into `txt` | 3,278,850 | txt = open('file.txt').read() | Doc, rtf and txt reader in python |
divide each element in list `myList` by integer `myInt` | 8,244,915 | myList[:] = [(x / myInt) for x in myList] | How do you divide each element in a list by an int? |
null | 7,934,620 | """Name: {0[person.name]}""".format({'person.name': 'Joe'}) | python: dots in the name of variable in a format string |
replace white spaces in dataframe `df` with '_' | 42,462,530 | df.replace(' ', '_', regex=True) | How to replace the white space in a string in a pandas dataframe? |
convert date `my_date` to datetime | 15,661,013 | datetime.datetime.combine(my_date, datetime.time.min) | Python: most efficient way to convert date to datetime |
convert tuple `tst` to string `tst2` | 3,886,669 | tst2 = str(tst) | Tuple to string |
get modified time of file `file` | 237,079 | time.ctime(os.path.getmtime(file)) | get file creation & modification date/times in |
get creation time of file `file` | 237,079 | time.ctime(os.path.getctime(file)) | get file creation & modification date/times in |
get modification time of file `filename` | 237,079 | t = os.path.getmtime(filename) | get file creation & modification date/times in |
get modification time of file `path` | 237,079 | os.path.getmtime(path) | get file creation & modification date/times in |
get modified time of file `file` | 237,079 | print(('last modified: %s' % time.ctime(os.path.getmtime(file)))) | get file creation & modification date/times in |
get the creation time of file `file` | 237,079 | print(('created: %s' % time.ctime(os.path.getctime(file)))) | get file creation & modification date/times in |
get the creation time of file `path_to_file` | 237,079 | return os.path.getctime(path_to_file) | get file creation & modification date/times in |
execute os command ''TASKKILL /F /IM firefox.exe'' | 5,625,524 | os.system('TASKKILL /F /IM firefox.exe') | How to Close a program using python? |
split string `string` on whitespaces using a generator | 3,862,010 | return (x.group(0) for x in re.finditer("[A-Za-z']+", string)) | Is there a generator version of `string.split()` in Python? |
Unpack each value in list `x` to its placeholder '%' in string '%.2f' | 7,568,627 | """, """.join(['%.2f'] * len(x)) | Using Python String Formatting with Lists |
match regex pattern '(\\d+(\\.\\d+)?)' with string '3434.35353' | 9,891,814 | print(re.match('(\\d+(\\.\\d+)?)', '3434.35353').group(1)) | How to use regex with optional characters in python? |
replace parentheses and all data within it with empty string '' in column 'name' of dataframe `df` | 20,894,525 | df['name'].str.replace('\\(.*\\)', '') | How to remove parentheses and all data within using Pandas/Python? |
create a list `result` containing elements form list `list_a` if first element of list `list_a` is in list `list_b` | 18,448,469 | result = [x for x in list_a if x[0] in list_b] | Python: filter list of list with another list |
generate all possible string permutations of each two elements in list `['hel', 'lo', 'bye']` | 4,059,550 | print([''.join(a) for a in combinations(['hel', 'lo', 'bye'], 2)]) | Generate all possible strings from a list of token |
get a list of items form nested list `li` where third element of each item contains string 'ar' | 6,889,785 | [x for x in li if 'ar' in x[2]] | python how to search an item in a nested list |
Sort lists in the list `unsorted_list` by the element at index 3 of each list | 17,555,218 | unsorted_list.sort(key=lambda x: x[3]) | Python - How to sort a list of lists by the fourth element in each list? |
Log message 'test' on the root logger. | 18,292,500 | logging.info('test') | Python logging typeerror |
Return a subplot axes positioned by the grid definition `1,1,1` using matpotlib | 1,358,977 | fig.add_subplot(1, 1, 1) | How to make several plots on a single page using matplotlib? |
Sort dictionary `x` by value in ascending order | 613,183 | sorted(list(x.items()), key=operator.itemgetter(1)) | Sort a Python dictionary by value |
Sort dictionary `dict1` by value in ascending order | 613,183 | sorted(dict1, key=dict1.get) | Sort a Python dictionary by value |
Sort dictionary `d` by value in descending order | 613,183 | sorted(d, key=d.get, reverse=True) | Sort a Python dictionary by value |
Sort dictionary `d` by value in ascending order | 613,183 | sorted(list(d.items()), key=(lambda x: x[1])) | Sort a Python dictionary by value |
elementwise product of 3d arrays `A` and `B` | 31,957,364 | np.einsum('ijk,ikl->ijl', A, B) | Numpy elementwise product of 3d array |
Print a string `card` with string formatting | 14,041,791 | print('I have: {0.price}'.format(card)) | print variable and a string in python |
Write a comment `# Data for Class A\n` to a file object `f` | 30,994,370 | f.write('# Data for Class A\n') | How can I add a comment to a YAML file in Python |
move the last item in list `a` to the beginning | 6,490,560 | a = a[-1:] + a[:-1] | How do I move the last item in a list to the front in python? |
Parse DateTime object `datetimevariable` using format '%Y-%m-%d' | 40,173,569 | datetimevariable.strftime('%Y-%m-%d') | python - convert datetime to varchar/string |
Normalize line ends in a string 'mixed' | 1,749,466 | mixed.replace('\r\n', '\n').replace('\r', '\n') | What's the most pythonic way of normalizing lineends in a string? |
find the real user home directory using python | 2,668,909 | os.path.expanduser('~user') | How to find the real user home directory using python? |
index a list `L` with another list `Idx` | 1,012,185 | T = [L[i] for i in Idx] | In Python, how do I index a list with another list? |
get a list of words `words` of a file 'myfile' | 7,745,260 | words = open('myfile').read().split() | Iterate through words of a file in Python |
Get a list of lists with summing the values of the second element from each list of lists `data` | 37,619,348 | [[sum([x[1] for x in i])] for i in data] | Summing 2nd list items in a list of lists of lists |
summing the second item in a list of lists of lists | 37,619,348 | [sum([x[1] for x in i]) for i in data] | Summing 2nd list items in a list of lists of lists |
sort objects in `Articles` in descending order of counts of `likes` | 35,097,130 | Article.objects.annotate(like_count=Count('likes')).order_by('-like_count') | Django order by highest number of likes |
return a DateTime object with the current UTC date | 27,587,127 | today = datetime.datetime.utcnow().date() | How to convert datetime.date.today() to UTC time? |
create a list containing the multiplication of each elements at the same index of list `lista` and list `listb` | 10,271,484 | [(a * b) for a, b in zip(lista, listb)] | How to perform element-wise multiplication of two lists in Python? |
fetch smilies matching regex pattern '(?::|;|=)(?:-)?(?:\\)|\\(|D|P)' in string `s` | 14,571,103 | re.findall('(?::|;|=)(?:-)?(?:\\)|\\(|D|P)', s) | Capturing emoticons using regular expression in python |
match the pattern '[:;][)(](?![)(])' to the string `str` | 14,571,103 | re.match('[:;][)(](?![)(])', str) | Capturing emoticons using regular expression in python |
convert a list of objects `list_name` to json string `json_string` | 26,033,239 | json_string = json.dumps([ob.__dict__ for ob in list_name]) | List of objects to JSON with Python |
create a list `listofzeros` of `n` zeros | 8,528,178 | listofzeros = [0] * n | List of zeros in python |
decode the string 'stringnamehere' to UTF-8 | 4,182,603 | stringnamehere.decode('utf-8', 'ignore') | python: how to convert a string to utf-8 |
Match regex pattern '((?:A|B|C)D)' on string 'BDE' | 11,985,628 | re.findall('((?:A|B|C)D)', 'BDE') | Python regex - Ignore parenthesis as indexing? |
Create a key `key` if it does not exist in dict `dic` and append element `value` to value. | 12,905,999 | dic.setdefault(key, []).append(value) | Python dict how to create key or append an element to key? |
Get the value of the minimum element in the second column of array `a` | 14,956,683 | a[np.argmin(a[:, (1)])] | Finding the minimum value in a numpy array and the corresponding values for the rest of that array's row |
extend dictionary `a` with key/value pairs of dictionary `b` | 577,234 | a.update(b) | Python "extend" for a dictionary |
removing key values pairs with key 'mykey1' from a list of dictionaries `mylist` | 13,254,241 | [{k: v for k, v in d.items() if k != 'mykey1'} for d in mylist] | Removing key values pairs from a list of dictionaries |
null | 13,254,241 | [dict((k, v) for k, v in d.items() if k != 'mykey1') for d in mylist] | Removing key values pairs from a list of dictionaries |
create 3 by 3 matrix of random numbers | 15,451,958 | numpy.random.random((3, 3)) | Simple way to create matrix of random numbers |
make new column 'C' in panda dataframe by adding values from other columns 'A' and 'B' | 34,023,918 | df['C'] = df['A'] + df['B'] | Make new column in Panda dataframe by adding values from other columns |
create a list of values from the dictionary `programs` that have a key with a case insensitive match to 'new york' | 10,484,261 | [value for key, value in list(programs.items()) if 'new york' in key.lower()] | Find dictionary items whose key matches a substring |
append a path `/path/to/main_folder` in system path | 9,153,527 | sys.path.append('/path/to/main_folder') | Import module in another directory from a "parallel" sub-directory |
get all digits in a string `s` after a '[' character | 34,338,341 | re.findall('\\d+(?=[^[]+$)', s) | Regex for getting all digits in a string after a character |
python pickle/unpickle a list to/from a file 'afile' | 18,229,082 | pickle.load(open('afile', 'rb')) | Python pickle/unpickle a list to/from a file |
End of preview. Expand
in Dataset Viewer.
YAML Metadata
Warning:
empty or missing yaml metadata in repo card
(https://huggingface.co/docs/hub/datasets-cards)
Dataset from: https://conala-corpus.github.io/
Uploaded here for easy remote access.
To access in google colaboratory:
!pip install datasets
from datasets import load_dataset
import pandas as pd
train = load_dataset('json', data_files='https://huggingface.co/datasets/janrauhl/conala/resolve/main/conala-train.json')
test = load_dataset('json', data_files='https://huggingface.co/datasets/janrauhl/conala/resolve/main/conala-test.json')
train = train['train'].to_pandas()
test = test['train'].to_pandas()
- Downloads last month
- 3