text
stringlengths 4
1.08k
|
|---|
how do i insert a list at the front of another list?,a[0:0] = k
|
remove colon character surrounded by vowels letters in string `word`,"word = re.sub('([aeiou]):(([aeiou][^aeiou]*){3})$', '\\1\\2', word)"
|
python/regex - expansion of parentheses and slashes,"['1', '15', '-23', '-23', '15', '4']"
|
convert a list of tuples `queryresult` to a string from the first indexes.,emaillist = '\n'.join([item[0] for item in queryresult])
|
how to append new data onto a new line,hs.write('{}\n'.format(name))
|
generate a sequence of numbers in python,""""""","""""".join('{},{}'.format(i, i + 1) for i in range(1, 100, 4))"
|
sorting a defaultdict by value in python,"sorted(list(d.items()), key=lambda k_v: k_v[1])"
|
python list comprehension double for,[line for line in file if not line.startswith('#')]
|
python subprocess with gzip,p.stdin.close()
|
list comprehensions in python : efficient selection in a list,(f(x) for x in list)
|
convert a string `s` containing a decimal to an integer,int(Decimal(s))
|
convert decimal `8` to binary list,[int(x) for x in bin(8)[2:]]
|
"django,fastcgi: how to manage a long running process?",sys.stdout.flush()
|
matplotlib fill beetwen multiple lines,plt.show()
|
convert string of bytes `y\xcc\xa6\xbb` into an int,"struct.unpack('<L', 'y\xcc\xa6\xbb')[0]"
|
python pandas - date column to column index,df.set_index('b')
|
how to use a dot in python format strings?,"""""""Hello {user[name]}"""""".format(**{'user': {'name': 'Markus'}})"
|
matplotlib: no effect of set_data in imshow for the plot,plt.show()
|
combining numpy arrays,"b = np.concatenate((a, a), axis=0)"
|
get relative path of path '/usr/var' regarding path '/usr/var/log/',"print(os.path.relpath('/usr/var/log/', '/usr/var'))"
|
get indexes of all true boolean values from a list `bool_list`,"[i for i, elem in enumerate(bool_list, 1) if elem]"
|
create a list containing the subtraction of each item in list `l` from the item prior to it,"[(y - x) for x, y in zip(L, L[1:])]"
|
sort pandas dataframe by date,df.sort_values(by='Date')
|
python pandas: how to get the row names from index of a dataframe?,df.index
|
how to pass pointer to an array in python for a wrapped c++ function,"AAF(10, [4, 5.5, 10], [1, 1, 2], 3)"
|
2d array of zeros,zeros = [([0] * M) for _ in range(N)]
|
sort a part of a list in place,a[i:j].sort()
|
reference to part of list - python,"[0, 1, 0, 1, 2, 5, 6, 7, 8, 9]"
|
separation of business logic and data access in django,User.objects.filter(active=True)
|
how do i remove identical items from a list and sort it in python?,"['a', 'b', 'c', 'd', 'e', 'f']"
|
pandas groupby where all columns are added to a list prefixed by column name,df.groupby('id1').apply(func)
|
sort a list of strings `strings` based on regex match,"strings.sort(key=lambda str: re.sub('.*%', '', str))"
|
check if any element of list `substring_list` are in string `string`,any(substring in string for substring in substring_list)
|
how to search a list of tuples in python,"[i for i, v in enumerate(L) if v[0] == 53]"
|
python nested list comprehension with two lists,[(x + y) for x in l2 for y in l1]
|
pyodbc insert into sql,cnxn.commit()
|
averaging over every n elements of a numpy array,"np.mean(arr.reshape(-1, 3), axis=1)"
|
sort n-d numpy array by column with a smaller n-d array,"a[(np.arange(a.shape[0])[:, (None)]), :, (b2)].transpose(0, 2, 1)"
|
"iterate over a python dictionary, ordered by values","sorted(list(dictionary.items()), key=lambda x: x[1])"
|
send cookies `cookie` in a post request to url 'http://wikipedia.org' with the python requests library,"r = requests.post('http://wikipedia.org', cookies=cookie)"
|
django filter with regex,"""""""^[a-zA-Z]+/$"""""""
|
numpy - efficient conversion from tuple to array?,"np.array(x).reshape(2, 2, 4)"
|
how to find the minimum value in a numpy matrix?,arr[arr != 0].min()
|
python most common element in a list,"print(most_common(['goose', 'duck', 'duck', 'goose']))"
|
how to determine the order of bars in a matplotlib bar chart,df.ix[list('CADFEB')].plot(kind='barh')
|
reading in integer from stdin in python,bin('10')
|
python - compress ascii string,comptest('This is a compression test of a short sentence.')
|
split a string `a` with new line character,a.split('\n')[:-1]
|
list comprehension with if statement,[y for y in a if y not in b]
|
how to read user input until eof?,input_str = sys.stdin.read()
|
typeerror: split() takes no keyword arguments,"str.split('&', 8)"
|
converting numpy array into python list structure?,"np.array([[1, 2, 3], [4, 5, 6]]).tolist()"
|
how do i tell a file from directory in python?,"current, dirs, files = next(os.walk('/path'))"
|
efficient way to create strings from a list,"list(product(['Long', 'Med'], ['Yes', 'No']))"
|
accessing columns with multiindex after using pandas groupby,"g1.columns = ['agd_mean', 'agd_std', 'hgd_mean', 'hgd_std']"
|
removing one list from another,[x for x in a if x not in b]
|
append string `foo` to list `list`,list.append('foo')
|
how do i reverse a part (slice) of a list in python?,b = a[:]
|
slicing a list into a list of sub-lists,"list(grouper(2, [1, 2, 3, 4, 5, 6, 7]))"
|
convert average of python list values to another list,"{'Mike': [[1, 4], [5, 7]], 'Joe': [[5, 7], [6, 9], [7, 4]]}"
|
matplotlib plot pulse propagation in 3d,"drawPropagation(1.0, 1.0, numpy.linspace(-2, 2, 10))"
|
django: how do i get the model a model inherits from?,list(StreetCat._meta.parents.keys())[-1]
|
using cumsum in pandas on group(),"data1.groupby(['Bool', 'Dir']).apply(lambda x: x['Data'].cumsum())"
|
save json outputed from a url to a file,"urllib.request.urlretrieve('http://search.twitter.com/search.json?q=hi', 'hi.json')"
|
rearrange tuple of tuples `t`,tuple(zip(*t))
|
changing the options of a optionmenu when clicking a button,root.mainloop()
|
python: get the first character of a the first string in a list?,mylist[0][:1]
|
how can i get an array of alternating values in python?,"np.resize([1, -1], 11)"
|
"how to use ""raise"" keyword in python",raise Exception('My error!')
|
how do i autosize text in matplotlib python?,plt.plot(list(range(10)))
|
convert a ip to hex by python,"hex(8).replace('0x', '')"
|
is it possible to have a vertical-oriented button in tkinter?,main.mainloop()
|
getting every possible combination in a list,"['cat_dog', 'cat_fish', 'dog_fish']"
|
how to stop python from propagating signals to subprocesses?,time.sleep(1)
|
trying to count words in a string,print({word: word_list.count(word) for word in word_list})
|
how to convert decimal string in python to a number?,float('1.03')
|
find and replace string values in python list,"words = [word.replace('[br]', '<br />') for word in words]"
|
how can i get all the plain text from a website with scrapy?,""""""""""""".join(sel.select('//body//text()').extract()).strip()"
|
how to generate xml documents with namespaces in python,print(doc.toprettyxml())
|
sort a numpy array like a table,"a[np.argsort(a[:, (1)])]"
|
how do i calculate the md5 checksum of a file in python?,hashlib.md5('filename.exe').hexdigest()
|
how do i get the modified date/time of a file in python?,os.path.getmtime(filepath)
|
how to set same color for markers and lines in a matplotlib plot loop?,plt.savefig('test.png')
|
"building full path filename in python,","os.path.join(dir_name, '.'.join((base_filename, filename_suffix)))"
|
best way to remove elements from a list,[item for item in my_list if some_condition()]
|
how to sort a list of strings with a different order?,lst.sort()
|
how to vectorise pandas calculation that is based on last x rows of data,df.shift(365).rolling(10).B.mean()
|
python: get values (objects) from a dictionary of objects in which one of the object's field matches a value (or condition),"mySubList = [dict((k, v) for k, v in myDict.items() if v.field2 >= 2)]"
|
make a row-by-row copy `y` of array `x`,y = [row[:] for row in x]
|
how to modify a variable inside a lambda function?,"lambda a, b: a + b"
|
merge sorted lists in python,"sorted(itertools.chain(args), cmp)"
|
matplotlib plot pulse propagation in 3d,"ax.plot_wireframe(T, z, abs(U), cstride=1000)"
|
how do i sort a key:list dictionary by values in list?,"{'name': [p['name'] for p in persons], 'age': [p['age'] for p in persons]}"
|
from a list of lists to a dictionary,{l[1]: l for l in lol}
|
count the number of trailing question marks in string `my_text`,len(my_text) - len(my_text.rstrip('?'))
|
get the immediate minimum among a list of numbers in python,min([x for x in num_list if x > 2])
|
pythonic way to eval all octal values in a string as integers,"re.sub('\\b0+(?!\\b)', '', '012+2+0-01+204-0')"
|
how to format a json text in python?,json_data = json.loads(json_string)
|
how to i load a tsv file into a pandas dataframe?,"DataFrame.from_csv('c:/~/trainSetRel3.txt', sep='\t', header=0)"
|
python data structure sort list alphabetically,"sorted(lst, key=str.lower)"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.