text
stringlengths 4
1.08k
|
|---|
How to decode a unicode-like string in Python 3?,"codecs.decode('\\u000D', 'unicode-escape')"
|
"Real time face detection OpenCV, Python","cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)"
|
How to import a module given the full path?,sys.path.append('/foo/bar/mock-0.3.1')
|
hex string to character in python,""""""""""""".join(chr(int(data[i:i + 2], 16)) for i in range(0, len(data), 2))"
|
How to convert a python numpy array to an RGB image with Opencv 2.4?,"cv2.imshow('image', img)"
|
How can I add nothing to the list in list comprehension?,[(2 * x) for x in some_list if x > 2]
|
How to write Unix end of line characters in Windows using Python,"f = open('file.txt', 'wb')"
|
ValueError: setting an array element with a sequence,"numpy.array([1.2, 'abc'], dtype=object)"
|
Django ORM way of going through multiple Many-to-Many relationship,Toy.objects.filter(owner__parent__id=1)
|
How to group DataFrame by a period of time?,"df.groupby([df.index.map(lambda t: t.minute), 'Source'])"
|
Editing the XML texts from a XML file using Python,"open('output.xml', 'wb').write(dom.toxml())"
|
How to split text without spaces into list of words?,"print(find_words('tableprechaun', words=set(['tab', 'table', 'leprechaun'])))"
|
How to generate negative random value in python,"random.uniform(-1, 1)"
|
How to convert dictionary values to int in Python?,"results = sorted(ranks, key=lambda x: int(x['rank'].replace(',', '')))"
|
Explicit line joining in Python,""""""", """""".join(('abc', 'def', 'ghi'))"
|
Python split string in moving window,"[''.join(x) for x in window('7316717', 3)]"
|
How to add group labels for bar charts in matplotlib?,plt.show()
|
How can I find the missing value more concisely?,"z, = set(('a', 'b', 'c')) - set((x, y))"
|
Index confusion in numpy arrays,"B = numpy.array([A[0, 0, 1], A[2, 1, 2]])"
|
How to convert from infix to postfix/prefix using AST python module?,"['x', 'cos']"
|
dump json into yaml,"json.dump(data, outfile, ensure_ascii=False)"
|
Test if an attribute is present in a tag in BeautifulSoup,tags = soup.find_all(lambda tag: tag.has_attr('src'))
|
List of strings to integers while keeping a format in python,data = [[int(i) for i in line.split()] for line in original]
|
How can I fill out a Python string with spaces?,"print(""'%-100s'"" % 'hi')"
|
Count rows that match string and numeric with pandas,df.MUT.str.extract('A:(T)|A:(G)|A:(C)|A:(-)')
|
"Using pandas, how do I subsample a large DataFrame by group in an efficient manner?",subsampled = df.ix[(choice(x) for x in list(grouped.groups.values()))]
|
"Matplotlib subplot title, figure title formatting",plt.show()
|
How to handle delete in Google App Engine (Python),self.response.out.write(key)
|
Plotting time in Python with Matplotlib,plt.show()
|
Iterating through directories with Python,"print(os.path.join(subdir, file))"
|
Crop image with corrected distortion in OpenCV (Python),"img = cv2.imread('Undistorted.jpg', 0)"
|
How to receive json data using HTTP POST request in Django 1.6?,received_json_data = json.loads(request.body.decode('utf-8'))
|
How to create dynamical scoped variables in Python?,greet_selves()
|
Python Spliting a string,"""""""Sico87 is an awful python developer"""""".split(' ')"
|
unique plot marker for each plot in matplotlib,plt.show()
|
How to get an arbitrary element from a frozenset?,[next(iter(s)) for _ in range(10)]
|
List of IP addresses in Python to a list of CIDR,"cidrs = netaddr.ip_range_to_cidrs(ip_start, ip_end)"
|
Making a request to a RESTful API using python,"response = requests.post(url, data=data)"
|
x11 forwarding with paramiko,ssh_client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
|
Numpy: get 1D array as 2D array without reshape,"np.array([1, 2, 3], ndmin=2).T"
|
Get a list of the lowest subdirectories in a tree,"[os.path.split(r)[-1] for r, d, f in os.walk(tree) if not d]"
|
Best way to return a value from a python script,"return [1, 2, 3]"
|
Add second axis to polar plot,"plt.setp(ax.get_yticklabels(), color='darkblue')"
|
How to get column by number in Pandas?,"df1.iloc[[1, 3, 5], [1, 3]]"
|
python max function using 'key' and lambda expression,"max(lis, key=lambda x: x[1])"
|
WTForms: How to select options in SelectMultipleField?,"form = MyForm(myfield=['1', '3'])"
|
Iterating over a dictionary to create a list,"{'Jhonny': 'green', 'Steve': 'blue'}"
|
How to make ordered dictionary from list of lists?,"pprint([OrderedDict(zip(names, subl)) for subl in list_of_lists])"
|
Delete Column in Pandas based on Condition,(df != 0).any(axis=0)
|
How to plot a wav file,plt.show()
|
Convert string to binary in python,""""""" """""".join(map(bin, bytearray(st)))"
|
How can I implement multiple URL parameters in a Tornado route?,tornado.ioloop.IOLoop.instance().start()
|
Convert Columns to String in Pandas,total_rows['ColumnID'] = total_rows['ColumnID'].astype(str)
|
Matplotlib cursor value with two axes,plt.show()
|
Conditional matching in regular expression,"re.findall(rx, st, re.VERBOSE)"
|
passing variables from python to bash shell script via os.system,os.system('echo {0}'.format(probe1))
|
Subset of dictionary keys,{key: data[key] for key in data if not_seen(key.split(':')[0])}
|
Finding maximum of a list of lists by sum of elements in Python,"max(a, key=sum)"
|
How to add title to subplots in Matplotlib?,ax.set_title('Title for first plot')
|
How to flush plots in IPython Notebook sequentially?,plt.show()
|
Label width in tkinter,root.mainloop()
|
Normalizing colors in matplotlib,plt.show()
|
Python 2.7 getting user input and manipulating as string without quotations,testVar = input('Ask user for something.')
|
Array indexing in numpy,"a[([i for i in range(a.shape[0]) if i != 1]), :, :]"
|
Python: How to get multiple variables from a URL in Flask?,"{'a': 'hello', 'b': 'world'}"
|
How do I write to the console in Google App Engine?,logging.debug('hi')
|
Writing to a file in a for loop,myfile.close()
|
How to define a mathematical function in SymPy?,"f.subs(x, 1)"
|
Pairwise crossproduct in Python,"[(x, y) for x in a for y in b]"
|
How to print a pdf file to stdout using python?,sys.stdout.buffer.write(pdf_file.read())
|
Is there a matplotlib equivalent of MATLAB's datacursormode?,"plt.subplot(2, 1, 1)"
|
Create Pandas DataFrame from txt file with specific pattern,"df['Region Name'] = df['Region Name'].str.replace(' \\(.+$', '')"
|
How can I open files in external programs in Python?,webbrowser.open(filename)
|
How to make a Python HTTP Request with POST data and Cookie?,"print(requests.get(url, data=data, cookies=cookies).text)"
|
How to write a regular expression to match a string literal where the escape is a doubling of the quote character?,"""""""'([^']|'')*'"""""""
|
Python Convert Unicode-Hex utf-8 strings to Unicode strings,s.encode('latin-1').decode('utf8')
|
Changing line properties in matplotlib pie chart,plt.rcParams['line.color'] = 'white'
|
Parsing a date in python without using a default,"datetime.datetime(ddd.year, ddd.month, ddd.day)"
|
how to return index of a sorted list?,"sorted(list(range(len(s))), key=lambda k: s[k])"
|
Add legends to LineCollection plot,plt.show()
|
Replace a substring selectively inside a string,"re.sub('\\bdelhi\\b(?=(?:""[^""]*""|[^""])*$)', '', a)"
|
Split string on whitespace in Python,"re.findall('\\S+', s)"
|
How to test if one string is a subsequence of another?,"assert not is_subseq('ca', 'abc')"
|
Twisted server for multiple clients,reactor.run()
|
Getting values from JSON using Python,data['lat']
|
Python pandas: how to run multiple univariate regression by group,"df.grouby('grp').apply(ols_res, ['x1', 'x2'], 'y')"
|
Can a Python method check if it has been called from within itself?,foo()
|
Python BeautifulSoup give multiple tags to findAll,"tags = soup.find_all(['hr', 'strong'])"
|
How do I sort a key:list dictionary by values in list?,"mydict = {'name': ['peter', 'janice', 'andy'], 'age': [10, 30, 15]}"
|
Unable to restore stdout to original (only to terminal),sys.stdout = sys.__stdout__
|
Python numpy: cannot convert datetime64[ns] to datetime64[D] (to use with Numba),testf(df['month_15'].astype('datetime64[D]').values)
|
parsing a complex logical expression in pyparsing in a binary tree fashion,"[[['x', '>', '7'], 'AND', [['x', '<', '8'], 'OR', ['x', '=', '4']]]]"
|
List comprehension without [ ] in Python,[str(n) for n in range(10)]
|
How to update a plot with python and Matplotlib,mpl.use('WXAgg')
|
Using Python to execute a command on every file in a folder,"print(os.path.join(directory, file))"
|
python pandas extract unique dates from time series,df['Date'][0]
|
Defining a discrete colormap for imshow in matplotlib,plt.show()
|
filter items in a python dictionary where keys contain a specific string,"filtered_dict = {k: v for k, v in list(d.items()) if filter_string in k}"
|
Python: How to know if two dictionary have the same keys,set(dic1.keys()) == set(dic2.keys())
|
Parse raw HTTP Headers,print(request.headers['host'])
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.