title stringlengths 10 172 | question_id int64 469 40.1M | question_body stringlengths 22 48.2k | question_score int64 -44 5.52k | question_date stringlengths 20 20 | answer_id int64 497 40.1M | answer_body stringlengths 18 33.9k | answer_score int64 -38 8.38k | answer_date stringlengths 20 20 | tags list |
|---|---|---|---|---|---|---|---|---|---|
/n in beautiful soup text | 39,322,134 | <p>I'm trying to get the transcript for a youtube video for some NLP work, and I think I can get it fine, but there are also a couple of issues. For example: </p>
<pre><code>from xml.etree import cElementTree as ET
from bs4 import BeautifulSoup as bs
from urllib2 import urlopen
URL = 'http://video.google.com/timedt... | 2 | 2016-09-04T22:47:12Z | 39,322,217 | <p>&#39 - is unescaped HTML code , in <strong>python 3.2</strong> and above use </p>
<pre><code>import html
html.unescape(<your_string>)
</code></pre>
| 1 | 2016-09-04T23:05:32Z | [
"python",
"beautifulsoup"
] |
/n in beautiful soup text | 39,322,134 | <p>I'm trying to get the transcript for a youtube video for some NLP work, and I think I can get it fine, but there are also a couple of issues. For example: </p>
<pre><code>from xml.etree import cElementTree as ET
from bs4 import BeautifulSoup as bs
from urllib2 import urlopen
URL = 'http://video.google.com/timedt... | 2 | 2016-09-04T22:47:12Z | 39,322,569 | <p>The <code>\n</code> are newlines which you will have to manually replace if you don't want them, the <a href="http://www.w3schools.com/html/html_entities.asp">html entities</a> can be unescaped with <a href="https://docs.python.org/2/library/htmlparser.html">HTMLParser</a> using python2 or <a href="http://import%20... | 5 | 2016-09-05T00:16:57Z | [
"python",
"beautifulsoup"
] |
Python GTK: Add a button to a GUI with another button | 39,322,137 | <p>I'm trying to add another button to my GUI by pressing a button on the GUI itself. Essentially I'm just trying to update it but I'm relatively new to OOP so I'm having issues with scope. </p>
<p>This is what I have so far...</p>
<pre><code> 1 #!/usr/bin/env python
2 import random, gi, sys
3 from gi.repository... | 0 | 2016-09-04T22:48:02Z | 39,322,649 | <p>Define an <a href="https://docs.python.org/3/tutorial/classes.html#class-and-instance-variables" rel="nofollow">instance variable</a> in your <code>MyWindow</code> class to keep track of that button. </p>
<p>For example, in your code, whenever you see a <code>draw_button</code> change it to <code>self.draw_button</... | 1 | 2016-09-05T00:35:02Z | [
"python",
"oop",
"gtk"
] |
compare two results (of many) from api data with django/python | 39,322,150 | <p>I'm learning django/python/css/etc... and while doing this, I've decided to build an app for my website that can pull simple movie data from TMDb. What I'm having trouble with is figuring out a way to add a way for the <strong>user to select two different movies, and once selected, see the differences between them (... | 0 | 2016-09-04T22:51:17Z | 39,482,880 | <p>Assuming you want to be able to add movies from different searches (e.g. search for rambo, add rambo, search for south park, add south park), you can probably do something like:</p>
<pre><code>@require_POST
def save_compare(request, pk):
""" Async endpoint to add movies to comparison list """
movies = req... | 0 | 2016-09-14T05:11:58Z | [
"javascript",
"python",
"html",
"django"
] |
What is the most effective method of storing and recalling data? | 39,322,242 | <p>I've been wanting to build a pretty big project which pretty much mimics Twitter, I've just started it and have run into a little error with account creation. I was wondering what the best method of storing and recalling data is. I'm well aware I can use .txt files to do this, but then I've found it's trickier to ma... | 0 | 2016-09-04T23:11:02Z | 39,322,289 | <p>Connecting to a database is really the way to go here. This gets deep pretty fast, but as far as handling the python sytax it's fairly straightforward. This answer handles that subject well:</p>
<p><a href="http://stackoverflow.com/questions/372885/how-do-i-connect-to-a-mysql-database-in-python">How do I connect to... | 0 | 2016-09-04T23:19:40Z | [
"python",
"database",
"import",
"export"
] |
What is the most effective method of storing and recalling data? | 39,322,242 | <p>I've been wanting to build a pretty big project which pretty much mimics Twitter, I've just started it and have run into a little error with account creation. I was wondering what the best method of storing and recalling data is. I'm well aware I can use .txt files to do this, but then I've found it's trickier to ma... | 0 | 2016-09-04T23:11:02Z | 39,322,365 | <p>Your expectations of Python are very low. That is great news because you are going to be very happy.</p>
<p>You can definitely use a database with Python. The simplest and quickest to set up as well as closest to what you described is a file database: SQLite. <a href="http://zetcode.com/db/sqlitepythontutorial/" re... | 1 | 2016-09-04T23:31:35Z | [
"python",
"database",
"import",
"export"
] |
What is the most effective method of storing and recalling data? | 39,322,242 | <p>I've been wanting to build a pretty big project which pretty much mimics Twitter, I've just started it and have run into a little error with account creation. I was wondering what the best method of storing and recalling data is. I'm well aware I can use .txt files to do this, but then I've found it's trickier to ma... | 0 | 2016-09-04T23:11:02Z | 39,322,378 | <p>Use SQLite or any other RDBMS like PostgreSQL.
To use Python with RDBMS:
<a href="https://wiki.python.org/moin/DatabaseInterfaces" rel="nofollow">https://wiki.python.org/moin/DatabaseInterfaces</a></p>
| 0 | 2016-09-04T23:34:55Z | [
"python",
"database",
"import",
"export"
] |
Execute and create one python script from another | 39,322,308 | <p>Suppose, I have a python script <code>test1.py</code> , executing of <code>test1.py</code> will create a copy of that file, let's say <code>test2.py</code> . Now, I want to run <code>test1.py</code> in such a way that first it will create <code>test2.py</code> and then will execute <code>test2.py</code> . </p>
<p>T... | 0 | 2016-09-04T23:22:33Z | 39,322,356 | <p>Run python with <code>test2.py</code> as it's first argument.</p>
<pre><code>os.system("python test2.py")
</code></pre>
<p>If you say what's your goal of this action. We can help you better.</p>
| 1 | 2016-09-04T23:30:59Z | [
"python"
] |
tf.train.shuffle_batch not working for me | 39,322,441 | <p>I'm trying to process my input data using the TensorFlow clean way (tf.train.shuffle_batch), most of this code I gathered from the tutorials with slight modifications like the decode_jpeg function.</p>
<pre><code>size = 32,32
classes = 43
train_size = 12760
batch_size = 100
max_steps = 10000
def read_and_decode(fi... | 0 | 2016-09-04T23:47:36Z | 39,322,554 | <p>The <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/io_ops.html#batching-at-the-end-of-an-input-pipeline" rel="nofollow">batching methods in TensorFlow</a> (<code>tf.train.batch()</code>, <code>tf.train.batch_join()</code>, <code>tf.train.shuffle_batch()</code>, and <code>tf.train.shuffle_batch_jo... | 1 | 2016-09-05T00:14:04Z | [
"python",
"tensorflow"
] |
Creating a MongoDB-Backed RESTFul API With Python and Flask | 39,322,466 | <p>Im currently working on a MongoDB backed RESTFUL API with flask... However, Ive got a zone search query set up with find_one(), however as soon as I try making it a larger query with multiple results using find(), I get the following error on postman :</p>
<pre><code>UnboundLocalError: local variable 'output' refer... | 0 | 2016-09-04T23:52:36Z | 39,324,162 | <p>This is probably because 'find_One' in mongo will return only 1 document as a dictionary whereas find will return multiple documents as a list of dictionaries. jsonify does not work on a list as seen here: <a href="http://stackoverflow.com/questions/12435297/how-do-i-jsonify-a-list-in-flask">How do I `jsonify` a lis... | 0 | 2016-09-05T04:57:35Z | [
"python",
"mongodb",
"rest",
"api"
] |
Regex for unicode sentences without spaces using CountVectorizer | 39,322,474 | <p>I hope I don't have to provide an example set.</p>
<p>I have a 2D array where each array contains a set of words from sentences.</p>
<p>I am using a <a href="http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html" rel="nofollow">CountVectorizer</a> to effectively call... | 0 | 2016-09-04T23:54:20Z | 39,330,430 | <p>I have figured this out. The vectorizer was allowing 0 or more non-whitespace items - it should allow 1 or more. The correct <code>CountVectorizer</code> is:</p>
<pre><code>CountVectorizer(analyzer="word",token_pattern="[\S]+",tokenizer=None,preprocessor=None,stop_words=None,max_features=5000)
</code></pre>
| 0 | 2016-09-05T12:16:06Z | [
"python",
"nlp",
"scikit-learn",
"vectorization",
"tokenize"
] |
Bokeh's to_bokeh() ignores legend from matplotlib | 39,322,522 | <p>When converting a matplotlib plot into a bokeh html plot, I see that the legend in the matplotlib plot does not appear in the bokeh html plot. Below is an example. How can I get the legend to show up in bokeh? Thanks.</p>
<pre><code>import matplotlib.pyplot as plt
from bokeh.plotting import figure, show, output_fil... | 0 | 2016-09-05T00:05:19Z | 39,334,503 | <p>Bokeh's MPL compat capability is based on an experimental third-party library that is no longer actively maintained. The <code>to_bokeh</code> functionality is provided as-is, and with the explicit expectation that it currently provides only partial coverage. More comprehensive compatibility will depend on the imple... | 0 | 2016-09-05T16:24:28Z | [
"python",
"matplotlib",
"bokeh"
] |
Exposing API Documentation Using Flask and Swagger | 39,322,550 | <p>I have build a small service with <code>flask</code> and already wrote a swagger yaml file to describe it's API. How can I expose the swagger file through the flask app?</p>
<p>I didn't mean to expose the file itself (<code>send_from_directory</code>) but to create new endpoint that will show it as swagger-ui (inte... | 1 | 2016-09-05T00:12:57Z | 39,532,160 | <p>OK, this is what I did.</p>
<p>I used <code>flasgger</code> to and wrap my app with <code>flasgger.Swagger</code>. than I added 2 endpoints:</p>
<ol>
<li><code>/_api</code> serves the YAML file (with <code>send_from_directory</code>)</li>
<li><code>/api</code> redirects to the flasgger api <code>/apidocs/index.htm... | 0 | 2016-09-16T12:59:52Z | [
"python",
"flask",
"swagger"
] |
Write a function that to sum the result of rolling two random dice n times | 39,322,574 | <p>Write a function DiceRoll(n) that inputs an integer n and produces n random numbers
between 1 and 6. Test your program for n = 12.</p>
<p>I got this for that : </p>
<pre><code>import random
def DiceRoll(n):
x=[random.randint(1,6) for _ in range(n)]
return x
</code></pre>
<p>Then,</p>
<p>Write a function... | -4 | 2016-09-05T00:18:25Z | 39,322,616 | <p><strong>Code:</strong></p>
<pre><code>import random
def TwoDiceRoll(n):
d1=DiceRoll(n)
d2=DiceRoll(n)
dsum=[i+j for i,j in zip(d1, d2)]
return d1,d2,dsum
def DiceRoll(n):
x=[random.randint(1,6) for _ in range(n)]
return x
x=DiceRoll(12)
print x
d1,d2,dsum=TwoDiceRoll(12)
print d1, "\n",... | -1 | 2016-09-05T00:28:31Z | [
"python",
"sage",
"dice"
] |
Write a function that to sum the result of rolling two random dice n times | 39,322,574 | <p>Write a function DiceRoll(n) that inputs an integer n and produces n random numbers
between 1 and 6. Test your program for n = 12.</p>
<p>I got this for that : </p>
<pre><code>import random
def DiceRoll(n):
x=[random.randint(1,6) for _ in range(n)]
return x
</code></pre>
<p>Then,</p>
<p>Write a function... | -4 | 2016-09-05T00:18:25Z | 39,322,641 | <p>Unsure of why you want to sum them but here you go! I am sure you are capable of wrapping this in a function!</p>
<pre><code>import random
def DiceRoll(n):
x=[random.randint(1,6) for _ in range(n)]
return x
d1 = DiceRoll(12)
d2 = DiceRoll(12)
print sum(d1+d2)
</code></pre>
| -1 | 2016-09-05T00:34:01Z | [
"python",
"sage",
"dice"
] |
Query regarding reactor.doSelect() and reactor.runUntilCurrent | 39,322,614 | <p>I am working on a game prototype using python twisted. Referring one of the books, I am currently using the following code to update the games </p>
<pre><code>def iterate(self):
now = time.time()
interval = now - self.beginFrame
self.beginFrame = now
# update the network
reactor.runUntilCurrent... | 0 | 2016-09-05T00:28:08Z | 39,323,476 | <p>Twisted usually selects the epoll reactor by default. The <a href="https://twistedmatrix.com/documents/current/api/twisted.internet.selectreactor.SelectReactor.html#doSelect" rel="nofollow"><code>doSelect</code></a> function is available in the the <a href="https://twistedmatrix.com/documents/current/api/twisted.int... | 0 | 2016-09-05T03:19:26Z | [
"python",
"twisted"
] |
How to put Python loop output in a list | 39,322,625 | <p>As a beginner to Python(SAGE) I want to put the output of this for loop
into a list:</p>
<pre><code>for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
print x
</code></pre>
<p>The output is </p>
<pre><code>0
1
2
3
8
9
10
11
</code></pre>
<p>(vertically). I want a list so I can use it for a later operati... | -1 | 2016-09-05T00:30:24Z | 39,322,664 | <p>This should do the trick:</p>
<pre><code>lst = [y+z for y in [0,8] for z in [0,1,2,3]]
print(lst) # prints: [1,2,3,8,9,10,11]
</code></pre>
<p>The reason your code did not work, is because your using the variable <code>x</code> for two different things. you first assign it to a list, then you assign it to a integ... | 1 | 2016-09-05T00:38:55Z | [
"python"
] |
How to put Python loop output in a list | 39,322,625 | <p>As a beginner to Python(SAGE) I want to put the output of this for loop
into a list:</p>
<pre><code>for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
print x
</code></pre>
<p>The output is </p>
<pre><code>0
1
2
3
8
9
10
11
</code></pre>
<p>(vertically). I want a list so I can use it for a later operati... | -1 | 2016-09-05T00:30:24Z | 39,322,684 | <p>Because you set variable <code>x</code> from <code>list</code> to <code>int</code> at this line: <code>x = y + z</code>.</p>
<p><code>for</code>-loops don't have scopes like a function or class, so if you set a variable out of the loop, the variable is the same as if it were in the loop.</p>
| 0 | 2016-09-05T00:45:20Z | [
"python"
] |
How to put Python loop output in a list | 39,322,625 | <p>As a beginner to Python(SAGE) I want to put the output of this for loop
into a list:</p>
<pre><code>for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
print x
</code></pre>
<p>The output is </p>
<pre><code>0
1
2
3
8
9
10
11
</code></pre>
<p>(vertically). I want a list so I can use it for a later operati... | -1 | 2016-09-05T00:30:24Z | 39,322,689 | <p>try this :</p>
<pre><code>import itertools
temp = [y+z for y,z in list(itertools.product([0,8], [0,1,2,3]))]
</code></pre>
| 0 | 2016-09-05T00:46:39Z | [
"python"
] |
How to put Python loop output in a list | 39,322,625 | <p>As a beginner to Python(SAGE) I want to put the output of this for loop
into a list:</p>
<pre><code>for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
print x
</code></pre>
<p>The output is </p>
<pre><code>0
1
2
3
8
9
10
11
</code></pre>
<p>(vertically). I want a list so I can use it for a later operati... | -1 | 2016-09-05T00:30:24Z | 39,322,693 | <p>You can also approach this functionally using itertools.product:</p>
<pre><code>from itertools import product
lst = [y + z for y, z in product([0, 8], [0, 1, 2, 3])]
print(lst)
</code></pre>
<p>will output <code>[0, 1, 2, 3, 8, 9, 10, 11]</code>.</p>
| 0 | 2016-09-05T00:47:32Z | [
"python"
] |
How to put Python loop output in a list | 39,322,625 | <p>As a beginner to Python(SAGE) I want to put the output of this for loop
into a list:</p>
<pre><code>for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
print x
</code></pre>
<p>The output is </p>
<pre><code>0
1
2
3
8
9
10
11
</code></pre>
<p>(vertically). I want a list so I can use it for a later operati... | -1 | 2016-09-05T00:30:24Z | 39,322,696 | <p>Try:</p>
<pre><code>x = [y+z for y in [0,8] for z in [0,1,2,3]]
</code></pre>
| 0 | 2016-09-05T00:48:38Z | [
"python"
] |
How to put Python loop output in a list | 39,322,625 | <p>As a beginner to Python(SAGE) I want to put the output of this for loop
into a list:</p>
<pre><code>for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
print x
</code></pre>
<p>The output is </p>
<pre><code>0
1
2
3
8
9
10
11
</code></pre>
<p>(vertically). I want a list so I can use it for a later operati... | -1 | 2016-09-05T00:30:24Z | 39,322,792 | <p>You can simply use a list comprehension such as this one:</p>
<pre><code>>>> lst = [y+z for y in [0,8] for z in [0,1,2,3]]
>>> lst
[0, 1, 2, 3, 8, 9, 10, 11]
</code></pre>
<p>That's perfectly clear to any Python programmer.</p>
<p>Or you could use <code>range</code>:</p>
<pre><code>>>>... | 0 | 2016-09-05T01:08:58Z | [
"python"
] |
How to put Python loop output in a list | 39,322,625 | <p>As a beginner to Python(SAGE) I want to put the output of this for loop
into a list:</p>
<pre><code>for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
print x
</code></pre>
<p>The output is </p>
<pre><code>0
1
2
3
8
9
10
11
</code></pre>
<p>(vertically). I want a list so I can use it for a later operati... | -1 | 2016-09-05T00:30:24Z | 39,323,039 | <p>You have a lots of ways! First, as a raw code, you can do this:</p>
<pre><code>lst=[]
for y in [0,8] :
for z in [0,1,2,3] :
x=y+z
lst.append(x)
print lst
</code></pre>
<p>You can try <code>list comprehension</code>:</p>
<pre><code>lst = [y+z for y in [0,8] for z in [0,1,2,3]]
print lst
</cod... | 0 | 2016-09-05T02:00:42Z | [
"python"
] |
Python: How to use Value and Array in Multiprocessing pool | 39,322,677 | <p>For <code>multiprocessing</code> with <code>Process</code>, I can use <code>Value, Array</code> by setting <code>args</code> param. </p>
<p>With <code>multiprocessing</code> with <code>Pool</code>, how can I use <code>Value, Array.</code> There is nothing in the docs on how to do this. </p>
<pre><code>from multip... | 1 | 2016-09-05T00:43:49Z | 39,322,905 | <p>I never knew "the reason" for this, but <code>multiprocessing</code> (<code>mp</code>) uses different pickler/unpickler mechanisms for functions passed to most <code>Pool</code> methods. It's a consequence that objects created by things like <code>mp.Value</code>, <code>mp.Array</code>, <code>mp.Lock</code>, ..., c... | 1 | 2016-09-05T01:32:17Z | [
"python",
"arrays",
"multiprocessing",
"pool"
] |
Return true if a binary number either contains all zero or all ones on a single flip.(Python) | 39,322,700 | <p>I got a program where any binary number is considered and with 1 flip of either 0 or 1, if we get all 0s or all 1s, then it returns true else it will return false. </p>
<p>For e.g. 110 on 1 flip of element 0 returns 111 and it is printed as true.
111 is a binary number which on one flip, is printed as false.
Any po... | -2 | 2016-09-05T00:49:23Z | 39,322,724 | <p>You can loop over the values from 0 to log(x) where x is your output and xor with 2<sup>x</sup> which is 100000... Then you just check, whether what you got is 0 or 2<sup>x+1</sup>-1. It should work fine.</p>
<pre><code>def g(x):
for i in range(int(log(x)/log(2))):
if x ^ 2 ** i == 0 or x ^ 2 ** i == 2 ... | 0 | 2016-09-05T00:54:40Z | [
"python",
"python-3.x",
"math",
"binary"
] |
Return true if a binary number either contains all zero or all ones on a single flip.(Python) | 39,322,700 | <p>I got a program where any binary number is considered and with 1 flip of either 0 or 1, if we get all 0s or all 1s, then it returns true else it will return false. </p>
<p>For e.g. 110 on 1 flip of element 0 returns 111 and it is printed as true.
111 is a binary number which on one flip, is printed as false.
Any po... | -2 | 2016-09-05T00:49:23Z | 39,322,739 | <p>One possible solution:</p>
<p>Get first digit to check against all the others, convert to stirng, because integer is not iterable</p>
<pre><code>first = str(number)[0]
</code></pre>
<p>Loop over all of them, return True if we go through the loop, false if we find a digit that doesn't match</p>
<pre><code>for dig... | 0 | 2016-09-05T00:58:07Z | [
"python",
"python-3.x",
"math",
"binary"
] |
Return true if a binary number either contains all zero or all ones on a single flip.(Python) | 39,322,700 | <p>I got a program where any binary number is considered and with 1 flip of either 0 or 1, if we get all 0s or all 1s, then it returns true else it will return false. </p>
<p>For e.g. 110 on 1 flip of element 0 returns 111 and it is printed as true.
111 is a binary number which on one flip, is printed as false.
Any po... | -2 | 2016-09-05T00:49:23Z | 39,322,884 | <p>Assume that the flip can apply to any bit of the number, you can just count the occurrence of 1 or 0. If either result returns 1, then the answer is true, otherwise the answer is false:</p>
<pre><code>def one_flip(i):
# i should be integer, so convert it to string using bin() and get the result excluding the '... | 0 | 2016-09-05T01:27:40Z | [
"python",
"python-3.x",
"math",
"binary"
] |
Return true if a binary number either contains all zero or all ones on a single flip.(Python) | 39,322,700 | <p>I got a program where any binary number is considered and with 1 flip of either 0 or 1, if we get all 0s or all 1s, then it returns true else it will return false. </p>
<p>For e.g. 110 on 1 flip of element 0 returns 111 and it is printed as true.
111 is a binary number which on one flip, is printed as false.
Any po... | -2 | 2016-09-05T00:49:23Z | 39,322,891 | <p>So you need to determine whether binary representation of given number contains only one "one" or only one "zero"? There is bit trick to find numbers with single bit set:</p>
<pre><code>if (x == 0)
return false
if (x & (x - 1) == 0
return true
</code></pre>
<p>Explanation: if number looks like <code>b00... | 2 | 2016-09-05T01:28:46Z | [
"python",
"python-3.x",
"math",
"binary"
] |
Return true if a binary number either contains all zero or all ones on a single flip.(Python) | 39,322,700 | <p>I got a program where any binary number is considered and with 1 flip of either 0 or 1, if we get all 0s or all 1s, then it returns true else it will return false. </p>
<p>For e.g. 110 on 1 flip of element 0 returns 111 and it is printed as true.
111 is a binary number which on one flip, is printed as false.
Any po... | -2 | 2016-09-05T00:49:23Z | 39,322,895 | <p>Just for laughs - with some bitwise manipulations:</p>
<pre><code>>>> def single_flip(n):
... return any(x and not x & (x - 1) for x in [n, n^2**n.bit_length()-1])])
...
>>> single_flip(0b1110111), single_flip(0b1010111), single_flip(0b0001000)
(True, False, True)
</code></pre>
<p>This jus... | 0 | 2016-09-05T01:29:49Z | [
"python",
"python-3.x",
"math",
"binary"
] |
"AssertionError: Cannot apply DjangoModelPermissions" even when get_queryset is defined in view | 39,322,708 | <p>I'm getting the following error <strong>even though my view is overriding <code>get_queryset()</code>.</strong></p>
<pre><code>AssertionError: Cannot apply DjangoModelPermissions on a view that does not set `.queryset` or have a `.get_queryset()` method.
</code></pre>
<p>Here's my view:</p>
<pre><code>class Playe... | 2 | 2016-09-05T00:51:02Z | 39,356,000 | <p>I've tried running your code on DRF 3.3.2 and could figure out a couple of easy to miss errors that may be leading to the AssertionError you mentioned.</p>
<ol>
<li>Misspelled <code>get_queryset()</code>. Looks fine in your question here, but double check your code to be sure.</li>
<li>In your code in <code>get_que... | 0 | 2016-09-06T18:55:20Z | [
"python",
"django",
"django-rest-framework"
] |
A function that creates functions named after arguments passed in | 39,322,751 | <p>Is there a way to make a function that makes other functions to be called later named after the variables passed in? </p>
<p>For the example let's pretend <a href="https://example.com/engine_list" rel="nofollow">https://example.com/engine_list</a> returns this xml file, when I call it in get_search_engine_xml</p>
... | 0 | 2016-09-05T01:00:06Z | 39,322,786 | <p>You can assign them to <a href="https://docs.python.org/3/library/functions.html#globals" rel="nofollow">globals()</a></p>
<pre><code>def create_get_engine_function(function_name, address):
def function():
r = requests.get(address)
function.__name__ = function_name
function.__qualname__ = funct... | 2 | 2016-09-05T01:07:22Z | [
"python",
"xml",
"automated-tests"
] |
how to groupby in complicated condition in pandas | 39,322,773 | <p>I have dataframe like this</p>
<pre><code> A B C
0 1 7 a
1 2 8 b
2 3 9 c
3 4 10 a
4 5 11 b
5 6 12 c
</code></pre>
<p>I would like to get groupby result (key=column C) below;</p>
<pre><code> A B
d 12 36
</code></pre>
<p>"d" means a or b ,</p>
... | 0 | 2016-09-05T01:05:53Z | 39,322,850 | <p>One option is to use <code>pandas</code> <code>where</code> to transform the C column so that where it was <code>a</code> or <code>b</code> becomes <code>d</code> and then you can groupby the transformed column and do the normal summary on it, and if rows with <code>c</code> is not desired, you can simply drop it af... | 1 | 2016-09-05T01:21:45Z | [
"python",
"pandas"
] |
matrices are not aligned error message | 39,322,928 | <p>I have the following dataframe of returns</p>
<pre><code>ret
Out[3]:
Symbol FX OGDC PIB WTI
Date
2010-03-02 0.000443 0.006928 0.000000 0.012375
2010-03-03 -0.000690 -0.007873 0.000171 0.014824
2010-03-04 -0.001354 0.001545 0.000007 -... | 0 | 2016-09-05T01:36:31Z | 39,322,943 | <p>Check the shape of the matrices you're calling the dot product on. The dot product of matrices <code>A.dot(B)</code> can be computed only if second axis of A is the same size as first axis of B.<br>
In your example you have additional column with date, that ruins your computation. You should just get rid of it in yo... | 0 | 2016-09-05T01:40:08Z | [
"python",
"pandas",
"matrix",
"dot",
"np"
] |
matrices are not aligned error message | 39,322,928 | <p>I have the following dataframe of returns</p>
<pre><code>ret
Out[3]:
Symbol FX OGDC PIB WTI
Date
2010-03-02 0.000443 0.006928 0.000000 0.012375
2010-03-03 -0.000690 -0.007873 0.000171 0.014824
2010-03-04 -0.001354 0.001545 0.000007 -... | 0 | 2016-09-05T01:36:31Z | 39,323,924 | <p>You have two columns in your weight matrix:</p>
<pre><code>df3.shape
Out[38]: (4, 2)
</code></pre>
<p>Set the index to <code>Symbol</code> on that atrix to get the proper <code>dot</code>:</p>
<pre><code>ret.dot(df3.set_index('Symbol'))
Out[39]:
Weight
Date
2010-03-02 0.007938
2010-03-03 0.006430
... | 1 | 2016-09-05T04:24:32Z | [
"python",
"pandas",
"matrix",
"dot",
"np"
] |
Django's runscript: No (valid) module for script 'filename' found | 39,322,967 | <p>I'm trying to run a script from the Django shell using the Django-extension <a href="http://django-extensions.readthedocs.io/en/latest/runscript.html" rel="nofollow">RunScript</a>. I have done this before and but it refuses to recognize my new script:</p>
<pre><code>(env) mint@mint-VirtualBox ~/GP/GP $ python manag... | 0 | 2016-09-05T01:45:37Z | 39,322,968 | <p>RunScript has confusing error messages. It gives the same error for when it can't find a script at all and when there's an import error in the script.</p>
<p>Here's an example script to produce the error:</p>
<pre><code>import nonexistrentpackage
def run():
print("Test")
</code></pre>
<p>The example has the ... | 1 | 2016-09-05T01:45:37Z | [
"python",
"django"
] |
Convert Pandas groupby group into columns | 39,323,002 | <p>I'm trying to group a Pandas dataframe by two separate group types, A_Bucket and B_Bucket, and convert each A_Bucket group into a column. I get the groups as such:</p>
<pre><code>grouped = my_new_df.groupby(['A_Bucket','B_Bucket'])
</code></pre>
<p>I want the A_Bucket group to be in columns and the B_Bucket group ... | 0 | 2016-09-05T01:52:21Z | 39,323,205 | <p>If I understand you correctly, you are trying to reshape your data frame instead of grouping by summary, in this case you can use <code>set_index()</code> and <code>unstack()</code>:</p>
<pre><code>df.set_index(["A_Bucket", "B_Bucket"]).unstack(level=0)
# Value
# A_Bucket 0.100 0.125 0.1... | 2 | 2016-09-05T02:34:44Z | [
"python",
"pandas",
"dataframe"
] |
COUNT DISTINCT / nunique within groups | 39,323,071 | <p>I want to count the number of distinct tuples within each group:</p>
<pre><code>df = pd.DataFrame({'a': ['A', 'A', 'A', 'A', 'B', 'B', 'B', 'B'],
'b': [1, 2, 1, 2, 1, 2, 1, 2],
'c': [1, 1, 2, 2, 2, 1, 2, 1]})
counts = count_distinct(df, by='a', columns=['b', 'c'])
assert counts == pd.Ser... | 2 | 2016-09-05T02:06:25Z | 39,323,102 | <p>I think your logic is equivalent to count the size of data frames grouped by column <code>a</code> after dropping the duplicated values of combined columns <code>a</code>, <code>b</code> and <code>c</code>, since duplicated tuples within each group must also be duplicated records in the data frame assuming your data... | 3 | 2016-09-05T02:12:44Z | [
"python",
"python-3.x",
"pandas"
] |
tqdm: 'module' object is not callable | 39,323,182 | <p>I import tqdm as this:</p>
<pre><code>import tqdm
</code></pre>
<p>I am using tqdm to show progress in my python3 code, but I have the following error:</p>
<pre><code>Traceback (most recent call last):
File "process.py", line 15, in <module>
for dir in tqdm(os.listdir(path), desc = 'dirs'):
TypeError:... | 0 | 2016-09-05T02:31:22Z | 39,333,877 | <p>The error is telling you are trying to call the module. You can't do this.</p>
<p>To call you just have to do</p>
<pre><code>tqdm.tqdm(dirs, desc = 'dirs')
</code></pre>
<p>to solve your problem. Or simply change your import to</p>
<pre><code>from tqdm import tqdm
</code></pre>
<p>But, the important thing here... | 2 | 2016-09-05T15:38:33Z | [
"python",
"tqdm"
] |
Spotify - searching for silences in a track | 39,323,185 | <p>I have been searching everywhere but haven't found any documentation about the <code>analysis_url</code> <code>audio feature</code> on <code>Spotify API</code>, in order to deepen my understanding on the subject.</p>
<p>As far as I'm concerned, it learns the audio by <code>segments</code>, <code>bars</code>, <code>... | 1 | 2016-09-05T02:31:46Z | 39,385,373 | <p>Analysis comes from a company called EchoNest, which was bought by Spotify some time ago. You can find the documentation for the analysis <a href="http://developer.echonest.com/docs/v4/_static/AnalyzeDocumentation.pdf" rel="nofollow">here</a>.</p>
<p>Segments include a loudness_max value which indicates the relativ... | 0 | 2016-09-08T07:50:03Z | [
"python",
"spotify",
"spotipy"
] |
Plylab / MatPlotLib plot not showing data properly | 39,323,212 | <p>I have been following a tutorial to learn about fft and although I have the code verbatum, the plot from my machine does not look how it ought to. I log the data to make sure that I have an approximate sine wav over 5292 samples. However when I run the plot with <code>show()</code> I get the following image: (btw... | 1 | 2016-09-05T02:35:50Z | 39,323,898 | <p>What is the value of your <code>sampFreq</code>? Your <code>timeArray</code> is an integer list and I am assuming sampFreq is returned an integer as well. If <code>sampFreq</code> is larger than the values in <code>timeArray</code> then all of the resultant values will be 0 because integer division. </p>
<p>You may... | 0 | 2016-09-05T04:21:18Z | [
"python",
"matplotlib"
] |
python - Removing duplicate rows under conditions in Pandas | 39,323,225 | <p>I have a DataFrame like this:</p>
<pre><code> NoDemande NoUsager Sens IdVehiculeUtilise Fait HeurePrevue HeureDebutTrajet
0 42191000823 001208 + 246Véh 1 08:20:04 08:22:26
1 42191000822 001208 + 246Véh 1 08:20:04 08:18:56
2 42191000822 001208 - ... | 1 | 2016-09-05T02:37:52Z | 39,328,823 | <p>I see here two solutions.
<em>The first is based on the suggestion, that you have always continuous pairs of entries in your dataset</em> - that if any entry has a pair, this pair comes after this entry. Then you should loop over your dataframe with step size = 2:</p>
<pre><code>for i in range(0,x,2):
your action... | 0 | 2016-09-05T10:39:11Z | [
"python",
"pandas",
"dataframe",
"duplicates"
] |
python - Removing duplicate rows under conditions in Pandas | 39,323,225 | <p>I have a DataFrame like this:</p>
<pre><code> NoDemande NoUsager Sens IdVehiculeUtilise Fait HeurePrevue HeureDebutTrajet
0 42191000823 001208 + 246Véh 1 08:20:04 08:22:26
1 42191000822 001208 + 246Véh 1 08:20:04 08:18:56
2 42191000822 001208 - ... | 1 | 2016-09-05T02:37:52Z | 39,330,855 | <p>This is a long-winded solution, there might be shorter ones. <code>frame0</code> is the exact frame you posted above.</p>
<p>First take the data, sort it by <code>NoDemande</code>, split it and recombine it so you have two pairings in the same row. Makes things a lot easier:</p>
<pre><code>frame0.HeurePrevue = pd.... | 0 | 2016-09-05T12:41:01Z | [
"python",
"pandas",
"dataframe",
"duplicates"
] |
python - Removing duplicate rows under conditions in Pandas | 39,323,225 | <p>I have a DataFrame like this:</p>
<pre><code> NoDemande NoUsager Sens IdVehiculeUtilise Fait HeurePrevue HeureDebutTrajet
0 42191000823 001208 + 246Véh 1 08:20:04 08:22:26
1 42191000822 001208 + 246Véh 1 08:20:04 08:18:56
2 42191000822 001208 - ... | 1 | 2016-09-05T02:37:52Z | 39,331,422 | <p>My approach on this problem was to make two columns which contain the conditions for a check (same heure and continuous increasing NoDemande). Then iterate over the dataframe dropping the pairs you do not want based on the Fait columns.</p>
<p>It's a bit of a hacky code but this seems to do the trick:</p>
<pre><co... | 1 | 2016-09-05T13:14:11Z | [
"python",
"pandas",
"dataframe",
"duplicates"
] |
Django models class attribute and instance property? | 39,323,233 | <p>I implement very simple hit-count models in <code>Django</code>.</p>
<p><code>models.py</code></p>
<pre><code>from django.db import models
from model_utils.models import TimeStampedModel
from posts.models import Post
class PostHit(TimeStampedModel):
post = models.ForeignKey(Post, related_name='post_hits')
... | 0 | 2016-09-05T02:38:50Z | 39,323,262 | <p>You need to save the model after updating it:</p>
<pre><code>def increase_hit(self):
self.num_of_hit += 1
self.save()
</code></pre>
<p>Otherwise, your changes persist only for the lifetime of the object.</p>
| 2 | 2016-09-05T02:43:12Z | [
"python",
"django"
] |
How does this python yield function work? | 39,323,239 | <pre class="lang-py prettyprint-override"><code>def func():
output = 0
while True:
new = yield output
output = new
genr = func()
print(next(genr))
print(next(genr))
print(next(genr))
</code></pre>
<p>output:</p>
<blockquote>
<p>0<br>
None<br>
None </p>
</blockquote>
<p>What i thought... | 1 | 2016-09-05T02:39:42Z | 39,323,300 | <p>The result of a <a href="https://docs.python.org/3/reference/expressions.html#yieldexpr" rel="nofollow">yield expression</a> is the value sent in by the <a href="https://docs.python.org/3/reference/expressions.html#generator.send" rel="nofollow">generator.send()</a> function, and <code>next(gen)</code> is equivalent... | 3 | 2016-09-05T02:49:32Z | [
"python",
"yield"
] |
How does this python yield function work? | 39,323,239 | <pre class="lang-py prettyprint-override"><code>def func():
output = 0
while True:
new = yield output
output = new
genr = func()
print(next(genr))
print(next(genr))
print(next(genr))
</code></pre>
<p>output:</p>
<blockquote>
<p>0<br>
None<br>
None </p>
</blockquote>
<p>What i thought... | 1 | 2016-09-05T02:39:42Z | 39,323,321 | <p>A <a href="https://docs.python.org/3.5/reference/simple_stmts.html#the-yield-statement"><em>yield</em></a> statement is used like <em>return</em> to return a value but it doesn't destroy the stack frame (the part of a function that knows the current line, local variables, and pending try-statements). This allows th... | 7 | 2016-09-05T02:53:46Z | [
"python",
"yield"
] |
Selenium Python cannot select Element on ConnectWise Login Page | 39,323,279 | <p>Hi I am trying to select the Company Box on the Connectwise login page to automate a login.</p>
<p>However I have trouble even selecting the Company Field.</p>
<p><a href="http://i.stack.imgur.com/Z5en9.png" rel="nofollow"><img src="http://i.stack.imgur.com/Z5en9.png" alt="enter image description here"></a></p>
<... | 1 | 2016-09-05T02:46:47Z | 39,323,564 | <blockquote>
<p>selenium.common.exceptions.InvalidSelectorException: Message: invalid selector: Unable to locate an element with the xpath expression /x:html/x:body/x:div[6]/x:div/x:table/x:tbody/x:tr1/x:td/x:table/x:tbody/x:tr[2]/x:td/x:table/x:tbody/x:tr1/x:td/x:table/x:tbody/x:tr/x:td[2]/x:table/x:tbody/x:tr1/x:td... | 1 | 2016-09-05T03:32:58Z | [
"python",
"html",
"selenium"
] |
Can I find subject from Spacy Dependency tree using NLTK in python? | 39,323,325 | <p>I want to find the <strong>subject</strong> from a sentence using <code>Spacy</code>. The code below is working fine and giving a <strong>dependency tree</strong>.</p>
<pre><code>import spacy
from nltk import Tree
en_nlp = spacy.load('en')
doc = en_nlp("The quick brown fox jumps over the lazy dog.")
def to_nltk_... | 0 | 2016-09-05T02:54:03Z | 39,334,628 | <p>I'm not sure whether you want to write code using the nltk parse tree (see <a href="http://stackoverflow.com/questions/28618400/how-to-identify-the-subject-of-a-sentence">How to identify the subject of a sentence?</a> ). But, spacy also generates this with the 'nsubj' label of the word.dep_ property. </p>
<pre><cod... | 1 | 2016-09-05T16:33:44Z | [
"python",
"nlp",
"spacy"
] |
Turn on 2 LEDs, then blink one forever on button press | 39,323,330 | <p>I need help. I need my Raspberry Pi to turn on a Yellow LED and a Red LED. Then, when the Yellow button is pressed, I need the Yellow LED to start blinking forever, and for the Red LED to remain on.</p>
<p>Here is the code I have but it only partially works. It turns the Red LED on but the Yellow LED is off. (I tho... | 0 | 2016-09-05T02:54:49Z | 39,324,240 | <p>This should do the trick</p>
<pre><code>import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setwarnings (False)
GPIO.setup(24, GPIO.IN, pull_up_down = GPIO.PUD_DOWN) #Yellow button
GPIO.setup(17, GPIO.OUT) #Yellow LED
GPIO.setup(27, GPIO.OUT) #Red LED
GPIO.output(17, GPIO.HIGH) #Turn Yellow LED... | 0 | 2016-09-05T05:08:21Z | [
"python",
"button",
"raspberry-pi",
"gpio",
"led"
] |
Replacing unknown characters in a string Python 2.7 | 39,323,331 | <p>How can I define characters(in a LIST or a STRING), and have any other characters replaced with.. lets say a '?'</p>
<p>Example:</p>
<pre><code>strinput = "abcdefg#~"
legal = '.,/?~abcdefg' #legal characters
while i not in legal:
#Turn i into '?'
print output
</code></pre>
| -1 | 2016-09-05T02:54:49Z | 39,323,411 | <p>If this is a large file, read in chunks, and apply <code>re.sub(..)</code> as below. <code>^</code> within a class (square brackets) stands for negation (similar to saying "anything other than")</p>
<pre><code>>>> import re
>>> char = '.,/?~abcdefg'
>>> re.sub(r'[^' + char +']', '?', "tes... | 1 | 2016-09-05T03:08:36Z | [
"python",
"python-2.7"
] |
Replacing unknown characters in a string Python 2.7 | 39,323,331 | <p>How can I define characters(in a LIST or a STRING), and have any other characters replaced with.. lets say a '?'</p>
<p>Example:</p>
<pre><code>strinput = "abcdefg#~"
legal = '.,/?~abcdefg' #legal characters
while i not in legal:
#Turn i into '?'
print output
</code></pre>
| -1 | 2016-09-05T02:54:49Z | 39,323,575 | <p>Put the legal characters in a set then use <a href="https://docs.python.org/3/reference/expressions.html?highlight=membership#membership-test-operations" rel="nofollow"><code>in</code></a> to test each character of the string. Construct the new string using the <a href="https://docs.python.org/3/library/stdtypes.ht... | 4 | 2016-09-05T03:35:09Z | [
"python",
"python-2.7"
] |
Stopping iterations in python | 39,323,465 | <p>I'm relatively new to coding, and I made this program to repeat mouse strokes when I am on a certain webpage so that the process can be automated. </p>
<pre><code>import pyautogui, time
inp = raw_input("Number input?")
iterations = raw_input("Iterations?")
def move(x, y):
pyautogui.moveTo(x, y)
for i in rang... | 0 | 2016-09-05T03:17:16Z | 39,323,953 | <p>For ctrl + C to work, the active window must be the one with the terminal running python.</p>
<p>I guess that it may be tricky when you have your program clicking everywhere...</p>
<p>Now to make an answer worth your while, I introduce you to web browsing with python : <a href="http://selenium-python.readthedocs.i... | 0 | 2016-09-05T04:29:17Z | [
"python",
"loops",
"break"
] |
Try Except block not working with datetime object? | 39,323,466 | <p>I have a DataFrame with some datetime data in one column and whatever else in other columns. However, some of the data is messed up, e.g.:</p>
<pre><code>11/11/2014 22:28 15.1
11/11/2014 22:29 16.1
11/11/2014 22:30 15.2
bollocks 10000
11/11/2014 22:32 15.4
:00
11/11/2014 22:3... | 0 | 2016-09-05T03:17:32Z | 39,323,626 | <p>This doesn't strictly answer your query, but if you are sure that all the valid datetime strings will be of the format: <code>"%d/%m/%Y %H:%M"</code>, you can do:</p>
<pre><code>In [34]: df
Out[34]:
DATETIME VALUES
0 11/11/2014 22:28 15.1
1 11/11/2014 22:29 16.1
2 11/11/2014 22:30 15.2
... | 0 | 2016-09-05T03:42:18Z | [
"python",
"datetime",
"pandas"
] |
Try Except block not working with datetime object? | 39,323,466 | <p>I have a DataFrame with some datetime data in one column and whatever else in other columns. However, some of the data is messed up, e.g.:</p>
<pre><code>11/11/2014 22:28 15.1
11/11/2014 22:29 16.1
11/11/2014 22:30 15.2
bollocks 10000
11/11/2014 22:32 15.4
:00
11/11/2014 22:3... | 0 | 2016-09-05T03:17:32Z | 39,323,837 | <p><a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html" rel="nofollow"><code>pd.to_datetime</code></a> can set to <code>NaT</code> ill-formed data while converting the column to datetime. </p>
<pre><code>pd.to_datetime(df['DATETIME'], format = '%d/%m/%Y %H:%M', errors='coerce')
... | 1 | 2016-09-05T04:13:53Z | [
"python",
"datetime",
"pandas"
] |
How to take multiple sets of inputs separated by space and carriage return in Python 3? | 39,323,505 | <p>So we are allowing a user to enter the number sets they want to enter. Each set of input will contain two integers separated by space. Then, the carriage return denotes the next set of inputs. For example,</p>
<pre><code>Enter number of sets: 3
1 3
2 4
5 6
</code></pre>
<p>Next we input these in variables a,b, per... | -1 | 2016-09-05T03:23:48Z | 39,323,574 | <p>The <code>input()</code> is returning a string like <code>"1 3"</code>. Parse that string with something like, <code>a, b = map(int, input().split())</code>. Save the output by using <em>list.append()</em>.</p>
<pre><code>from pprint import pprint
inputs = []
results = []
sets = int(input("Enter number of sets: ... | 4 | 2016-09-05T03:35:04Z | [
"python",
"list",
"user-input",
"python-3.4"
] |
How can I create a dictionary from a list of k:v tuples returned from a SQL query? | 39,323,623 | <p>My SQL (sqlite3) query is along the lines of this:</p>
<pre><code>SELECT id, name FROM mytable;
</code></pre>
<p>This returns a ton of rows. I would like to create a dictionary from these results, where I can lookup the name given an id.</p>
<p>Other answers I've found seem to create dictionaries based on SQL re... | 2 | 2016-09-05T03:40:54Z | 39,323,691 | <p>You can loop over the rows (the <a href="https://docs.python.org/3/library/sqlite3.html#module-sqlite3" rel="nofollow">result cursor is iterable</a>), <a href="https://docs.python.org/3/tutorial/datastructures.html#tuples-and-sequences" rel="nofollow">unpack</a> the key and value, then assemble the result using a <a... | 3 | 2016-09-05T03:52:51Z | [
"python",
"sql",
"dictionary",
"sqlite3"
] |
How can I create a dictionary from a list of k:v tuples returned from a SQL query? | 39,323,623 | <p>My SQL (sqlite3) query is along the lines of this:</p>
<pre><code>SELECT id, name FROM mytable;
</code></pre>
<p>This returns a ton of rows. I would like to create a dictionary from these results, where I can lookup the name given an id.</p>
<p>Other answers I've found seem to create dictionaries based on SQL re... | 2 | 2016-09-05T03:40:54Z | 39,323,709 | <p>The result returned from cursor is a list of 2-elements tuples so you can just convert that to a dictionary as the first item of each tuple is a unique value:</p>
<pre><code>result = dict(cursor.execute("SELECT id, name FROM mytable"))
</code></pre>
| 2 | 2016-09-05T03:55:18Z | [
"python",
"sql",
"dictionary",
"sqlite3"
] |
How can I create a dictionary from a list of k:v tuples returned from a SQL query? | 39,323,623 | <p>My SQL (sqlite3) query is along the lines of this:</p>
<pre><code>SELECT id, name FROM mytable;
</code></pre>
<p>This returns a ton of rows. I would like to create a dictionary from these results, where I can lookup the name given an id.</p>
<p>Other answers I've found seem to create dictionaries based on SQL re... | 2 | 2016-09-05T03:40:54Z | 39,323,710 | <p>Suppose you get your sql query result in Python, something like</p>
<p><code>db_conn = sqlite3.connect('text.db')
cur = db_conn.cursor()
cur.execute('''select id, name from mytable''')</code></p>
<p>Then you can get all the query results in the return of <code>cur.fetchall()</code>.
The result will be a list of tu... | 0 | 2016-09-05T03:55:19Z | [
"python",
"sql",
"dictionary",
"sqlite3"
] |
Extracting text within tag with BeautifulSoup | 39,323,666 | <pre><code> <div>
<p class="tabbed" style="margin-top:2px;"><span class="tab"><strong>LANGUAGES</strong></span>Cantonese</p>
<p class="tabbed" style="margin-top:2px;"><span class="tab"></span>English</p>
<p class="tabbed" style="margin-top:2px;">... | 0 | 2016-09-05T03:49:17Z | 39,323,759 | <p>You can use the <a href="https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0ahUKEwja4Ii7q_fOAhVGN48KHR_QDZsQygQIHzAA&url=https%3A%2F%2Fwww.crummy.com%2Fsoftware%2FBeautifulSoup%2Fdocumentation.html%23The%2520basic%2520find%2520method%3A%2520findA... | 0 | 2016-09-05T04:00:29Z | [
"python",
"html",
"text",
"tags",
"beautifulsoup"
] |
Extracting text within tag with BeautifulSoup | 39,323,666 | <pre><code> <div>
<p class="tabbed" style="margin-top:2px;"><span class="tab"><strong>LANGUAGES</strong></span>Cantonese</p>
<p class="tabbed" style="margin-top:2px;"><span class="tab"></span>English</p>
<p class="tabbed" style="margin-top:2px;">... | 0 | 2016-09-05T03:49:17Z | 39,328,973 | <p>You don't need to search every tag, you can find the span where the <code>text="GENDER"</code> and get the text from the parent <code>p</code> setting <em>resursive=False</em> to only get the parent text:</p>
<pre><code>In [4]: from bs4 import BeautifulSoup
In [5]: h = """<div>
...: <p class="tabbed" s... | 0 | 2016-09-05T10:48:24Z | [
"python",
"html",
"text",
"tags",
"beautifulsoup"
] |
Extracting text within tag with BeautifulSoup | 39,323,666 | <pre><code> <div>
<p class="tabbed" style="margin-top:2px;"><span class="tab"><strong>LANGUAGES</strong></span>Cantonese</p>
<p class="tabbed" style="margin-top:2px;"><span class="tab"></span>English</p>
<p class="tabbed" style="margin-top:2px;">... | 0 | 2016-09-05T03:49:17Z | 39,331,893 | <p>Here's a simpler way for you to understand: You can get your desired output by parsing the "p" tags. </p>
<pre><code>from bs4 import BeautifulSoup
doc = """
<div>
<p class="tabbed" style="margin-top:2px;"><span class="tab"><strong>LANGUAGES</strong></span>Cantonese</p>
&l... | 0 | 2016-09-05T13:39:43Z | [
"python",
"html",
"text",
"tags",
"beautifulsoup"
] |
Zeppelin and BigQuery | 39,323,667 | <p>I'm looking for a visualisation and analytical notebook engine for <code>BigQuery</code> and am interested in <code>Apache</code>/<code>Zeppelin</code>.</p>
<p>We have internal capability in <code>Python</code> and <code>R</code> and want to use this with our <code>BigQuery</code> back end.</p>
<p>All the installa... | 0 | 2016-09-05T03:49:45Z | 39,324,306 | <p>Starting with 0.6.1 there is a <a href="https://zeppelin.apache.org/docs/0.6.1/interpreter/bigquery.html" rel="nofollow">Native BigQuery Interpreter for Apache Zeppelin</a> available.<br>
It allows you to process and analyze datasets stored in Google BigQuery by directly running SQL against it from within an Apache ... | 1 | 2016-09-05T05:17:06Z | [
"python",
"google-bigquery",
"apache-zeppelin"
] |
How do you make a list of lists in python3? | 39,323,671 | <p>So, currently I've created 2 empty <code>list</code>, with length 128 and 64, added numbers into them (just to test it out) and now I'm trying to insert the <code>DirectoryEntries</code> <code>list</code> into the <code>AvailableBlocks</code> <code>list</code>. But when I print the new list out, it just prints <code... | 2 | 2016-09-05T03:50:18Z | 39,323,750 | <p>The insert does not return a value.
Try</p>
<pre><code>AvailableBlocks.insert(0, DirectoryEntries)
print(AvailableBlocks)
</code></pre>
<p>and it should work</p>
| 4 | 2016-09-05T03:59:05Z | [
"python",
"list",
"insert",
"python-3.5"
] |
Updating Jinja2 Variables every X seconds - Python Flask | 39,323,779 | <p>I am trying to update variables inside of my index.html file. I am going to be running a thread with a loop in python but I want a way to update my jinja2 table listed below to update every x seconds just like if you were using php and ajax.</p>
<p>Here is my Jinja2 Code: </p>
<pre><code><table border=1 id="all... | -1 | 2016-09-05T04:03:33Z | 39,323,881 | <p>You'll need some javascript in there.</p>
<p>Either ajax requests, or websockets, though ajax might be simpler.</p>
<p>Simply use javascript <code>setInterval()</code> with an ajax request.</p>
<p>I'd recommend using a library, maybe jquery as it is very simple.</p>
<pre><code>$.get( "/auto_refresh", function( d... | 1 | 2016-09-05T04:18:45Z | [
"python",
"html",
"flask",
"jinja2"
] |
Updating Jinja2 Variables every X seconds - Python Flask | 39,323,779 | <p>I am trying to update variables inside of my index.html file. I am going to be running a thread with a loop in python but I want a way to update my jinja2 table listed below to update every x seconds just like if you were using php and ajax.</p>
<p>Here is my Jinja2 Code: </p>
<pre><code><table border=1 id="all... | -1 | 2016-09-05T04:03:33Z | 39,353,382 | <p>Jinja variables are generated at template render-time. There's no way to programmatically update them without using javascript of some sort.</p>
<p>From <a href="http://jinja.pocoo.org/docs/dev/templates/" rel="nofollow">the docs</a> (emphasis mine):</p>
<blockquote>
<p>A [Jinja] template contains variables and/... | 0 | 2016-09-06T16:06:24Z | [
"python",
"html",
"flask",
"jinja2"
] |
Limits on Complex Sparse Linear Algebra in Python | 39,323,796 | <p>I am prototyping numerical algorithms for linear programming and matrix manipulation with very large (100,000 x 100,000) very sparse (0.01% fill) complex (a+b*i) matrices with symmetric structure and asymmetric values. I have been happily using MATLAB for seven years, but have been receiving suggestions to switch to... | 0 | 2016-09-05T04:06:14Z | 39,326,243 | <p>Probably your sparse solvers were slower than <code>A\b</code> at least in part due to the interpreter overhead of MATLAB scripts. Internally MATLAB uses UMFPACK's multifrontal solver for <code>LU()</code> function and <code>A\b</code> operator (see <a href="http://faculty.cse.tamu.edu/davis/suitesparse.html" rel="n... | 0 | 2016-09-05T08:06:01Z | [
"python",
"matlab",
"matrix",
"linear-programming"
] |
Selenium can't open Firefox 48.0.1 | 39,323,817 | <p>I am starting to learn how to become a better test driven developer when creating web applications in Django. I am trying to use Selenium to open a browser, but I am getting an error.</p>
<pre><code>selenium.common.exceptions.WebDriverException: Message: Can't load the profile. Profile Dir: /var/folders/xn/bvyw0fm9... | 2 | 2016-09-05T04:10:00Z | 39,324,230 | <p>That error is because you are using FF 48. For FF>=47 FirefoxDriver stop working. You must use the new <a href="https://developer.mozilla.org/en-US/docs/Mozilla/QA/Marionette/WebDriver" rel="nofollow">MarionetteDriver</a> </p>
<p>Set up this:</p>
<pre><code>from selenium import webdriver
from selenium.webdriver.co... | 1 | 2016-09-05T05:06:38Z | [
"python",
"selenium",
"firefox"
] |
How to delete files using the syntax '*' with python3? | 39,323,893 | <p>There are some files that named like percentxxxx.csv,percentyyyy.csv in the dir.I want to delete the files with the name begins with percent.</p>
<p>I find the <code>os.remove</code> function maybe can help me,bu I don't konw how to solve the problem.</p>
<p>Are there any other functions can delete files using the... | 0 | 2016-09-05T04:20:34Z | 39,323,904 | <p>Use <a href="https://docs.python.org/3.1/library/glob.html#module-glob" rel="nofollow">glob</a>:</p>
<pre><code>import os
import glob
for csv in glob.glob("percent*.csv"):
os.remove(csv)
</code></pre>
| 3 | 2016-09-05T04:22:11Z | [
"python",
"python-3.x",
"delete-file"
] |
How to build a dictionary of string lengths using a for loop? | 39,323,937 | <p>I am pretty new to python, but I know the basic commands. I am trying to create a for loop which, when given a list of sentences, adds a key for the length of each sentence. The value of each key would be the frequency of that sentence length in the list, so that the format would look something like this:</p>
<pre>... | 4 | 2016-09-05T04:26:33Z | 39,324,021 | <p>I think this will solve your problem, in Python 3:</p>
<pre><code>sentences ='Hi my name is xyz'
words = sentences.split()
dictionary ={}
for i in words:
if len(i) in dictionary:
dictionary[len(i)]+=1
else:
dictionary[len(i)] = 1
print(dictionary)
</code></pre>
<p>Output:</p>
<pre><code>{... | 2 | 2016-09-05T04:39:04Z | [
"python",
"string",
"list",
"dictionary",
"sentence"
] |
Getting error message when trying to break out of a while loop in Python | 39,324,043 | <p>I'm trying to write code that includes the following:</p>
<p>1) Uses a conditional test in the while statement to stop the loop.</p>
<p>2) Uses an active variable to control how long the loop runs.</p>
<p>3) Use a break statement to exit the loop when the user enters a 'quit' value.</p>
<p><strong>Here is my cod... | 2 | 2016-09-05T04:41:43Z | 39,324,070 | <p>You convert age to an integer with <code>int()</code> so it will never equal <code>'quit'</code>. Do the <code>quit</code> check first, then convert to integer:</p>
<pre><code>age = input(prompt)
if age == 'quit':
break;
age = int(age)
...
</code></pre>
<p>This now checks if it's equal to a string literal <e... | 1 | 2016-09-05T04:45:33Z | [
"python"
] |
Getting error message when trying to break out of a while loop in Python | 39,324,043 | <p>I'm trying to write code that includes the following:</p>
<p>1) Uses a conditional test in the while statement to stop the loop.</p>
<p>2) Uses an active variable to control how long the loop runs.</p>
<p>3) Use a break statement to exit the loop when the user enters a 'quit' value.</p>
<p><strong>Here is my cod... | 2 | 2016-09-05T04:41:43Z | 39,324,074 | <p>You are converting the user's input to a number before checking if that input is actually a number. Go from this:</p>
<pre><code>age = input(prompt)
age = int(age)
if age == 'quit':
break
elif age < 3:
print("Your ticket is free.")
</code></pre>
<p>To this:</p>
<pre><code>age = input(prompt)
if age ... | 5 | 2016-09-05T04:46:03Z | [
"python"
] |
Getting error message when trying to break out of a while loop in Python | 39,324,043 | <p>I'm trying to write code that includes the following:</p>
<p>1) Uses a conditional test in the while statement to stop the loop.</p>
<p>2) Uses an active variable to control how long the loop runs.</p>
<p>3) Use a break statement to exit the loop when the user enters a 'quit' value.</p>
<p><strong>Here is my cod... | 2 | 2016-09-05T04:41:43Z | 39,324,083 | <p>You are casting the string "quit" to integer, and python tells you it's wrong.</p>
<p>This will work :</p>
<pre><code>prompt = "What is your age?"
prompt += "\nEnter 'quit' to exit: "
while True:
age = input(prompt)
if age == 'quit':
break
age = int(age)
if age < 3:
pri... | 1 | 2016-09-05T04:47:13Z | [
"python"
] |
Getting error message when trying to break out of a while loop in Python | 39,324,043 | <p>I'm trying to write code that includes the following:</p>
<p>1) Uses a conditional test in the while statement to stop the loop.</p>
<p>2) Uses an active variable to control how long the loop runs.</p>
<p>3) Use a break statement to exit the loop when the user enters a 'quit' value.</p>
<p><strong>Here is my cod... | 2 | 2016-09-05T04:41:43Z | 39,324,128 | <p>Just for the sake of showing something different, you can actually make use of a <code>try/except</code> here for catching a <code>ValueError</code> and in your exception block, you can check for <code>quit</code> and <code>break</code> accordingly. Furthermore, you can slightly simplify your input prompt to save a ... | 1 | 2016-09-05T04:53:39Z | [
"python"
] |
Getting error message when trying to break out of a while loop in Python | 39,324,043 | <p>I'm trying to write code that includes the following:</p>
<p>1) Uses a conditional test in the while statement to stop the loop.</p>
<p>2) Uses an active variable to control how long the loop runs.</p>
<p>3) Use a break statement to exit the loop when the user enters a 'quit' value.</p>
<p><strong>Here is my cod... | 2 | 2016-09-05T04:41:43Z | 39,326,538 | <p>As proposed in a comment above you should use raw_input() instead of input in order to handle the user input as a string so that you can check for the 'quit' string. If the user input is not equal to 'quit' then you can try to manage the input string as integer numbers. In case the user passes an invalid string (e.g... | 0 | 2016-09-05T08:28:03Z | [
"python"
] |
Stream a non-seekable file-like object to multiple sinks | 39,324,151 | <p>I have a non-seekable file-like object. In particular it is a file of indeterminate size coming from an HTTP request.</p>
<pre><code>import requests
fileobj = requests.get(url, stream=True)
</code></pre>
<p>I am streaming this file to a call to an Amazon AWS SDK function which is writing the contents to Amazon S3.... | 4 | 2016-09-05T04:56:42Z | 39,333,962 | <p>The discomfort regarding your <code>MyFilewrapper</code> solution arises, because the IO loop inside <code>upload_fileobj</code> is now in control of feeding the data to a subprocess that is strictly speaking unrelated to the upload.</p>
<p>A "proper" solution would involve an upload API that provides a file-like o... | 1 | 2016-09-05T15:45:00Z | [
"python",
"python-3.x",
"stream"
] |
Stream a non-seekable file-like object to multiple sinks | 39,324,151 | <p>I have a non-seekable file-like object. In particular it is a file of indeterminate size coming from an HTTP request.</p>
<pre><code>import requests
fileobj = requests.get(url, stream=True)
</code></pre>
<p>I am streaming this file to a call to an Amazon AWS SDK function which is writing the contents to Amazon S3.... | 4 | 2016-09-05T04:56:42Z | 39,334,595 | <p>Here is an implementation of <code>StreamDuplicator</code> with requested functionality and use model. I verified that it handles correctly the case when one of the sinks stops consuming the respective stream half-way.</p>
<p><strong>Usage</strong>:</p>
<pre><code>./streamduplicator.py <sink1_command> <si... | 1 | 2016-09-05T16:31:17Z | [
"python",
"python-3.x",
"stream"
] |
How do I build a cx_oracle app using pyinstaller to use multiple Oracle client versions? | 39,324,217 | <p>I am building an application in Python using cx_Oracle (v5) and Pyinstaller to package up and distribute the application. When I built and packaged the application, I had the Oracle 12c client installed. However, when I deployed it to a machine with the 11g client installed, it seems not to work. I get the messag... | 0 | 2016-09-05T05:04:42Z | 39,349,805 | <p>The error "Unable to acquire Oracle environment handle" means there is something wrong with your Oracle configuration. Check to see what libclntsh.so file you are using. The simplest way to do that is by using the ldd command on the cx_Oracle module that PyInstaller has bundled with the executable. Then check to see... | 1 | 2016-09-06T13:07:33Z | [
"python",
"oracle",
"pyinstaller",
"cx-oracle"
] |
Fast hash for 2 coordinates where order doesn't matter? | 39,324,220 | <p>Is there a formula that is a one way hash for 2 coordinates (a, b) and (c, d) to one integer where a, b, c, and d are positive? Order <strong>doesn't</strong> matter here, so the formula should give the same results when given <code>(a, b), (c, d)</code> and <code>(c, d), (a, b)</code>. The order of the actual numbe... | 3 | 2016-09-05T05:04:59Z | 39,325,840 | <p>You can use the <a href="https://docs.python.org/3/library/functions.html#hash" rel="nofollow">hash()</a> of a <a href="https://docs.python.org/3/library/functions.html#func-frozenset" rel="nofollow">frozenset</a> for this.</p>
<pre><code>>>> hash(frozenset([(10, 20), (11, 22)]))
1735850283064117985
>&g... | 1 | 2016-09-05T07:40:38Z | [
"python",
"hash",
"hashmap",
"key",
"hashcode"
] |
Python scipy / Fortran : float64, real, double? | 39,324,311 | <p>I am writing a front-end in Python for a Fortran library. The Python modules are supposed to work on both 32-bit and 64-bit machines; for windows, linux and mac. </p>
<p>I would like to get some clarity on the byte widths of some of the data types:</p>
<p>[1] Say a variable in the Fortran function is declared as "... | 1 | 2016-09-05T05:17:42Z | 39,324,882 | <pre><code>In [241]: np.double
Out[241]: numpy.float64
In [246]: x=np.float64(34)
In [247]: x
Out[247]: 34.0
In [248]: x.nbytes
Out[248]: 8
</code></pre>
<p><a href="http://docs.scipy.org/doc/numpy/reference/c-api.config.html" rel="nofollow">http://docs.scipy.org/doc/numpy/reference/c-api.config.html</a>
Docs for sy... | 1 | 2016-09-05T06:24:15Z | [
"python",
"numpy",
"scipy",
"data-type-conversion"
] |
Accept YAML input from website user | 39,324,356 | <p>I haven't written this in the code yet but I want to parse YAML from my website users. The YAML should just be string key/values and lists of strings.</p>
<p>They input YAML into a textbox, send it to the server, then the python will parse the YAML, put it in the database and it will later be queryable.</p>
<p>Is ... | 2 | 2016-09-05T05:24:05Z | 39,324,450 | <p>The main thing to observe is to parse the yaml with either <code>safe_load</code> ( <a href="https://pypi.python.org/pypi/ruamel.yaml/" rel="nofollow">ruamel.yaml</a> (supporting YAML 1.2), <a href="http://pyyaml.org/" rel="nofollow">PyYAML</a> (YAML 1.1)) or <code>round_trip_load</code> (ruamel.yaml, this will allo... | 2 | 2016-09-05T05:35:49Z | [
"python",
"security",
"yaml"
] |
Best way to create Django instances while manipulating/hiding fields from caller? | 39,324,472 | <p>Suppose I have the following Django class:</p>
<pre><code>from django.db import models
class Person(models.Model):
name = models.CharField(max_length=254)
year_of_birth = models.IntegerField()
</code></pre>
<p>I can create an instance of the model by doing the following:</p>
<pre><code>p = Person.object.... | 0 | 2016-09-05T05:37:39Z | 39,325,495 | <p>Maybe you can add a Person manager to your Person model class like this:</p>
<pre><code>objects = PersonManager()
</code></pre>
<p>Then define a method inside PersonManager() that creates a person:</p>
<pre><code>class PersonManager(models.Manager):
def create_person(name, age):
return self.create(nam... | 1 | 2016-09-05T07:14:35Z | [
"python",
"django",
"django-models"
] |
Understanding Tensorflow LSTM Input shape | 39,324,520 | <p>I have a dataset X which consists <strong>N = 4000 samples</strong>, each sample consists of <strong>d = 2 features</strong> (continuous values) spanning back <strong>t = 10 time steps</strong>. I also have the corresponding 'labels' of each sample which are also continuous values, at time step 11. </p>
<p>At the ... | 3 | 2016-09-05T05:43:29Z | 39,325,925 | <p>The <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/nn.html#dynamic_rnn" rel="nofollow">documentation of <code>tf.nn.dynamic_rnn</code></a> states:</p>
<blockquote>
<p><code>inputs</code>: The RNN inputs. If <code>time_major == False</code> (default), this must be a Tensor of shape: <code>[batc... | 0 | 2016-09-05T07:46:02Z | [
"python",
"tensorflow",
"regression",
"lstm"
] |
Why am I getting the error: "Error: Render_to_response not defined"; Django | 39,324,619 | <p>I'm learning Django, and I found a very basic example online on how to display tables using templates. I followed the code exactly, but for some reason I get the error:</p>
<pre><code>Error: Render_to_response not defined
</code></pre>
<p>Here is my views.py:</p>
<pre><code>from django.shortcuts import render
de... | 3 | 2016-09-05T05:54:39Z | 39,324,692 | <p>You are importing <code>render</code> but using <code>render_to_response</code></p>
<p>Replace <code>render_to_response</code></p>
<pre><code>from django.shortcuts import render
def display(request):
return render(request, 'template.tmpl', {'obj':models.Book.objects.all()})
</code></pre>
| 4 | 2016-09-05T06:03:25Z | [
"python",
"django"
] |
get Font Size in Python with Tesseract and Pyocr | 39,324,626 | <p>Is it possible to get font size from an image using <code>pyocr</code> or <code>Tesseract</code>?
Below is my code.</p>
<pre><code>tools = pyocr.get_available_tools()
tool = tools[0]
txt = tool.image_to_string(
Imagee.open(io.BytesIO(req_image)),
lang=lang,
builder=pyocr.builders.TextBuilder()
)
<... | 0 | 2016-09-05T05:55:11Z | 39,400,521 | <p>Using <a href="https://github.com/sirfz/tesserocr" rel="nofollow">tesserocr</a>, you can get a <code>ResultIterator</code> after calling <code>Recognize</code> on your image, for which you can call the <code>WordFontAttributes</code> method to get the information you need. Read the method's documentation for more in... | 0 | 2016-09-08T21:30:55Z | [
"python",
"tesseract",
"font-size",
"python-tesseract"
] |
Rename response fields django rest framework serializer | 39,324,691 | <p>I'm calling a simple get API using djangorestframework. My Model is </p>
<pre><code>class Category(models.Model):
category_id = models.AutoField(primary_key=True)
category_name = models.CharField("Category Name", max_length = 30)
category_created_date = models.DateField(auto_now = True, auto_now_add=Fal... | 2 | 2016-09-05T06:03:18Z | 39,324,779 | <p>You can override to_representation function in serializer.Check the following code you can update <code>data</code> dictionary as you want.</p>
<pre><code>class CategorySerializer(serializers.ModelSerializer) :
class Meta:
model = Category
fields = ['category_id', 'category_name']
def to_rep... | 0 | 2016-09-05T06:13:05Z | [
"python",
"django",
"django-rest-framework",
"jsonserializer"
] |
Rename response fields django rest framework serializer | 39,324,691 | <p>I'm calling a simple get API using djangorestframework. My Model is </p>
<pre><code>class Category(models.Model):
category_id = models.AutoField(primary_key=True)
category_name = models.CharField("Category Name", max_length = 30)
category_created_date = models.DateField(auto_now = True, auto_now_add=Fal... | 2 | 2016-09-05T06:03:18Z | 39,324,788 | <p>You can just wrap it up in <code>json</code>. This is the way you render the way you want:</p>
<pre><code>from django.http import HttpResponse
import json
def category_list(request):
if request.method == 'GET':
categories = Category.objects.all()
serializer = CategorySerializer(categories, many... | 1 | 2016-09-05T06:13:50Z | [
"python",
"django",
"django-rest-framework",
"jsonserializer"
] |
Rename response fields django rest framework serializer | 39,324,691 | <p>I'm calling a simple get API using djangorestframework. My Model is </p>
<pre><code>class Category(models.Model):
category_id = models.AutoField(primary_key=True)
category_name = models.CharField("Category Name", max_length = 30)
category_created_date = models.DateField(auto_now = True, auto_now_add=Fal... | 2 | 2016-09-05T06:03:18Z | 39,325,147 | <p><strong>First</strong> of all using <code>category_</code> in field names is redundant. Because you are already assigning this fields to <code>Category</code> model, and by doing this you are creating "namespace" for this fields.</p>
<pre><code>class Category(models.Model):
id = models.AutoField(primary_key=Tru... | 4 | 2016-09-05T06:46:17Z | [
"python",
"django",
"django-rest-framework",
"jsonserializer"
] |
How to run python production on customer environment | 39,324,787 | <p>I have some python application that should run on customer site. I compile my <code>py</code> files to <code>pyc</code> (python byte code).</p>
<p>What is the standard way to run the app on the customer environment? The options I see are:</p>
<ul>
<li>As part of my installer, install some python distribution, i.e ... | 9 | 2016-09-05T06:13:36Z | 39,352,901 | <p>Given your requirements, the last two options seem most viable:</p>
<blockquote>
<ul>
<li>Bring python libraries and executable along with my code and run it directly from my installation dir.</li>
<li>Convert the scripts to exe using some py-to-exe tool.</li>
</ul>
</blockquote>
<p>You can either <a hr... | 2 | 2016-09-06T15:38:14Z | [
"python",
"python-3.x",
"production",
"pyc",
"python-install"
] |
Error importing modules in thumbor | 39,324,822 | <p>I have installed thumbor using pip on windows when I try to run the thumbor server I get an error like:</p>
<pre><code>2016-09-05 11:45:10 thumbor:WARNING Module thumbor.filters.brightness could not
be imported.
2016-09-05 11:45:10 thumbor:WARNING Module thumbor.filters.colorize could not be
imported.
2016-09-05 1... | 0 | 2016-09-05T06:17:33Z | 39,325,411 | <p>Seems this issue has already been reported on github <a href="https://github.com/thumbor/thumbor/issues/256" rel="nofollow">issue-256</a>. Try referring to that.</p>
| 0 | 2016-09-05T07:08:19Z | [
"python",
"thumbor"
] |
Tensorflow - Using batching to make predictions | 39,324,856 | <p>I'm attempting to make predictions using a trained convolutional neural network, slightly modified from the example in the example expert tensorflow tutorial. I have followed the instructions at <a href="https://www.tensorflow.org/versions/master/how_tos/reading_data/index.html" rel="nofollow">https://www.tensorflow... | 0 | 2016-09-05T06:21:40Z | 39,359,162 | <p>Does using tensorflow serving to make predictions work for you?</p>
| 0 | 2016-09-06T23:23:56Z | [
"python",
"machine-learning",
"tensorflow"
] |
Python Requests - Dynamically Pass HTTP Verb | 39,324,970 | <p>Is there a way to pass an HTTP verb (PATCH/POST) to a function and dynamically use that verb for Python requests?</p>
<p>For example, I want this function to take a 'verb' variable which is only called internally and will either = post/patch.</p>
<pre><code>def dnsChange(self, zID, verb):
for record in config.... | 1 | 2016-09-05T06:32:07Z | 39,325,096 | <p>You can always rely on <code>getattr</code> with a default value. Maybe like</p>
<pre><code>action = getattr(requests, verb, None)
if action:
action(headers=self.auth, url=self.API + '/zones/' + str(zID) + '/dns_records', data={"type":record[0], "name":record[1], "content":record[2]})
else:
# handle invali... | 2 | 2016-09-05T06:42:17Z | [
"python",
"http",
"request",
"httpverbs"
] |
Python Requests - Dynamically Pass HTTP Verb | 39,324,970 | <p>Is there a way to pass an HTTP verb (PATCH/POST) to a function and dynamically use that verb for Python requests?</p>
<p>For example, I want this function to take a 'verb' variable which is only called internally and will either = post/patch.</p>
<pre><code>def dnsChange(self, zID, verb):
for record in config.... | 1 | 2016-09-05T06:32:07Z | 39,327,014 | <p>Just use the <code>request()</code> method. First argument is the HTTP verb that you want to use. <code>get()</code>, <code>post()</code>, etc. are just aliases to <code>request('GET')</code>, <code>request('POST')</code>: <a href="https://requests.readthedocs.io/en/master/api/#requests.request" rel="nofollow">http... | 2 | 2016-09-05T08:56:36Z | [
"python",
"http",
"request",
"httpverbs"
] |
How to download japanese history stock prices automatically from google finance in python | 39,325,060 | <p>I use python to analyze Japanese stock prices. I want to get Japanese historical stock prices to get from google finance. I also refer to googlefinance0.7 ( <a href="https://pypi.python.org/pypi/googlefinance" rel="nofollow">https://pypi.python.org/pypi/googlefinance</a> ) and pandas, but they are not support Japan... | 2 | 2016-09-05T06:39:53Z | 39,325,455 | <p><a href="https://www.quandl.com/data/TSE" rel="nofollow">Quandl</a> has all the historical data sets you need.
<br>
It's designed for easy usage with Python so for <a href="https://www.quandl.com/data/TSE/TOPIX-Tokyo-Stock-Exchange-TOPIX-Index" rel="nofollow">Tokyo Stock Exchange TOPIX Index</a> :</p>
<pre><code>im... | 1 | 2016-09-05T07:12:01Z | [
"python",
"finance",
"stock"
] |
Changing userPassword in OpenLDAP using ldap3 library | 39,325,089 | <p>I can't seem to change a users password using the ldap3 python module against an OpenLDAP server. A similar question has been asked <a href="http://stackoverflow.com/questions/37847042/changing-active-directory-user-password-in-python-3-x">before</a> but that's specific to Active Directory.</p>
<p>What I've tried:<... | 2 | 2016-09-05T06:41:54Z | 39,338,891 | <p>Changing the password seems to work as described in the docs and shown in the edit of my question above. For future reference, this code seems to work:</p>
<pre><code>from ldap3 import (
HASHED_SALTED_SHA, MODIFY_REPLACE
)
from ldap3.utils.hashed import hashed
def modify_user_password(self, user, password):
... | 1 | 2016-09-05T23:54:57Z | [
"python",
"python-3.x",
"openldap",
"ldap3"
] |
How to train TensorFlow network using a generator to produce inputs? | 39,325,275 | <p>The TensorFlow <a href="https://www.tensorflow.org/versions/r0.10/how_tos/reading_data/index.html" rel="nofollow">docs</a> describe a bunch of ways to read data using TFRecordReader, TextLineReader, QueueRunner etc and queues.</p>
<p>What I would like to do is much, much simpler: I have a python generator function... | 3 | 2016-09-05T06:57:38Z | 39,331,675 | <p>Suppose you have a function that generates data: </p>
<pre><code> def generator(data):
...
yield (X, y)
</code></pre>
<p>Now you need some function that describes your network architecture. It could be any network that processes X and has to predict y as output. </p>
<p>Suppose your function receives X... | 3 | 2016-09-05T13:27:49Z | [
"python",
"tensorflow"
] |
pyinstaller 3.2 with django 1.10.1 | 39,325,296 | <p>System: windows 7 64 bit, python 3.5, anaconda 3 (64 bit) , django 1.10.1 </p>
<p>I'm trying to compile my django project in 2 ways:</p>
<p>First:</p>
<pre><code>[Anaconda3] c:\compilation\Gui>pyinstaller --name=gui --exclude-module=PyQt4 --exclude-module=matplotlib --clean --win-private-assemblies manage.py
... | 0 | 2016-09-05T06:59:21Z | 39,333,547 | <p>What is your files layout? According to these <code>pyinstaller</code> docs <a href="https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Executable-From-Django" rel="nofollow">https://github.com/pyinstaller/pyinstaller/wiki/Recipe-Executable-From-Django</a> there could be two solutions.</p>
<ol>
<li><p>run your ... | 0 | 2016-09-05T15:16:28Z | [
"python",
"django",
"pyinstaller"
] |
Numba: Manual looping faster than a += c * b with numpy arrays? | 39,325,352 | <p>I would like to do a 'daxpy' (add to a vector the scalar multiple of a second vector and assign the result to the first) with <code>numpy</code> using <code>numba</code>. Doing the following test, I noticed that writing the loop myself was much faster than doing <code>a += c * b</code>.</p>
<p>I was not expecting t... | 5 | 2016-09-05T07:03:30Z | 39,352,473 | <p>One thing to keep in mind is 'manual looping' in <code>numba</code> is very fast, essentially the same as the c-loop used by numpy operations.</p>
<p>In the first example there are two operations, a temporary array (<code>c * b</code>) is allocated / calculated, then that temporary array is added to <code>a</code>.... | 2 | 2016-09-06T15:13:48Z | [
"python",
"numba"
] |
Installation for pyzmq for Windows fails with error C2143, C4142 | 39,325,522 | <p>I have a windows 7 machine with python 2.7 and I am trying to install <code>pyzmq</code> following <a href="http://zeromq.org/docs:windows-installations" rel="nofollow">these</a> steps. I built <code>libzmq</code> got the binaries and copied them from <code>libzmq\bin\Win32\Debug\v140\dynamic\</code> to <code>libzmq... | 0 | 2016-09-05T07:16:46Z | 39,352,652 | <p>ZMQ usually provides <code>sln</code> files that will build from Microsoft Visual Studio. You will have to dig around a little to find it. You are better off trying to get that to work then going directly from the <code>python setup.py</code> that you are currently attempting. Note that you also need <code>libsodiu... | 0 | 2016-09-06T15:22:32Z | [
"python",
"windows",
"pyzmq"
] |
how to return item load in scrapy loop | 39,325,674 | <p>The code is as below , every time it returns only the first loop ,the last 9 loops disapeared .So what should I do to get all the loops ?</p>
<p>I have tried to add a "m = []" and m.append(l) ,but got a error "ERROR: Spider must return Request, BaseItem, dict or None, got 'ItemLoader'"</p>
<p>link is <a href="http... | 0 | 2016-09-05T07:27:39Z | 39,325,882 | <p>The error: </p>
<blockquote>
<p>ERROR: Spider must return Request, BaseItem, dict or None, got
'ItemLoader'</p>
</blockquote>
<p>is slightly misleading since you can also return a generator! What is happening here is that return breaks the loop and the whole function. You can turn this function into a generat... | 2 | 2016-09-05T07:43:16Z | [
"python",
"json",
"ajax",
"scrapy",
"web-crawler"
] |
Mongoengine: dynamic Fields with EmbededDocuments as values | 39,325,746 | <p>I have been using MapField till now as:</p>
<pre><code>class Game(EmbeddedDocument):
iscomplete = BooleanField()
score = IntField()
#other not dynamic fields
class Progress(Document):
user = ReferenceField(User, dbref=True)
games = MapField(EmbeddedDocumentField(Game))
created_at = DateTim... | 0 | 2016-09-05T07:33:40Z | 39,355,893 | <p>You can achive that using <a href="http://docs.mongoengine.org/guide/defining-documents.html#dynamic-document-schemas" rel="nofollow">dynamic document in mongengine</a>:</p>
<blockquote>
<p>DynamicDocument documents work in the same way as Document but any
data / attributes set to them will also be saved</p>
</... | 1 | 2016-09-06T18:46:34Z | [
"python",
"mongodb",
"mongoengine",
"embedded-documents"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.