text
stringlengths 4
1.08k
|
|---|
how to pass dictionary items as function arguments in python?,my_function(**data)
|
how to add a scrollbar to a window with tkinter?,"root.wm_title(""Got Skills' Skill Tracker"")"
|
call external program from python and get its output,"subprocess.check_output(['ls', '-l', '/dev/null'])"
|
beautifulsoup html table parsing,entry = [str(x) for x in cols.findAll(text=True)]
|
make a flat list from list of lists `list2d`,list(itertools.chain(*list2d))
|
complex sorting of a list,"['8:00', '12:30', '1:45', '6:15']"
|
how to get values from a map and set them into a numpy matrix row?,"l = np.array([list(method().values()) for _ in range(1, 11)])"
|
python regex extract vimeo id from url,"re.search('^(http://)?(www\\.)?(vimeo\\.com/)?(\\d+)', embed_url).group(4)"
|
append the sum of each tuple pair in the grouped list `list1` and list `list2` elements to list `list3`,"list3 = [(a + b) for a, b in zip(list1, list2)]"
|
convert black and white array into an image in python?,im = Image.fromarray(my_array)
|
python - how to run multiple coroutines concurrently using asyncio?,asyncio.get_event_loop().run_forever()
|
how to split comma-separated key-value pairs with quoted commas,"{'age': '12', 'name': 'bob', 'hobbies': 'games,reading', 'phrase': ""I'm cool!""}"
|
representing graphs (data structure) in python,"[('A', 'B'), ('B', 'C'), ('B', 'D'), ('C', 'D'), ('E', 'F'), ('F', 'C')]"
|
how to write a cell with multiple columns in xlwt?,"sheet.write(1, 1, 2)"
|
"how to add key,value pair to dictionary?",dictionary[key] = value
|
how do i convert lf to crlf?,"f = open('words.txt', 'rU')"
|
formatting floats in a numpy array,np.random.randn(5) * 10
|
convert numpy array into python list structure,"np.array([[1, 2, 3], [4, 5, 6]]).tolist()"
|
sort dict in jinja2 loop,"sorted(list(league.items()), key=lambda x: x[1]['totalpts'], reverse=True)"
|
static properties in python,mc = MyClass()
|
how to get absolute url in pylons?,"print(url('blog', id=123, qualified=True, host='example.com'))"
|
how to get current date and time from db using sqlalchemy,"print(select([my_table, func.current_date()]).execute())"
|
find max since condition in pandas timeseries dataframe,df['b'].cumsum()
|
how to get if checkbox is checked on flask,value = request.form.getlist('check')
|
"remove all null values from columns 'three', 'four' and 'five' of dataframe `df2`","df2.dropna(subset=['three', 'four', 'five'], how='all')"
|
python's configparser unique keys per section,"[('spam', 'eggs'), ('spam', 'ham')]"
|
how to get the red channel color space of an image?,"img[:, :, (0)] = 0"
|
"i need to securely store a username and password in python, what are my options?","keyring.set_password('system', 'username', 'password')"
|
iterating over a numpy array,"[(x, y) for x, y in numpy.ndindex(a.shape)]"
|
creating an empty list,[]
|
python getting a list of value from list of dict,[d['value'] for d in l if 'value' in d]
|
clear text from textarea with selenium,driver.find_element_by_id('foo').clear()
|
search a list of strings for any sub-string from another list,any(k in s for k in keywords)
|
change string list to list,"ast.literal_eval('[1,2,3]')"
|
assigning values in each column to be the sum of that column,df = pd.DataFrame([df.sum()] * len(df))
|
find first non-zero value in each row of pandas dataframe,"df.replace(0, np.nan).bfill(1).iloc[:, (0)]"
|
how to count the number of letters in a string without the spaces?,sum(c != ' ' for c in word)
|
"python - how do i write a more efficient, pythonic reduce?",a.contains(b)
|
"check whether a file ""/etc"" exists",print(os.path.isfile('/etc'))
|
how do i integrate ajax with django applications?,"url('^home/', 'myapp.views.home'),"
|
python: get key of index in dictionary,"d = {'i': 1, 'j': 1}"
|
how can i import a python module function dynamically?,my_function = __import__('my_apps.views').my_function
|
"make subset of array, based on values of two other arrays in python","c1[np.logical_and(c2 == 2, c3 == 3)]"
|
how to check whether elements appears in the list only once in python?,len(set(a)) == len(a)
|
"how do i get the ""visible"" length of a combining unicode string in python?",wcswidth('\xe1\x84\x80\xe1\x85\xa1\xe1\x86\xa8')
|
is there a way to remove duplicate and continuous words/phrases in a string?,"re.sub('\\b(.+)(\\s+\\1\\b)+', '\\1', s)"
|
python pandas - how to flatten a hierarchical index in columns,df.columns = [' '.join(col).strip() for col in df.columns.values]
|
create a list containing the multiplication of each elements at the same index of list `lista` and list `listb`,"[(a * b) for a, b in zip(lista, listb)]"
|
print a dict sorted by values,"sorted(((v, k) for k, v in d.items()), reverse=True)"
|
"python, format string","""""""{} %s {}"""""".format('foo', 'bar')"
|
pandas changing order of columns after data retrieval,"df = df.rename(columns={'oldName1': 'newName1', 'oldName2': 'newName2'})"
|
list of non-zero elements in a list in python,"[1, 1, 0, 0, 1, 0]"
|
what's a good way to combinate through a set?,list(powerset('abcd'))
|
convert python modules into dll file,sys.path.append('C:\\Path\\To\\Dll')
|
sort list `lst` based on each element's number of occurrences,"sorted(lst, key=lambda x: (-1 * c[x], lst.index(x)))"
|
how to get the length of words in a sentence?,[len(x) for x in s.split()]
|
python(pandas): removing duplicates based on two columns keeping row with max value in another column,"df.sort('C').drop_duplicates(subset=['A', 'B'], take_last=True)"
|
python sorting two lists,"[list(x) for x in zip(*sorted(zip(list1, list2), key=lambda pair: pair[0]))]"
|
"append a list [8, 7] to list `foo`","foo.append([8, 7])"
|
python - how to delete hidden signs from string?,print(repr(the_string))
|
extracting date from a string in python,"dparser.parse('monkey 2010-07-32 love banana', fuzzy=True)"
|
python failing to encode bad unicode to ascii,"s.decode('ascii', 'ignore')"
|
get each value from a list of lists `a` using itertools,print(list(itertools.chain.from_iterable(a)))
|
filtering a pandas dataframe without removing rows,df.where((df > df.shift(1)).values & DataFrame(df.D == 1).values)
|
subprocess.popen with a unicode path,"subprocess.Popen('Pok\xc3\xa9mon.mp3', shell=True)"
|
find all occurrences of a substring in python,"[m.start() for m in re.finditer('test', 'test test test test')]"
|
how to add more headers in websocket python client,"self.sock.connect(self.url, header=self.header)"
|
how can i filter a haystack searchqueryset for none on an integerfield,self.searchqueryset.filter(group__isnull=True)
|
python: how to generate a 12-digit random number?,"int(''.join(str(random.randint(0, 9)) for _ in range(12)))"
|
is there a way to make multiple horizontal boxplots in matplotlib?,plt.show()
|
how can i print the truth value of a variable?,print(bool(a))
|
sort a python list of dictionaries `users` by a given list `order` of ids 'id' with the desired order,users.sort(key=lambda x: order.index(x['id']))
|
python - regex search and findall,"regex = re.compile('((\\d+,)*\\d+)')"
|
convert tuple `tst` to string `tst2`,tst2 = str(tst)
|
reduce left and right margins in matplotlib plot,plt.tight_layout()
|
using regular expression to split string in python,[m[0] for m in re.compile('((.+?)\\2+)').findall('44442(2)2(2)44')]
|
python 3: how to check if an object is a function?,"hasattr(fn, '__call__')"
|
"how to count the repetition of the elements in a list python, django","[('created', 1), ('some', 2), ('here', 2), ('tags', 2)]"
|
"add header 'wwwauthenticate' in a flask app with value 'basic realm=""test""'","response.headers['WWW-Authenticate'] = 'Basic realm=""test""'"
|
regex to get list of all words with specific letters (unicode graphemes),"print(' '.join(get_words(['\u0baa', '\u0bae\u0bcd', '\u0b9f'])))"
|
"replace `0` with `2` in the list `[0, 1, 0, 3]`","[(a if a else 2) for a in [0, 1, 0, 3]]"
|
first non-null value per row from a list of pandas columns,df.stack()
|
how to declare an array in python,[0] * 10000
|
how to get tuples from lists using list comprehension in python,"[(x, lst2[i]) for i, x in enumerate(lst)]"
|
how do i insert a column at a specific column index in pandas?,"df.insert(idx, col_name, value)"
|
python/matplotlib - is there a way to make a discontinuous axis?,"plt.figure(figsize=(10, 8))"
|
"python, add items from txt file into a list",names = [line.strip() for line in open('names.txt')]
|
motif search with gibbs sampler,Motifs.append(Motif)
|
from tuples to multiple columns in pandas,"df = df.drop('location', axis=1)"
|
execute command 'echo $0' in z shell,"os.system(""zsh -c 'echo $0'"")"
|
move x-axis of the pyplot object `ax` to the top of a plot in matplotlib,ax.xaxis.set_ticks_position('top')
|
encoding binary data in flask/jinja2,entry['image'] = entry['image'].encode('base64')
|
how can i display a np.array with pylab.imshow(),plt.show()
|
how to get nested-groups with regexp,"re.findall('\\[ (?:[^][]* \\[ [^][]* \\])* [^][]* \\]', s, re.X)"
|
how to input an integer tuple from user?,"tuple(map(int, input().split(',')))"
|
add tuple to a list of tuples,"c = [[(i + j) for i, j in zip(e, b)] for e in a]"
|
transform unicode string in python,"data['City'].encode('ascii', 'ignore')"
|
configuration file with list of key-value pairs in python,"config = {'name': 'hello', 'see?': 'world'}"
|
control a print format when printing a list in python,print([('%5.3f' % val) for val in l])
|
creating a dictionary from an iterable,"x = dict(zip(list(range(0, 10)), itertools.repeat(0)))"
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.