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 |
|---|---|---|---|---|---|---|---|---|---|
Running Flask app on Windows raises "an operation was attempted on something that is not a socket" | 39,067,544 | <p>When running a basic Flask app I am getting this error in the shell and can't find how to solve this.</p>
<pre><code> Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) <br/>
Restarting with stat<br/>
Debugger is active!<br/>
Debugger pin code: 295-257-376<br/>
Exception in thread ... | 3 | 2016-08-21T18:29:10Z | 39,111,936 | <p>You're currently trying to execute this from a global python installation. It is a "good practice" to use virtual environments for python projects to keep each projects' pip install separate.</p>
<p>Start by running <code>pip install virtualenv</code></p>
<p>Then, navigate to your projects folder and execute <code... | 0 | 2016-08-23T22:55:17Z | [
"python",
"flask"
] |
Running Flask app on Windows raises "an operation was attempted on something that is not a socket" | 39,067,544 | <p>When running a basic Flask app I am getting this error in the shell and can't find how to solve this.</p>
<pre><code> Running on http://127.0.0.1:5000/ (Press CTRL+C to quit) <br/>
Restarting with stat<br/>
Debugger is active!<br/>
Debugger pin code: 295-257-376<br/>
Exception in thread ... | 3 | 2016-08-21T18:29:10Z | 39,236,998 | <p>i know it is not a solution to the core problem, but for me the issue only occurs when setting the debug flag to True. If you can use your app without the debug/reloading features you might want to give it a try:</p>
<pre><code>app.run(debug=False)
</code></pre>
<p>Meanwhile i am too searching for a way to actuall... | 0 | 2016-08-30T20:58:58Z | [
"python",
"flask"
] |
Create a new dict with means from a dict of dicts | 39,067,562 | <p>I have a dictionary like:</p>
<pre><code>dict = {'abc':{'a':1,'b':2,'c':3},
'bla':{'a':0,'b':9},
'ind':{'b':3,'c':4}
}
</code></pre>
<p>And I want to use list or dictionary comprehension to create a new dictionary which contains every inner key, and then the mean across all values for that inner key, e.g.:</p>
<... | 0 | 2016-08-21T18:31:20Z | 39,067,665 | <p>I know you specifically asked for dictionary/list comprehension, but I'm not sure it's possible to solve this problem with only those tools in an efficient way.</p>
<p>I think the code below is clear and reasonably succinct:</p>
<pre><code>from collections import defaultdict
outer = {
'abc': { 'a': 1, 'b': 2,... | 2 | 2016-08-21T18:42:10Z | [
"python",
"dictionary",
"list-comprehension",
"mean",
"dictionary-comprehension"
] |
Find all lines beginning with a digit | 39,067,585 | <p>What is the regex to extract all lines beginning with a digit?</p>
<p>I know the <code>^</code> character is used to match anything at the beginning of the line but I am not constructing it correct.</p>
<p>Here is what I have tried :</p>
<pre><code>re.findall('^[0-9]+',mystring).
</code></pre>
| -3 | 2016-08-21T18:33:20Z | 39,067,642 | <p>I'm guessing you want to match the entire the line but it is only matching the starting number. You need to include the greedy wildcard as well as the multiline argument to tell it you want to search many lines. Try:</p>
<pre><code>re.findall('^[0-9].*', mystring, re.MULTILINE)
</code></pre>
| 2 | 2016-08-21T18:39:09Z | [
"python",
"regex",
"python-2.7",
"python-3.x"
] |
Find all lines beginning with a digit | 39,067,585 | <p>What is the regex to extract all lines beginning with a digit?</p>
<p>I know the <code>^</code> character is used to match anything at the beginning of the line but I am not constructing it correct.</p>
<p>Here is what I have tried :</p>
<pre><code>re.findall('^[0-9]+',mystring).
</code></pre>
| -3 | 2016-08-21T18:33:20Z | 39,067,673 | <p>You forget the <code>re.MULTILINE</code> modifier and <code>.*</code> after <code>[0-9]</code> to match the rest of the line. If you <em>were</em> to use a regex, you would use <code>r"(?m)^[0-9].*"</code>. However, it is not the best way. Split with \n and iterate through the lines checking if the first char is a d... | 3 | 2016-08-21T18:43:35Z | [
"python",
"regex",
"python-2.7",
"python-3.x"
] |
Scrapy crawler doesnt work with a website i get partial results | 39,067,592 | <p>I'm new to Scrapy and Python. I have been working to extract data from 2 websites and they work really well if I do it directly with python. I have investigated and I want to crawl these websites:</p>
<ol>
<li>homedepot.com.mx/comprar/es/miguel-aleman/home (works perfectly)</li>
<li>vallenproveedora.com.mx/ (doesn'... | 2 | 2016-08-21T18:34:26Z | 39,113,822 | <p>You're seeing <code>['partial']</code> in your logs because the server at vallenproveedora.com.mx doesn't set the Content-Length header in its response; run <code>curl -I</code> to see for yourself. For more detail on the cause of the <code>partial</code> flag, see <a href="http://stackoverflow.com/questions/3360608... | 0 | 2016-08-24T03:14:14Z | [
"python",
"scrapy",
"web-crawler",
"partial"
] |
Determine if a day is a business day in Python / Pandas | 39,067,626 | <p>I currently have a program setup to run two different ways. One way is to run over a specified time frame, and the other way is to run everyday. However, when I have it set to run everyday, I only want it to continue if its a business day. Now from research I've seen that you can iterate through business days using ... | 0 | 2016-08-21T18:37:31Z | 39,068,260 | <p>Since <code>len</code> of <code>pd.bdate_range()</code> tells us how many business days are in the supplied range of dates, we can cast this to a <code>bool</code> to determine if a range of a single day is a business day:</p>
<pre><code>def is_business_day(date):
return bool(len(pd.bdate_range(date, date)))
</... | 0 | 2016-08-21T19:47:32Z | [
"python",
"date",
"datetime",
"pandas"
] |
Determine if a day is a business day in Python / Pandas | 39,067,626 | <p>I currently have a program setup to run two different ways. One way is to run over a specified time frame, and the other way is to run everyday. However, when I have it set to run everyday, I only want it to continue if its a business day. Now from research I've seen that you can iterate through business days using ... | 0 | 2016-08-21T18:37:31Z | 39,068,368 | <p>Please check this module - <a href="https://pypi.python.org/pypi/bdateutil/0.1" rel="nofollow">bdateutil</a></p>
<p>Please check the below code using above module :</p>
<pre><code>from bdateutil import isbday
from datetime import datetime,date
now = datetime.now()
val = isbday(date(now.year, now.month, now.day))
p... | 0 | 2016-08-21T20:01:51Z | [
"python",
"date",
"datetime",
"pandas"
] |
I can't install matplotlib | 39,067,640 | <p>Collecting matplotlib
Using cached matplotlib-1.5.2.tar.gz
Complete output from command python setup.py egg_info:
============================================================================
Edit setup.cfg to change the build options</p>
<pre><code>BUILDING MATPLOTLIB
matplotlib: yes [1.5.... | 0 | 2016-08-21T18:39:03Z | 39,067,856 | <p>I installed matplotlib with the .whl file and it worked for me. I got it from this website <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib" rel="nofollow">http://www.lfd.uci.edu/~gohlke/pythonlibs/#matplotlib</a>. Download the right .whl package ( i.e If you have Python 3.5.1 64 bit download matplotli... | 0 | 2016-08-21T19:04:38Z | [
"python",
"matplotlib",
"install"
] |
Django form not calling clean_<fieldname> (in this case clean_email) | 39,067,677 | <p>I couldn't find an answer to the following question, it took me a couple of hours to find out, hence I'm adding it. I'll add my approach of solving it and the answer.</p>
<p>I'm following a YouTube tutorial from <a href="https://www.youtube.com/watch?v=g0tvJsUAx7g&list=PLEsfXFp6DpzRcd-q4vR5qAgOZUuz8041S&ind... | 0 | 2016-08-21T18:43:54Z | 39,067,784 | <p>After using print statements for a while and reading questions that seemed similar but eventually didn't solve my problem, I decided to look into the source of Django (idea inspired by the <a href="http://stackoverflow.com/questions/1871746/django-form-not-calling-clean-fieldname">most similar question I could find<... | 0 | 2016-08-21T18:55:59Z | [
"python",
"django"
] |
Different counters in one pass of list of dicts | 39,067,732 | <p>I have a list of dictionaries in Python. Every element of the list corresponds to one day, and every element of the dictionary has information on a user's minute-by-minute activity.</p>
<p>Example:</p>
<pre><code>list_of_dicts = [
{u'activity':
{u'values': [
[1407729600, 3.0],
... | 0 | 2016-08-21T18:50:26Z | 39,067,879 | <p>Correct me if I'm wrong, but I would summarize your question as follows:</p>
<blockquote>
<p>Is there a way to compute multiple operations in one single pass of a list of dicts?</p>
</blockquote>
<p>In the general case this shouldn't really matter. If you're computing 15 operations, you're going to have to do a ... | 0 | 2016-08-21T19:06:43Z | [
"python",
"list",
"dictionary",
"counter"
] |
Python one liner with if in a loop | 39,067,759 | <p>I'm having a problem .</p>
<p>How can I write below one liner using function?</p>
<pre><code>def onlyPairs(string):
for x in string:
if int(x)%2:
return False
return True
print [string for string in map(str, myList) if onlyPairs(string) ]
</code></pre>
<p>I've been on it for hours, I ... | -4 | 2016-08-21T18:53:58Z | 39,067,798 | <p>Use a generator expression with <a href="https://docs.python.org/3/library/functions.html#all" rel="nofollow"><code>all()</code></a>:</p>
<pre><code>[item for item in myList if all(not int(x)%2 for x in str(item))]
</code></pre>
<p>But it seems that you want to check if all digits of a number are even. Which in th... | 1 | 2016-08-21T18:57:40Z | [
"python",
"python-2.7",
"python-3.x",
"list-comprehension"
] |
Python one liner with if in a loop | 39,067,759 | <p>I'm having a problem .</p>
<p>How can I write below one liner using function?</p>
<pre><code>def onlyPairs(string):
for x in string:
if int(x)%2:
return False
return True
print [string for string in map(str, myList) if onlyPairs(string) ]
</code></pre>
<p>I've been on it for hours, I ... | -4 | 2016-08-21T18:53:58Z | 39,067,866 | <p>Here's a possible solution:</p>
<pre><code>myList = [1200, 3520, 2002, 2006, 1230]
print map(str, filter(lambda x: all([int(d) % 2 == 0 for d in str(x)]), myList))
</code></pre>
| 0 | 2016-08-21T19:05:11Z | [
"python",
"python-2.7",
"python-3.x",
"list-comprehension"
] |
Python one liner with if in a loop | 39,067,759 | <p>I'm having a problem .</p>
<p>How can I write below one liner using function?</p>
<pre><code>def onlyPairs(string):
for x in string:
if int(x)%2:
return False
return True
print [string for string in map(str, myList) if onlyPairs(string) ]
</code></pre>
<p>I've been on it for hours, I ... | -4 | 2016-08-21T18:53:58Z | 39,068,229 | <p>use sets:</p>
<pre><code>myList = [1200, 3520, 2002, 2006, 1230]
print [num for num in myList if not set(str(num)) - set('02468')]
</code></pre>
| 2 | 2016-08-21T19:44:57Z | [
"python",
"python-2.7",
"python-3.x",
"list-comprehension"
] |
DataFrame with MultiIndex to dict | 39,067,831 | <p>I have a dataframe with a MultiIndex. I am wondering whether I created the data frame in the correct manner (see below).</p>
<pre><code> 01.01 02.01 03.01 04.01
bar total1 40 52 18 11
total2 36 85 5 92
baz total1 23 39 45 70
total2 50 4... | 1 | 2016-08-21T19:02:05Z | 39,074,579 | <p>Try:</p>
<pre><code>df.groupby(level=0).apply(lambda df: df.xs(df.name).to_dict()).to_dict()
{'bar': {'01.01': {'total1': 40, 'total2': 36},
'02.01': {'total1': 52, 'total2': 85},
'03.01': {'total1': 18, 'total2': 5},
'04.01': {'total1': 11, 'total2': 92}},
'baz': {'01.01': {'total1': 23, 'total2': 50},
'... | 1 | 2016-08-22T08:25:19Z | [
"python",
"pandas",
"dictionary"
] |
'QuerySet' object has no attribute 'filter_on_search' Python Django | 39,067,834 | <p>Can anyone please suggest me why I am getting this error. </p>
<p>Following is model with Manager</p>
<pre><code>class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
customer_name = models.CharField(max_length=256)
customer_mobile = models.CharField(max_length=10)
cu... | 0 | 2016-08-21T19:02:16Z | 39,071,427 | <p>The method you have created in <code>MyClassManager</code> has the <a href="https://docs.djangoproject.com/en/stable/topics/db/managers/#modifying-a-manager-s-initial-queryset" rel="nofollow">wrong name</a>:</p>
<pre><code>def get_query_set(self):
</code></pre>
<p>Which should instead be:</p>
<pre><code># query_s... | 1 | 2016-08-22T04:28:41Z | [
"python",
"django"
] |
'QuerySet' object has no attribute 'filter_on_search' Python Django | 39,067,834 | <p>Can anyone please suggest me why I am getting this error. </p>
<p>Following is model with Manager</p>
<pre><code>class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
customer_name = models.CharField(max_length=256)
customer_mobile = models.CharField(max_length=10)
cu... | 0 | 2016-08-21T19:02:16Z | 39,071,454 | <p>You are using <code>filter_on_search</code> on your queryset. Instead, you need to use it in lieu of <code>objects</code>. </p>
<p>So, you would star by doing </p>
<pre><code>obj_list = klass.filter_on_search
</code></pre>
<p>However, looks like you may want to move all of your logic from the view to the manager.... | 0 | 2016-08-22T04:31:11Z | [
"python",
"django"
] |
Rename pandas column values from unstacked pivot table | 39,067,839 | <p>I have pandas pivot table <code>merge2</code> that looks like:</p>
<pre><code> Site TripDate Volume Early_Vol Percent_Vol
0 024l 2004-12-02 1117.134948 1117.134948 0.000000
1 024l 2005-05-07 390.980708 1117.134948 -0.650015
2 024l 2006-10-07 321.110175 1117.134948 -0.712559
3 024... | 1 | 2016-08-21T19:02:58Z | 39,067,909 | <p>try this:</p>
<pre><code>t.columns = t.columns.droplevel()
</code></pre>
| 1 | 2016-08-21T19:08:51Z | [
"python",
"pandas",
"rename"
] |
NameError: name 'file' is not defined | 39,067,840 | <p>This works in Python 2.7 but not in 3.5.</p>
<pre><code>def file_read(self, input_text):
doc = (file.read(file(input_text))).decode('utf-8', 'replace')
</code></pre>
<p>I'm trying to open this file, input_text is a path value from argparse.</p>
<p>I get this error.</p>
<pre><code>NameError: name 'file' is n... | -1 | 2016-08-21T19:02:59Z | 39,067,943 | <p>Your original code works in Python 2.7 but it is bad style there. The <code>file</code> for this use was deprecated long time ago in favour of using <code>open</code>, and instead of calling the <code>file.read</code> passing the file as the argument you should have just called the <code>.read</code> method on the r... | 2 | 2016-08-21T19:12:43Z | [
"python",
"file",
"python-3.x"
] |
Calling a function, stored as a value in a dictionary, if the user's input matches the value's key | 39,067,842 | <p>I'm currently creating a simple interactive fiction (IF) game in Python. In addition to the commands relevant to each room they explore, I would like for the player to have access to a list of "global commands" that can be called at anytime (inventory, help, etc).</p>
<p>I used <a href="http://stackoverflow.com/que... | 3 | 2016-08-21T19:03:18Z | 39,068,016 | <p>Make the values in the global_commands dictionary the functions. Don't include parentheses as you don't want to call them yet.</p>
<pre><code>global_commands = {
'inventory': inventory,
'help': game_help,
}
</code></pre>
<p>Then look up the command in the dictionary and execute the corresponding function:<... | 6 | 2016-08-21T19:21:17Z | [
"python"
] |
Is removeWidget() necessary | 39,067,900 | <p>I just started with PyQt and I'm trying to sort elements in a <code>QGridLayout</code>. In the code below, I'm moving an existing button from the cell <code>(4,1)</code> to <code>(0,0)</code>. My confusion arises because either using <code>removeWidget</code> or not, both pieces of code behave exactly the same:</p>
... | 1 | 2016-08-21T19:08:23Z | 39,069,593 | <p>A widget can only belong to one layout. Before a widget is added to a layout, Qt will check to see if it has ever been in a layout, and if so, it will remove it from whatever layout it currently belongs to. The widget will also be automatically reparented to the layout's current parent-widget.</p>
<p>A widget also ... | 1 | 2016-08-21T23:03:30Z | [
"python",
"user-interface",
"pyqt",
"pyqt4"
] |
How can I create a matrix from a list? | 39,067,946 | <p>I am given a list which somehow represents a matrix, but it is in the list format, like</p>
<pre><code>["OOX","XOX","XOX"]
</code></pre>
<p>Is there any way i can convert it into a matrix?
I have gone through numpy, but could not figure out!</p>
| 0 | 2016-08-21T19:12:57Z | 39,068,021 | <p>numpy is overkill for this. For something like Tic-tac-toe, a list of lists is enough.</p>
<p>If <code>'OOX'</code> is a string, then <code>list('OOX')</code> is the list <code>['O','O','O']</code>.</p>
<p>You can combine <code>list</code> with a list comprehension:</p>
<p>Something like:</p>
<pre><code>>>... | 1 | 2016-08-21T19:21:44Z | [
"python",
"matrix"
] |
How can I create a matrix from a list? | 39,067,946 | <p>I am given a list which somehow represents a matrix, but it is in the list format, like</p>
<pre><code>["OOX","XOX","XOX"]
</code></pre>
<p>Is there any way i can convert it into a matrix?
I have gone through numpy, but could not figure out!</p>
| 0 | 2016-08-21T19:12:57Z | 39,068,322 | <p>As simple as this:</p>
<pre><code>In [4]: a = ["OOX","XOX","XOX"]
In [5]: m = np.array([*map(list, a)])
In [6]: m
Out[6]:
array([['O', 'O', 'X'],
['X', 'O', 'X'],
['X', 'O', 'X']],
dtype='<U1')
</code></pre>
| 0 | 2016-08-21T19:55:42Z | [
"python",
"matrix"
] |
Error : Can't multiply sequence by non-int of type 'Mul' | 39,067,978 | <p>I defined a method below that is supposed to take 5 integer/float values as input, and one list object (the <code>lst</code> parameter) and return only the positive solutions for <code>r</code> in the equation <code>F</code>. The formula for F should return a list where each element is multiplied/subtracted using th... | 1 | 2016-08-21T19:17:01Z | 39,068,120 | <p>You forgot to pass the instance of the object (or <code>self</code>) on which the code is being called to the method. Since there was no <code>self</code>, you were getting the non-int error, because T0 became <code>self</code>, <code>T</code> became <code>T0</code>, and then your <code>lst</code> was being used as ... | 1 | 2016-08-21T19:32:14Z | [
"python",
"list",
"python-2.7"
] |
Linking numpy extensions | 39,068,018 | <p>I am trying to compile an extension with the numpy C api and setuptools. The code compiles fine, but when running it from python, I get:</p>
<pre><code>ImportError: ./_pyav.so: undefined symbol: PyArray_SimpleNewFromData
</code></pre>
<p>My setup.py looks roughly as follows:</p>
<pre><code>import numpy
from setu... | 0 | 2016-08-21T19:21:33Z | 39,068,866 | <p>Silly me,</p>
<p>I had forgotten "#include "numpy/arrayobject.h".</p>
| 0 | 2016-08-21T21:06:25Z | [
"python",
"c",
"numpy",
"linker"
] |
Filter rows in Spark dataframe from the words in RDD | 39,068,065 | <p>I have the following commands in spark,</p>
<pre><code>data = sqlContext.sql("select column1, column2, column3 from table_name")
words = sc.textFile("words.txt")
</code></pre>
<p><code>words.txt</code> has a bunch of words and data has three string columns taken from <code>table_name</code>.</p>
<p>Now I want to... | 4 | 2016-08-21T19:26:29Z | 39,069,180 | <p>You may read the words from the <code>words.txt</code>, and build a regex pattern like this:</p>
<pre><code>(?s)^(?=.*word1)(?=.*word2)(?=.*word3)
</code></pre>
<p>etc. where <code>(?s)</code> allows <code>.</code> to match <em>any</em> symbol, <code>^</code> matches the string start position and then each <code>(... | 4 | 2016-08-21T21:52:58Z | [
"python",
"regex",
"apache-spark",
"pyspark",
"spark-dataframe"
] |
Trouble running new Python version after uninstalling older and installing new (MAC) | 39,068,070 | <p>I was trying to uninstall my Anaconda version of Python and reinstall the regular Python 3.5 version (mac). I used the answer from <a href="http://stackoverflow.com/questions/22585235/python-anaconda-how-to-safely-uninstall">this SO question</a> to remove the Anaconda folder using <code>rm -rf ~/anaconda</code> and ... | 1 | 2016-08-21T19:27:05Z | 39,068,165 | <p>Based on your comments, it seems like bash has stored <code>/Users/paul/anaconda/bin/python</code> as the entry for <code>python</code> for performance reasons. <code>hash -d python</code> should remove this entry and use normal path resolution.</p>
| 3 | 2016-08-21T19:37:02Z | [
"python",
"bash",
"osx",
"anaconda",
"python-install"
] |
How to append a dataframe to existing excel sheet? | 39,068,124 | <p>The function gets called several times. I have kept a count so that if its called for the first time, A workbook is created. Then I write to that workbook using <code>pd.ExcelWrite()</code>. Next time <code>else:</code> gets executed and the same workbook is opened. Its first sheet is selected, its last row is found... | 1 | 2016-08-21T19:32:36Z | 39,068,188 | <p>Thanks to @ski.</p>
<p>Please refer his ans on the same question</p>
<p><a href="http://stackoverflow.com/questions/20219254/how-to-write-to-an-existing-excel-file-without-overwriting-data-using-pandas">How to write to an existing excel file without overwriting data (using pandas)?</a></p>
<pre><code>import panda... | 1 | 2016-08-21T19:39:06Z | [
"python",
"pandas",
"xlrd",
"xlsxwriter"
] |
How to append a dataframe to existing excel sheet? | 39,068,124 | <p>The function gets called several times. I have kept a count so that if its called for the first time, A workbook is created. Then I write to that workbook using <code>pd.ExcelWrite()</code>. Next time <code>else:</code> gets executed and the same workbook is opened. Its first sheet is selected, its last row is found... | 1 | 2016-08-21T19:32:36Z | 39,068,733 | <p>you can do it this way:</p>
<pre><code>df = pd.DataFrame(np.arange(1, 31), columns=['val'])
fn = 'd:/temp/test.xlsx'
count = 0
writer = pd.ExcelWriter(fn)
for chunk in np.split(df, 3):
chunk.to_excel(writer, index=False, header=(count==0), startrow=count+(count!=0))
count += len(chunk)
writer.save()
</co... | 0 | 2016-08-21T20:49:15Z | [
"python",
"pandas",
"xlrd",
"xlsxwriter"
] |
Closing a browser using python | 39,068,146 | <p>I am trying to make an internet radio based on opening and closing the web browser to start and stop the radio but I can't for some reason close the browser using different methods.</p>
<p>I have already tried using the <strong>subprocess</strong> method.</p>
<pre><code>import subprocess as sp
web = sp.Popen("epip... | 2 | 2016-08-21T19:35:18Z | 39,087,332 | <p>It seems like you want to close the browser that just opened. Assuming that you only have one epiphany instance open, you can use</p>
<pre><code>sp.Popen("killall epiphany")
</code></pre>
<p>Which will kill all instance of epiphany.
If you have multiple instances you will need to get the id of the running epiphany... | 0 | 2016-08-22T19:29:45Z | [
"python",
"selenium",
"raspberry-pi3"
] |
Closing a browser using python | 39,068,146 | <p>I am trying to make an internet radio based on opening and closing the web browser to start and stop the radio but I can't for some reason close the browser using different methods.</p>
<p>I have already tried using the <strong>subprocess</strong> method.</p>
<pre><code>import subprocess as sp
web = sp.Popen("epip... | 2 | 2016-08-21T19:35:18Z | 39,107,243 | <p>after doing alot of research i found out that i could kill the browser by typing</p>
<pre><code>pkill epiphany
</code></pre>
<p>into the terminal so i just used this code to close it in python:</p>
<pre><code>import os
os.system("pkill epiphany")
</code></pre>
| 0 | 2016-08-23T17:19:35Z | [
"python",
"selenium",
"raspberry-pi3"
] |
Why doesn't QtConsole echo next()? | 39,068,174 | <p>I found this question about iterator behavior in Python: </p>
<p><a href="https://stackoverflow.com/questions/16814984/python-list-iterator-behavior-and-nextiterator">Python list iterator behavior and next(iterator)</a></p>
<p>When I typed in the code: </p>
<pre><code>a = iter(list(range(10)))
for i in a:
pri... | 6 | 2016-08-21T19:37:47Z | 39,084,476 | <p>This is just a choice the developers of <code>IPython</code> (on which the <code>QtConsole</code> is based) made regarding what should be echoed back to the user. </p>
<p>Specifically, in the <a href="https://github.com/ipython/ipython/blob/master/IPython/core/interactiveshell.py#L198" rel="nofollow"><code>Interact... | 2 | 2016-08-22T16:28:50Z | [
"python",
"interpreter",
"jupyter",
"python-internals"
] |
Google App Engine Send Mail Not Working | 39,068,177 | <p>I'm trying to use Python and Google App Engine to send automated emails to certain addresses:</p>
<pre><code> message = mail.EmailMessage(sender="noreply@"+app_identity.get_application_id()+".appspotmail.com",subject="Verify Email",to="Bob Person <bob.person@gmail.com>")
message.body = "Hey, someon... | 0 | 2016-08-21T19:37:55Z | 39,068,224 | <p>The sender's email ID should be added as a owner in the appengine project or use service account ID as sender.</p>
| 2 | 2016-08-21T19:44:22Z | [
"python",
"email",
"google-app-engine"
] |
Google App Engine Send Mail Not Working | 39,068,177 | <p>I'm trying to use Python and Google App Engine to send automated emails to certain addresses:</p>
<pre><code> message = mail.EmailMessage(sender="noreply@"+app_identity.get_application_id()+".appspotmail.com",subject="Verify Email",to="Bob Person <bob.person@gmail.com>")
message.body = "Hey, someon... | 0 | 2016-08-21T19:37:55Z | 39,192,003 | <p>It turns out, the solution was to remove an appspot.com link. I ended up using a bitly API to replace the links with bitly ones. Thank you everyone for helping with this one, it'd be really helpful if this behaviour was officially documented.</p>
| 0 | 2016-08-28T13:53:30Z | [
"python",
"email",
"google-app-engine"
] |
Setting the alpha value of a custom palette in seaborn | 39,068,206 | <p>I am modifying a piece of code I found in the seaborn documentation, in order to design a palette that is common to matplotlib and seaborn. The code below work great, however, if you plot many points (5000 in my example), the darker color dominates the chart.
A quick fix to that is to set the alpha value of one (or ... | 0 | 2016-08-21T19:41:16Z | 39,070,407 | <p>You can set the alpha as part of the colors in your colormap:</p>
<pre><code>custom = [(0xD1/0xFF, 0xEC/0xFF, 0x9C/0xFF, 1), (0xF1/0xFF, 0xEB/0xFF, 0xF4/0xFF, 0.5)]
my_cmap = mpl.colors.ListedColormap(custom)
</code></pre>
<p>Here I gave the second color alpha of 0.5; you can do it with the other color if you want... | 2 | 2016-08-22T01:50:55Z | [
"python",
"seaborn"
] |
How to count outliers for all columns in Python? | 39,068,214 | <p>I have dataset with three columns in Python notebook. It seems there are too many outliers out of 1.5 times IQR. I'm think how can I count the outliers for all columns?</p>
<p>If there are too many outliers, I may consider to remove the points considered as outliers for more than one feature. If so, how I can count... | 0 | 2016-08-21T19:42:02Z | 39,068,451 | <p>Similar to <a href="http://stackoverflow.com/a/35606727/2285236">Romain X.'s answer</a> but operates on the DataFrame instead of Series.</p>
<p>Random data:</p>
<pre><code>np.random.seed(0)
df = pd.DataFrame(np.random.randn(100, 5), columns=list('ABCDE'))
df.iloc[::10] += np.random.randn() * 2 # this hopefully in... | 2 | 2016-08-21T20:14:29Z | [
"python",
"pandas"
] |
Passing a numpy array to a tensorflow Queue | 39,068,259 | <p>I have a NumPy array and would like to read it in TensorFlow's code using a <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/io_ops.html#queues" rel="nofollow">Queue</a>. I would like the queue to return the whole data shuffled, some specified number of epochs and throw an error after that. It woul... | 0 | 2016-08-21T19:47:25Z | 39,068,577 | <p>You could create another queue, enqueue your data onto it <code>num_epoch</code> times, close it, and then hook it up to your <code>batch</code>. To save memory, you can make this queue small, and enqueue items onto it in parallel. There will be a bit of mixing between epochs. To fully prevent mixing, you could take... | 2 | 2016-08-21T20:29:56Z | [
"python",
"numpy",
"tensorflow"
] |
How to retrieve the value of a many2many field for each sale order? | 39,068,266 | <p>I've created a many2many field in the sale.order model that it's related with fleet.vehicle model (id).</p>
<p>How it's showed in the follow image:</p>
<p>IMAGE 1: <a href="http://i.stack.imgur.com/747Jz.png" rel="nofollow"><img src="http://i.stack.imgur.com/747Jz.png" alt="enter image description here"></a></p>
... | 1 | 2016-08-21T19:48:12Z | 39,069,273 | <p>The field isn't going to be available on the table you declared it, it's a Many2many relationship so a separate 'join' table is going to be created for it, the name of that table is</p>
<p><code>x_fleet_vehicle_sale_order_rel</code></p>
<p>That table will contain the fields <code>sale_order_id</code> and <code>fle... | 1 | 2016-08-21T22:06:14Z | [
"python",
"openerp",
"odoo-8",
"odoo-9"
] |
How to retrieve the value of a many2many field for each sale order? | 39,068,266 | <p>I've created a many2many field in the sale.order model that it's related with fleet.vehicle model (id).</p>
<p>How it's showed in the follow image:</p>
<p>IMAGE 1: <a href="http://i.stack.imgur.com/747Jz.png" rel="nofollow"><img src="http://i.stack.imgur.com/747Jz.png" alt="enter image description here"></a></p>
... | 1 | 2016-08-21T19:48:12Z | 39,069,278 | <p>The relation is not stored in the <code>sale_order</code> table. Since it's <code>many2many</code>, it is stored in a relational table. Based on your screenshot, your relational table is this one: <code>x_fleet_vehicle_sale_order_rel</code></p>
<p>To query for the vehicles, you have to join through this table lik... | 2 | 2016-08-21T22:07:50Z | [
"python",
"openerp",
"odoo-8",
"odoo-9"
] |
How to apply a proxy in libtorrent? | 39,068,376 | <p>I am creating a torrent client and would like to add a proxy to it. I just can't seem to get it to work.i am using "<a href="http://ipmagnet.services.cbcdn.com" rel="nofollow">http://ipmagnet.services.cbcdn.com</a>" to check what IP address my client is handing out to peers and trackers.How can I fix my code to appl... | 0 | 2016-08-21T20:03:26Z | 39,069,606 | <p>I would suggest you look at alerts generated by your session, to see if anything is failing to use the proxy.</p>
<p>By default, libtorrent considers the proxy to be best-effort. If it fails for any reason, libtorrent will fall back to attempting direct connections.</p>
<p>If you would like to force using the prox... | 0 | 2016-08-21T23:07:27Z | [
"python",
"proxy",
"libtorrent"
] |
Absolute Import Not Working, But Relative Import Does | 39,068,391 | <p>Here is my app structure:</p>
<pre><code>foodo/
setup.py
foodo/
__init__.py
foodo.py
models.py
</code></pre>
<p><code>foodo/foodo/foodo.py</code> imports classes from the <code>models.py</code> module:</p>
<pre><code>from foodo.models import User
</code></pre>
<p>which throws an <... | 0 | 2016-08-21T20:06:25Z | 39,068,432 | <p>You have a <em>local</em> module <code>foodoo</code> inside the <code>foodoo</code> package. Imports in Python 2 always first look for names in the current package before looking for a top-level name.</p>
<p>Either rename the <code>foodoo</code> module inside the <code>foodoo</code> package (eliminating the possibi... | 4 | 2016-08-21T20:11:38Z | [
"python",
"python-2.7",
"python-import",
"importerror"
] |
Using apply() method on SFrame issues | 39,068,428 | <p><strong>Background:</strong> I have an SFrame that contains numbers indicting how close a dog image is to other images. Usually the dog image should be closest to another dog image but the point is to test the evaluation method</p>
<p>My SFrame is called dog_distances (1000 rows x 4 columns):</p>
<pre><code>dog-au... | 0 | 2016-08-21T20:11:19Z | 39,074,868 | <p>Please try this:</p>
<pre><code>dog_distances['new_column'] = dog_distances.apply(lambda row: 1 if row['dog-dog'] == min(row.values()) else 0)
</code></pre>
<p>Add</p>
<p>Hi Steven,</p>
<p>This code works correctly in my laptop. Please see the link below.</p>
<ol>
<li><p><a href="http://i.stack.imgur.com/9gFjy.... | 0 | 2016-08-22T08:40:48Z | [
"python",
"apply",
"graphlab",
"sframe"
] |
Using apply() method on SFrame issues | 39,068,428 | <p><strong>Background:</strong> I have an SFrame that contains numbers indicting how close a dog image is to other images. Usually the dog image should be closest to another dog image but the point is to test the evaluation method</p>
<p>My SFrame is called dog_distances (1000 rows x 4 columns):</p>
<pre><code>dog-au... | 0 | 2016-08-21T20:11:19Z | 39,089,515 | <p>I figured out the solution:</p>
<p>The problem I think is all documentation suggests that .apply() goes row by row.
I assumed that this meant, as it ran a function on a given row, the variable passed was the row number as an integer.</p>
<p>In fact, the variable/object/text that is passed to .apply() is <code>sfra... | 0 | 2016-08-22T22:12:28Z | [
"python",
"apply",
"graphlab",
"sframe"
] |
Python logger doesn't adhere to the set level | 39,068,465 | <p>I created a logger in the Python3 interactive prompt:</p>
<pre><code>>>> import logging
>>> logger = logging.getLogger('foo')
>>> logger.setLevel(logging.INFO)
>>> logger.warn('bar')
bar
>>> logger.info('bar')
>>>
</code></pre>
<p>I'd expect <code>logger.info<... | 2 | 2016-08-21T20:16:42Z | 39,068,547 | <p>Actually, in your case neither should output anything since you haven't configured logging. You'll need to run <code>logging.basicConfig()</code> or add a handler to your logger to expect any output:</p>
<pre><code>In [1]: import logging
In [2]: logger = logging.getLogger('foo')
In [3]: logger.setLevel(logging.IN... | 1 | 2016-08-21T20:26:03Z | [
"python",
"python-3.x",
"logging"
] |
Python: Python.h file missing | 39,068,598 | <p>I am using Ubuntu 16.04. I am trying to install Murmurhash python library but it is throwing error: command 'x86_64-linux-gnu-gcc' failed with exit status 1 . I looked on Internet and it is says that this error is due to missing python header files. So i did </p>
<pre><code>sudo apt-get install python-dev
</code>... | 0 | 2016-08-21T20:32:33Z | 39,089,092 | <p>I just tried a docker container with <code>ubuntu 16.04</code></p>
<pre><code>apt-get update
apt-get install -y python-pip
pip install mmh3
</code></pre>
<p>That seems to be working. In your machine, you can just try.</p>
<pre><code>sudo apt-get install -y python-pip
sudo pip install mmh3
</code></pre>
<p>With t... | 0 | 2016-08-22T21:34:49Z | [
"python",
"gcc",
"anaconda",
"murmurhash"
] |
Skip XML tag if attribute is missing | 39,068,602 | <p>I am trying to get data from the XML file underneath. For each type the explanation should be right next to it. </p>
<p>For example:</p>
<p>Orange They belong to the Citrus.They cannot grow at a temperature below
Lemon They belong to the Citrus.They cannot grow at a temperature below</p>
<pre><code><Fruits&... | 1 | 2016-08-21T20:33:03Z | 39,068,649 | <p>Using <em>xml.etree</em>, just try to find the <em>Explanation</em> child:</p>
<pre><code>from xml.etree import ElementTree as et
root = et.fromstring(xml)
for node in root.iter("Fruit"):
if node.find("Explanation") is not None:
print(node.find("Family").text)
</code></pre>
<p>You could also use an x... | 1 | 2016-08-21T20:38:36Z | [
"python",
"xml"
] |
List Index Out Of Range error when not out of range | 39,068,665 | <p>I have a data file which only contains the following line:</p>
<pre><code>"testA" "testB":1:"testC":2
</code></pre>
<p>Now when I split this line, and print the resulting list(w) I get the following:</p>
<pre><code>['"testA"', '"testB":1:"testC":2']
[]
</code></pre>
<p>Now when I want to access <code>w[0]</code... | 0 | 2016-08-21T20:40:29Z | 39,068,691 | <p>working for me without any error:</p>
<pre><code>>>> a = '"testA" "testB":1:"testC":2'
>>> b = a.split(' ')
>>> b
['"testA"', '"testB":1:"testC":2']
>>> b[0]
'"testA"'
>>> b[1]
'"testB":1:"testC":2'
</code></pre>
<p>ae you doing anything different?</p>
| 0 | 2016-08-21T20:44:23Z | [
"python",
"list",
"indexing"
] |
List Index Out Of Range error when not out of range | 39,068,665 | <p>I have a data file which only contains the following line:</p>
<pre><code>"testA" "testB":1:"testC":2
</code></pre>
<p>Now when I split this line, and print the resulting list(w) I get the following:</p>
<pre><code>['"testA"', '"testB":1:"testC":2']
[]
</code></pre>
<p>Now when I want to access <code>w[0]</code... | 0 | 2016-08-21T20:40:29Z | 39,068,862 | <p>Your code does not crash on <code>w[1]</code> on the <code>"testA" "testB":1:"testC":2</code> line, otherwise it would <em>not</em> print <code>"testB":1:"testC":2</code>. Note the additional <code>[]</code> in your output? Your file contains some more empty lines, which are split to <code>[]</code>, and which will ... | 1 | 2016-08-21T21:04:56Z | [
"python",
"list",
"indexing"
] |
List Index Out Of Range error when not out of range | 39,068,665 | <p>I have a data file which only contains the following line:</p>
<pre><code>"testA" "testB":1:"testC":2
</code></pre>
<p>Now when I split this line, and print the resulting list(w) I get the following:</p>
<pre><code>['"testA"', '"testB":1:"testC":2']
[]
</code></pre>
<p>Now when I want to access <code>w[0]</code... | 0 | 2016-08-21T20:40:29Z | 39,108,912 | <p>I also cannot reproduce your error but want to share a tip that I use in situations where I'm reading from a file and splitting on a delimiter.</p>
<pre><code>cleaned_list = [ a.strip() for a in input_line.split(' ') if a ]
</code></pre>
<p>Simple and sanitizes the split list well. </p>
| 0 | 2016-08-23T19:07:41Z | [
"python",
"list",
"indexing"
] |
List Index Out Of Range error when not out of range | 39,068,665 | <p>I have a data file which only contains the following line:</p>
<pre><code>"testA" "testB":1:"testC":2
</code></pre>
<p>Now when I split this line, and print the resulting list(w) I get the following:</p>
<pre><code>['"testA"', '"testB":1:"testC":2']
[]
</code></pre>
<p>Now when I want to access <code>w[0]</code... | 0 | 2016-08-21T20:40:29Z | 39,133,133 | <p>The answer was that the program read the next line after the first one which it split, and that line was empty. So as soon as it tried to index the content of that (empty line) it crashed. That's why it DID print the first line, and then crashed. Thanks a lot for your help, though!</p>
| 0 | 2016-08-24T21:13:54Z | [
"python",
"list",
"indexing"
] |
Tensorflow: Using weights trained in one model inside another, different model | 39,068,703 | <p>I'm trying to train an LSTM in Tensorflow using minibatches, but after training is complete I would like to use the model by submitting one example at a time to it. I can set up the graph within Tensorflow to train my LSTM network, but I can't use the trained result afterward in the way I want.</p>
<p>The setup c... | 2 | 2016-08-21T20:45:53Z | 39,079,555 | <p><strong>What is the proper way to move trained LSTM weights from one graph to another?</strong></p>
<p>You can create your decoding graph first (with a saver object to save the parameters) and create a GraphDef object that you can import in your bigger training graph:</p>
<pre><code>basegraph = tf.Graph()
with bas... | 1 | 2016-08-22T12:27:34Z | [
"python",
"tensorflow",
"lstm"
] |
Kombu, RabbitMQ: Ack message more than once in a consumer mixin | 39,068,790 | <p>I have stumbled upon this problem <a class='doc-link' href="http://stackoverflow.com/documentation/python/drafts/6079">while I was documenting Kombu</a> for the new SO documentation project.</p>
<p>Consider the following Kombu code of a <a href="http://docs.celeryproject.org/projects/kombu/en/latest/reference/kombu... | 1 | 2016-08-21T20:56:53Z | 39,072,173 | <h1>Solutions</h1>
<h2>1 - Checking <code>message.acknowledged</code></h2>
<p>The <code>message.acknowledged</code> flag checks whether the message is already ACK-ed:</p>
<pre class="lang-python prettyprint-override"><code>def print_upper(body, message):
print body.upper()
if not message.acknowledged:
... | 0 | 2016-08-22T05:55:05Z | [
"python",
"rabbitmq",
"kombu",
"message-ack"
] |
Does tkinter arrowshape require a tuple but stores as text? | 39,068,796 | <p>I ran into a problem, since pulling <em>options["arrowshape"]</em> from the tkinter canvas resulted in a string "x y z", while setting the arrowshape in <em>create_line</em> will use a tuple [x,y,z] and not a string...
Is this correct in Python 2.7.10+</p>
| 0 | 2016-08-21T20:57:36Z | 39,068,870 | <p>This is how you create an arrow:</p>
<pre><code>from tkinter import *
root = Tk()
can = Canvas(root, bg='white')
ar = can.create_line(5, 5, 100, 70, arrow='last', arrowshape='20 40 10')
can.pack()
root.mainloop()
</code></pre>
<p>You need to pass a string (or a list or a tuple) representing the shape of the arr... | 0 | 2016-08-21T21:06:36Z | [
"python"
] |
Cannot compare type 'Timestamp' with type 'int' | 39,068,813 | <p>When running the following code:</p>
<pre><code>for row,hit in hits.iterrows():
forwardRows = data[data.index.values > row];
</code></pre>
<p>I get this error:</p>
<pre><code>TypeError: Cannot compare type 'Timestamp' with type 'int'
</code></pre>
<p>If I look into what is being compared here I have these... | 3 | 2016-08-21T20:59:55Z | 39,069,304 | <p>Although this isn't a direct answer to your question, I have a feeling that this is what you're looking for: <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.truncate.html" rel="nofollow">pandas.DataFrame.truncate</a></p>
<p>You could use it as follows:</p>
<pre><code>for row, hit in... | 1 | 2016-08-21T22:11:57Z | [
"python",
"pandas"
] |
Cannot compare type 'Timestamp' with type 'int' | 39,068,813 | <p>When running the following code:</p>
<pre><code>for row,hit in hits.iterrows():
forwardRows = data[data.index.values > row];
</code></pre>
<p>I get this error:</p>
<pre><code>TypeError: Cannot compare type 'Timestamp' with type 'int'
</code></pre>
<p>If I look into what is being compared here I have these... | 3 | 2016-08-21T20:59:55Z | 39,069,325 | <p>When using <code>values</code> you put it into <code>numpy</code> world. Instead, try</p>
<pre><code>for row,hit in hits.iterrows():
forwardRows = data[data.index > row];
</code></pre>
| 2 | 2016-08-21T22:15:25Z | [
"python",
"pandas"
] |
Return diagonal elements of scipy sparse matrix | 39,068,833 | <p>Given a <code>scipy.sparse.csr.csr_matrix</code>, is there a quick way to return the elements on the diagonal?</p>
<p>The reason I would like to do this is to compute <code>inv(D) A</code>, where <code>D</code> is a diagonal matrix whose diagonal entries agree with <code>A</code> (<code>A</code> is my sparse matrix... | 1 | 2016-08-21T21:02:15Z | 39,068,857 | <p>Use <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.sparse.csr_matrix.diagonal.html#scipy.sparse.csr_matrix.diagonal" rel="nofollow">csr_matrix.diagonal()</a>:</p>
<blockquote>
<p>Returns the main diagonal of the matrix</p>
</blockquote>
<p>Example:</p>
<pre><code>>>> import numpy as... | 2 | 2016-08-21T21:04:45Z | [
"python",
"numpy",
"matrix",
"scipy",
"diagonal"
] |
How to append to a file from stream rather than overwrite in Python | 39,068,864 | <p>I am new to python so this maybe a simple question but I have a kafka consumer from which I read in messages. Every time a new message comes in it rewrites the previous message into the order.json file however I want to append it instead. Additionally, I want to make sure the messages do not get read in no faster th... | 0 | 2016-08-21T21:05:07Z | 39,068,879 | <p>Open outside the loop:</p>
<pre><code>with open('order.json', 'w') as file:
for message in consumer:
file.write(message.value.decode('UTF-8'))
</code></pre>
<p>Or open outside and use <code>a</code> if you are going to be appending for each run:</p>
<pre><code>with open('order.json', 'a') a... | 0 | 2016-08-21T21:07:42Z | [
"python",
"file",
"stream",
"message"
] |
How to append to a file from stream rather than overwrite in Python | 39,068,864 | <p>I am new to python so this maybe a simple question but I have a kafka consumer from which I read in messages. Every time a new message comes in it rewrites the previous message into the order.json file however I want to append it instead. Additionally, I want to make sure the messages do not get read in no faster th... | 0 | 2016-08-21T21:05:07Z | 39,068,881 | <p>You want to open your file in <a href="http://man7.org/linux/man-pages/man2/open.2.html" rel="nofollow">append mode</a>. Also, you may not want to open the file on each message, since it can be an expensive operation (e.g. you will need to change file metadata like modification time every time you close the file):</... | 0 | 2016-08-21T21:07:57Z | [
"python",
"file",
"stream",
"message"
] |
How to append to a file from stream rather than overwrite in Python | 39,068,864 | <p>I am new to python so this maybe a simple question but I have a kafka consumer from which I read in messages. Every time a new message comes in it rewrites the previous message into the order.json file however I want to append it instead. Additionally, I want to make sure the messages do not get read in no faster th... | 0 | 2016-08-21T21:05:07Z | 39,068,893 | <p>Open the file in <code>append</code> mode as '<code>w'</code> (write mode) truncates the file each time it exists</p>
<pre><code>for message in consumer:
with open('order.json', 'a') as file:
file.write(message.value.decode('UTF-8'))
</code></pre>
| 0 | 2016-08-21T21:10:08Z | [
"python",
"file",
"stream",
"message"
] |
Using a recursive call in If-condition in Python | 39,068,912 | <p>I have written a function to perform lasso regression using coordinate descent. </p>
<p>The code is as follows:</p>
<pre><code>def lasso_cyclical_coordinate_descent(feature_matrix, output, weights, l1_penalty, tolerance):
for i in range(len(weights)):
old_weights_i = weights[i]
weights[i] = las... | -3 | 2016-08-21T21:12:14Z | 39,069,084 | <p>You are right. Your if statement and your implicite else is your recursion "stopping condition". As soon as the if condition is false, it will exit the function and end recursion by exiting all parent calls.</p>
<p>You have to make sure this statement can be false at least once to avoid a max depth recursion except... | 0 | 2016-08-21T21:37:20Z | [
"python",
"recursion"
] |
Printing the values in a nested dictionary in Python 2.x | 39,068,943 | <p>I have a dictionary type variable returned in my Python 2.x script that contains the below values:-</p>
<pre><code>{u'image': u'/users/me/Desktop/12345_507630509400555_869403269181768452_n.jpg', u'faces': [{u'gender': {u'gender': u'FEMALE', u'score': 0.731059}, u'age': {u'max': 17, u'score': 0.983185}, u'face_locat... | 1 | 2016-08-21T21:16:21Z | 39,068,962 | <p>You have nested dicts and lists:</p>
<pre><code>d = {u'image': u'/users/me/Desktop/12345_507630509400555_869403269181768452_n.jpg', u'faces': [{u'gender': {u'gender': u'FEMALE', u'score': 0.731059}, u'age': {u'max': 17, u'score': 0.983185}, u'face_location': {u'width': 102, u'top': 102, u'left': 426, u'height': 106... | 2 | 2016-08-21T21:18:57Z | [
"python",
"json",
"python-2.7",
"dictionary",
"nested"
] |
Printing the values in a nested dictionary in Python 2.x | 39,068,943 | <p>I have a dictionary type variable returned in my Python 2.x script that contains the below values:-</p>
<pre><code>{u'image': u'/users/me/Desktop/12345_507630509400555_869403269181768452_n.jpg', u'faces': [{u'gender': {u'gender': u'FEMALE', u'score': 0.731059}, u'age': {u'max': 17, u'score': 0.983185}, u'face_locat... | 1 | 2016-08-21T21:16:21Z | 39,068,996 | <p>It's a bit complex dict. This is how you extract the desired values:</p>
<p>Let <code>d</code> be your dict:</p>
<pre><code>key = 'faces'
inner = d[key][0]
print(inner['gender']['gender'], inner['gender']['score'], inner['age']['max'], inner['age']['score'])
</code></pre>
<p>Output:</p>
<pre><code>FEMALE 0.7310... | 1 | 2016-08-21T21:23:56Z | [
"python",
"json",
"python-2.7",
"dictionary",
"nested"
] |
python use lazy assignment when passing lists to methods | 39,068,974 | <p>I have a python class A and its child B. I make an object of class B passing some list-type arguments, which are appended in B and the result stored in class A. I would like to be able to change one of those initial arguments and see the change reflected without further ado. Let me explain with an example:</p>
<pre... | 2 | 2016-08-21T21:20:33Z | 39,069,026 | <p>You need to implement it "manually". For example, like so:</p>
<pre><code>class B(A):
def __init__(self,x,y):
self.x=x
self.y=y
self.spread_changes()
def change_x(self,x):
self.x = x
self.spread_changes()
def spread_changes(self):
A.__init__(self,self.x+... | 1 | 2016-08-21T21:28:49Z | [
"python",
"generator"
] |
python use lazy assignment when passing lists to methods | 39,068,974 | <p>I have a python class A and its child B. I make an object of class B passing some list-type arguments, which are appended in B and the result stored in class A. I would like to be able to change one of those initial arguments and see the change reflected without further ado. Let me explain with an example:</p>
<pre... | 2 | 2016-08-21T21:20:33Z | 39,069,040 | <p>Is there a reason to have the class <code>A</code> at all? You could create a property or method <code>a</code> that returns what you want within class <code>B</code>.</p>
<pre><code>class B():
def __init__(self, x, y):
self.x = x
self.y = y
def change_x(self, x):
self.x = x
@p... | 7 | 2016-08-21T21:30:10Z | [
"python",
"generator"
] |
python use lazy assignment when passing lists to methods | 39,068,974 | <p>I have a python class A and its child B. I make an object of class B passing some list-type arguments, which are appended in B and the result stored in class A. I would like to be able to change one of those initial arguments and see the change reflected without further ado. Let me explain with an example:</p>
<pre... | 2 | 2016-08-21T21:20:33Z | 39,093,097 | <p>I ended up storing all parts of self.a (in A) directly by slicing/indexing from it's inheriting classes. I added a method "B.update_crc(self)" as suggested by Israel Unterman to reevaluate certain parts of self.a in case of a modification.</p>
<p>Thanks, my first approach just wan't the right one :)</p>
| 0 | 2016-08-23T05:35:53Z | [
"python",
"generator"
] |
Reading CONNECT headers | 39,068,998 | <p>I'm using a proxy service (proxymesh) that puts useful information into the headers sent in response to a CONNECT request. For whatever reason, <a href="https://bugs.python.org/issue24964" rel="nofollow">Python's <code>httplib</code> doesn't parse them</a>:</p>
<pre><code>> CONNECT example.com:443 HTTP/1.1
> ... | 1 | 2016-08-21T21:24:12Z | 39,068,999 | <p>Python's <code>httplib</code> actually ignores these headers when creating the tunnel. It's hacky, but you can intercept them and merge the "header" lines with the actual HTTP response's headers:</p>
<pre><code>import socket
import httplib
import requests
from requests.packages.urllib3.connection import HTTPSConne... | 1 | 2016-08-21T21:24:12Z | [
"python",
"proxy",
"http-headers",
"python-requests",
"httplib"
] |
wxPython : Soundboard panel [NOW PLAYING] just like in winamp | 39,069,001 | <p>I am almost done my wxPython soundboard and want to implement one quick feature. </p>
<p>How does one add another panel to a wxPython window, and how do you implement the text, [ NOW PLAYING ] within that panel. </p>
<p>Here is my code so far:
import wx
import os
import pygame</p>
<pre><code>pygame.i... | 0 | 2016-08-21T21:24:23Z | 39,084,943 | <p>Before:</p>
<pre><code>print("[ NOW PLAYING ] ... %s" % name)
</code></pre>
<p>input:</p>
<pre><code>self.usertext.SetValue("[ NOW PLAYING ] ... %s" % name)
</code></pre>
<p>P.S. Your indentation is a mess</p>
| 0 | 2016-08-22T16:57:56Z | [
"python",
"wxpython"
] |
Append list value to corresponding value in another list | 39,069,013 | <p>So I'm trying to attach a bunch of values in a huge list to their corresponding headings stored in another list. For example, right now I have a list with only the headings (e.g. ['Target'],['Choice']) and I want to take values corresponding with those headings (e.g. 'Target':3, 'Choice':1) and append them to the c... | 0 | 2016-08-21T21:26:41Z | 39,069,114 | <p>If i understand your question correctly, you have a list, and you have some corresponding values in another list retaliative to the first list. If that is the case, and assuming that all your values corresponded in the correct order you could use list comprehension:</p>
<pre><code>lst1 = ['th', 'an', 'bu']
lst2 = [... | 0 | 2016-08-21T21:42:27Z | [
"python",
"list",
"csv"
] |
Append list value to corresponding value in another list | 39,069,013 | <p>So I'm trying to attach a bunch of values in a huge list to their corresponding headings stored in another list. For example, right now I have a list with only the headings (e.g. ['Target'],['Choice']) and I want to take values corresponding with those headings (e.g. 'Target':3, 'Choice':1) and append them to the c... | 0 | 2016-08-21T21:26:41Z | 39,069,295 | <p>I'm still having a hard time understanding the question, but if my guess is right, I think this is what you need. Note that this code uses the excellent <a href="http://docs.python-tablib.org/en/latest/" rel="nofollow"><code>tablib</code> module</a>:</p>
<pre><code>from collections import defaultdict
import re
imp... | 0 | 2016-08-21T22:10:10Z | [
"python",
"list",
"csv"
] |
Including the same blocks in several pages in Django | 39,069,025 | <p>On my website, blog posts appear in multiple places across the site. I want to create a template like <code>blog_posts.html</code> that given the list of blog posts (as an argument to <code>render</code>) creates the block with these posts, formatted and processed.</p>
<p>There are several disconnected pages to whi... | 0 | 2016-08-21T21:28:23Z | 39,069,197 | <p>You can either render <code>blog_posts.html</code> to string and pass it as a variable to the other template:</p>
<pre><code>from django.template.loader import get_template
blog_posts = get_template('/path/to/blog_posts.htm')
somevar = blog_posts.render({'foo': 'foo', 'bar': 'baz'})
</code></pre>
<p>then place <co... | 1 | 2016-08-21T21:54:34Z | [
"python",
"django",
"django-templates"
] |
Including the same blocks in several pages in Django | 39,069,025 | <p>On my website, blog posts appear in multiple places across the site. I want to create a template like <code>blog_posts.html</code> that given the list of blog posts (as an argument to <code>render</code>) creates the block with these posts, formatted and processed.</p>
<p>There are several disconnected pages to whi... | 0 | 2016-08-21T21:28:23Z | 39,069,425 | <p>you might want to consider using template tags. Something like the inclusion tag should serve you well (see here for docs <a href="https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#inclusion-tags" rel="nofollow">https://docs.djangoproject.com/en/1.10/howto/custom-template-tags/#inclusion-tags</a>)</... | 0 | 2016-08-21T22:33:39Z | [
"python",
"django",
"django-templates"
] |
Files are corrupted after transfer them to a FTP server using ftplib | 39,069,038 | <p>I've got a problem with the ftplib library when I'm uploading .gz files.</p>
<p>The script was working before but somehow in one of my thousands of editions, I changed something that is causing to transfer corrupted files.
The files is successfully transferred to the ftp server, however, that files when is being us... | 0 | 2016-08-21T21:29:46Z | 39,069,217 | <p>The issue was the use of storlines. In this case, needs to be use storbinary</p>
| 1 | 2016-08-21T21:57:09Z | [
"python",
"ftp",
"ftplib"
] |
Employing Post Method in Flask | 39,069,061 | <p>Using the following:</p>
<pre><code>from flask import Flask, render_template
import beautiful_soup_tidal
app = Flask(__name__)
@app.route('/')
def form():
return render_template('form_submit.html')
@app.route('/richmond', methods=['POST'])
def richmond():
someTides = beautiful_soup_tidal.getTides()
r... | -1 | 2016-08-21T21:33:47Z | 39,069,465 | <p>i believe this line should also include GET so that you can render the html form first time round before you actually click submit to post it.</p>
<pre><code>@app.route('/richmond', methods=['POST'])
</code></pre>
<p>so it would change to</p>
<pre><code>@app.route('/richmond', methods=['GET', 'POST'])
</code></pr... | 0 | 2016-08-21T22:39:42Z | [
"python",
"flask"
] |
PyQT QFileDialog - get full directory including IP of disk | 39,069,089 | <p>I'd like to get full path of my directory, something like:</p>
<pre><code>//192.168.1.23/D/test/test/aaaa/
</code></pre>
<p>or</p>
<pre><code>//192.168.1.23/D:/test/test/aaaa/
</code></pre>
<p>How can I get QFileDialog to give me the IP address of the HDD that I have selected? </p>
<p>Currently using </p>
<pre... | 0 | 2016-08-21T21:37:51Z | 39,069,172 | <p>What you want to do is not possible in PyQt directly with <code>QFileDialog</code> what you can do instead is to get the ip address of your machine with another method and then concatenate that with the file path, something like this. QFileDialog isn't 'Network aware'</p>
<pre><code>import socket
def get_ip_addr():... | 1 | 2016-08-21T21:52:09Z | [
"python",
"pyqt",
"pyqt4",
"qfiledialog"
] |
PyQT QFileDialog - get full directory including IP of disk | 39,069,089 | <p>I'd like to get full path of my directory, something like:</p>
<pre><code>//192.168.1.23/D/test/test/aaaa/
</code></pre>
<p>or</p>
<pre><code>//192.168.1.23/D:/test/test/aaaa/
</code></pre>
<p>How can I get QFileDialog to give me the IP address of the HDD that I have selected? </p>
<p>Currently using </p>
<pre... | 0 | 2016-08-21T21:37:51Z | 39,450,031 | <p>Not sure where I found it but here is the option I followed at the end. I let user decide then which device to use for location</p>
<pre><code>from netifaces import interfaces, ifaddresses, AF_INET
p =[]
for ifaceName in interfaces():
addresses = [i['addr'] for i in ifaddresses(ifaceName).setdefault(AF_INET, [{... | 0 | 2016-09-12T12:11:23Z | [
"python",
"pyqt",
"pyqt4",
"qfiledialog"
] |
When do I have to initialize variables in Tensorflow? | 39,069,130 | <p>I am trying to understand tensor flow and how understand it one has to first create ops and variables add them to the graph and then in a session those operations will be performed.
Then why in this piece of code I don't have to use the method initialize_all_variables()?
I was trying to add <code>init = tf.initiali... | 0 | 2016-08-21T21:45:08Z | 39,069,688 | <p>You are not allowed to read an uninitialized value. In the case above you are not reading <code>z</code> hence you don't need to initialize it.</p>
<p>If you look at at <code>variables.py</code> you see that <code>initialize_all_variables is a group node connected to all initializers</code></p>
<pre><code>def init... | 0 | 2016-08-21T23:23:33Z | [
"python",
"tensorflow"
] |
pip install python-libtorrent==1.1.0 fails on linux | 39,069,168 | <p>Title is self explanatory. I get the following error in linux and python2.7:</p>
<pre><code>Could not find a version that satisfies the requirement python-libtorrent (from versions: )
No matching distribution found for python-libtorrent
</code></pre>
<p>I can see it listed on pypi:</p>
<p><a href="https://pypi.py... | 2 | 2016-08-21T21:51:34Z | 39,069,220 | <p>The package in question, and its version, has been registered to PyPI. However there is no downloadable distribution file at all. Either the author/maintainer forgot to upload it (or them), or it was later removed.</p>
<p>If a distribution was uploaded, it should show up on the <a href="https://pypi.python.org/pypi... | 2 | 2016-08-21T21:57:49Z | [
"python",
"libtorrent"
] |
I´m getting the error, "atan2() takes exactly 2 arguments (1 given)" | 39,069,376 | <p>I´m new to programing so I have no idea what went wrong. please help</p>
<pre><code>from math import atan2, pi
x = int(input("value of x"))
y = int(input("value of y"))
r = (x**2 + y**2) ** 0.5
ang = atan2(y/x)
print("Hypotenuse is", r, "angle is", ang)
</code></pre>
| 2 | 2016-08-21T22:23:55Z | 39,069,394 | <p>The reason for that error is that <code>atan2</code> requires two arguments. Observe:</p>
<pre><code>>>> from math import atan, atan2
>>> atan(2)
1.1071487177940904
>>> atan2(4, 2)
1.1071487177940904
</code></pre>
<p>Note that <code>atan(y/x)</code> does not work if <code>x</code> is ze... | 2 | 2016-08-21T22:27:29Z | [
"python",
"atan2"
] |
I´m getting the error, "atan2() takes exactly 2 arguments (1 given)" | 39,069,376 | <p>I´m new to programing so I have no idea what went wrong. please help</p>
<pre><code>from math import atan2, pi
x = int(input("value of x"))
y = int(input("value of y"))
r = (x**2 + y**2) ** 0.5
ang = atan2(y/x)
print("Hypotenuse is", r, "angle is", ang)
</code></pre>
| 2 | 2016-08-21T22:23:55Z | 39,069,397 | <p>In Python, there are 2 arctangent functions: <code>atan</code> is simply the inverse of <code>tan</code>; but <code>atan2</code> takes 2 arguments. In your case since you know both catheti, you could as well use the 2-argument function <code>atan2</code>:</p>
<pre><code>ang = atan2(y, x)
</code></pre>
<p>Alternati... | 4 | 2016-08-21T22:28:11Z | [
"python",
"atan2"
] |
How do I detect where dlib's correlation_tracker lost the target image? | 39,069,480 | <p>I added a correlation_tracker to a multithreaded face <a href="http://blog.dlib.net/2015/02/dlib-1813-released.html" rel="nofollow">tracking script</a>, and oddly enough, it generally does well tracking a face on the screen, but when you put your hand over the camera it keeps saying the same coordinates and highligh... | 1 | 2016-08-21T22:41:52Z | 39,069,633 | <p>You must run the face detector every now and then to see if the face is still there. </p>
| 1 | 2016-08-21T23:13:42Z | [
"python",
"computer-vision",
"dlib"
] |
How to extract the strong elements which are in div tag | 39,069,497 | <p>I am new to web scraping. I am using Python to scrape the data.
Can someone help me in how to extract data from:</p>
<pre><code><div class="dept"><strong>LENGTH:</strong> 15 credits</div>
</code></pre>
<p>My output should be LENGTH: <code>15 credits</code></p>
<p>Here is my code:</p>
<pre... | 1 | 2016-08-21T22:44:55Z | 39,069,502 | <p>You should improve your code a bit to locate the <code>strong</code> element <a class='doc-link' href="http://stackoverflow.com/documentation/beautifulsoup/1940/locating-elements/6339/locate-a-text-after-an-element-in-beautifulsoup#t=20160821225134749343"><em>by text</em></a>:</p>
<pre><code>soup.find("strong", tex... | 2 | 2016-08-21T22:46:29Z | [
"python",
"web-scraping",
"beautifulsoup"
] |
Python Tkinter Scrollbar Not Working | 39,069,544 | <p>I'm working on a new program in Python 3 with tkinter. I'm trying to add a scrollbar to the whole window, but it isn't working. Right now I'm just trying to make the window 1000 pixels tall (will be set later in the program) and use the a vertical scrollbar to access the parts not seen on screen. I've read multiple ... | 0 | 2016-08-21T22:54:48Z | 39,177,453 | <p>The scroll bar was there the whole time, the problem was that I made the canvas width the screen's size and the scroll bar was adding onto the width, therefore going off the screen. I just had to make the width a little less.</p>
| 0 | 2016-08-27T04:26:48Z | [
"python",
"tkinter"
] |
How to use override parameters of a fixture in Pytest? | 39,069,551 | <p>Let's say I have a parameterized fixture like this:</p>
<pre><code>@pytest.fixture(params=[1, 2, 800]):
def resource(request):
return Resource(capacity=request.param)
</code></pre>
<p>When I use the fixture as parameter in a test function, Pytest runs the test with all three versions:</p>
<pre><code>def test_... | 0 | 2016-08-21T22:56:57Z | 39,069,653 | <p>I don't think that you can configure it <em>"to only receive certain versions"</em>, but you can explicitly ignore some of them:</p>
<pre><code>def test_worker(resource, worker):
if resource.capacity == 800:
pytest.skip("reason why that value won't work")
worker.use(resource)
assert worker.is_ok... | 2 | 2016-08-21T23:17:02Z | [
"python",
"python-3.x",
"py.test",
"fixtures"
] |
How to use override parameters of a fixture in Pytest? | 39,069,551 | <p>Let's say I have a parameterized fixture like this:</p>
<pre><code>@pytest.fixture(params=[1, 2, 800]):
def resource(request):
return Resource(capacity=request.param)
</code></pre>
<p>When I use the fixture as parameter in a test function, Pytest runs the test with all three versions:</p>
<pre><code>def test_... | 0 | 2016-08-21T22:56:57Z | 39,378,910 | <p>If you want to use different set of parameters for different tests then <code>pytest.mark.parametrize</code> is helpful. </p>
<pre><code>@pytest.mark.parametrize("resource", [1, 2, 800], indirect=True)
def test_resource(resource):
assert resource.is_okay()
@pytest.mark.parametrize("resource", [1, 5], indirect=... | 1 | 2016-09-07T20:59:40Z | [
"python",
"python-3.x",
"py.test",
"fixtures"
] |
How to install mesos.native python module in Mac OS and Ubuntu | 39,069,553 | <p>I would like to write and run a Mesos framework with Python, so I need mesos.native module.</p>
<p>On Ubuntu:</p>
<p>I can build mesos from source code. I tried to easy_install all the generated egg files but none of them made it possible for Python to import mesos.native.</p>
<p>I also tried to download the egg ... | 0 | 2016-08-21T22:57:23Z | 39,072,413 | <p>Problem solved: <a href="https://github.com/RobinDong/mesos-python-examples/blob/master/calculate_pi/pi_run" rel="nofollow">https://github.com/RobinDong/mesos-python-examples/blob/master/calculate_pi/pi_run</a></p>
<p>I just need to set PYTHONPATH as that in the file and run python. Mesos.native can be successfully... | 0 | 2016-08-22T06:13:49Z | [
"python",
"mesos",
"mesosphere"
] |
What is this "join" doing? | 39,069,701 | <p>I just installed retext via pip. I have to download icons for it but I realise it doesn't work (no icons on the menu) unless i run "retext" in the folder of retext.</p>
<p>I tried to fix it but my python skills are not very strong.</p>
<p>At the moment, I force the icon_path to have the path I want.</p>
<pre><cod... | 1 | 2016-08-21T23:26:15Z | 39,069,786 | <p>This is <a href="https://docs.python.org/3/library/os.path.html#os.path.join" rel="nofollow"><code>os.path.join()</code></a>:</p>
<blockquote>
<p><code>os.path.join(path, *paths)</code></p>
<p>Join one or more path components intelligently. The return value is the concatenation of path and any members of <co... | 0 | 2016-08-21T23:41:26Z | [
"python",
"list",
"join",
"expression"
] |
Python thread won't start using socket | 39,069,704 | <p>i have a problem with my progam using socket and thread.</p>
<p>I have made a socket server who add client in a thread, but the client thread never start...</p>
<p>here is my code:</p>
<p>socket server</p>
<pre><code>import socket, threading, logging, sys
from client_thread import ClientThread
class SocketServe... | 2 | 2016-08-21T23:26:52Z | 39,070,010 | <p>You have this line of code in your <code>Server</code> instance <code>start</code> function:</p>
<pre><code>new_client = threading.Thread(target=ClientThread,
args=[len(self.CLIENTS), ip, port, clientsock])
</code></pre>
<p>The <code>target=</code> argument to <code>threading.Thread</code> needs to be a calla... | 3 | 2016-08-22T00:28:22Z | [
"python",
"multithreading",
"sockets"
] |
What is the python way to iterate two list and compute by position? | 39,069,782 | <p>What is the Pythonic way to iterate two list and compute?</p>
<pre><code>a, b=[1,2,3], [4,5,6]
c=[]
for i in range(3):
c.append(a[i]+b[i])
print(c)
[5,7,9]
</code></pre>
<p>Is there a one-liner for <code>c</code> without a for loop?</p>
| 3 | 2016-08-21T23:40:29Z | 39,069,789 | <p>One possibility:</p>
<pre><code>a, b = [1, 2, 3], [4, 5, 6]
c = list(map(sum, zip(a,b)))
</code></pre>
<p>Another option (if it's always just two lists):</p>
<pre><code>c = [x + y for x, y in zip(a, b)]
</code></pre>
<p>Or probably my favorite, which is equivalent to my first example but uses list comprehension ... | 8 | 2016-08-21T23:42:00Z | [
"python"
] |
What is the python way to iterate two list and compute by position? | 39,069,782 | <p>What is the Pythonic way to iterate two list and compute?</p>
<pre><code>a, b=[1,2,3], [4,5,6]
c=[]
for i in range(3):
c.append(a[i]+b[i])
print(c)
[5,7,9]
</code></pre>
<p>Is there a one-liner for <code>c</code> without a for loop?</p>
| 3 | 2016-08-21T23:40:29Z | 39,069,792 | <p>Use <code>zip</code> and list comprehension:</p>
<pre><code>[x+y for (x,y) in zip(a, b)]
</code></pre>
| 9 | 2016-08-21T23:42:20Z | [
"python"
] |
What is the python way to iterate two list and compute by position? | 39,069,782 | <p>What is the Pythonic way to iterate two list and compute?</p>
<pre><code>a, b=[1,2,3], [4,5,6]
c=[]
for i in range(3):
c.append(a[i]+b[i])
print(c)
[5,7,9]
</code></pre>
<p>Is there a one-liner for <code>c</code> without a for loop?</p>
| 3 | 2016-08-21T23:40:29Z | 39,069,803 | <p>If you are doing this sort of thing often, you should be using <code>numpy</code>:</p>
<pre><code>>>> import numpy as np
>>> a, b=[1,2,3], [4,5,6]
>>> c = np.array(a) + b
>>> c
array([5, 7, 9])
</code></pre>
| 4 | 2016-08-21T23:45:09Z | [
"python"
] |
What is the python way to iterate two list and compute by position? | 39,069,782 | <p>What is the Pythonic way to iterate two list and compute?</p>
<pre><code>a, b=[1,2,3], [4,5,6]
c=[]
for i in range(3):
c.append(a[i]+b[i])
print(c)
[5,7,9]
</code></pre>
<p>Is there a one-liner for <code>c</code> without a for loop?</p>
| 3 | 2016-08-21T23:40:29Z | 39,069,811 | <p><code>zip</code> is the way to go, but the actual title of your question suggests <code>enumerate</code>:</p>
<pre><code>[x+b[i] for i, x in enumerate(a)]
</code></pre>
<p>This sort of thing is helpful if you need the actual <em>position</em> (index) in the computation.</p>
| 3 | 2016-08-21T23:46:30Z | [
"python"
] |
win 10 WinPython Script import xlwings get errors | 39,069,794 | <ol>
<li>Python and xlwings in same folder. comtypes folder in xlwings folder</li>
<li>can't find module named 'com types'</li>
</ol>
<p>The xlwings documentation says to install with pip. This puts xlwings in the C:\Python27 folder. WinPython ends up in the Downloads/WinPython-64bit-3.4.4-3Qtr5/ (1.37GB, btw) mo... | 0 | 2016-08-21T23:43:22Z | 39,083,271 | <p>maybe this would work better:</p>
<ul>
<li><p>click on the "WinPython Command Prompt" icon of your WinPython distribution</p></li>
<li><p>in the opening DOS windows, type: </p></li>
</ul>
<blockquote>
<p>pip install xlwings</p>
</blockquote>
| 0 | 2016-08-22T15:20:57Z | [
"python",
"xlwings",
"comtypes"
] |
Python - Integrating entire list with the Gaussian distribution | 39,069,846 | <p>I'm trying to plot the integral of this normal distribution for values greater than x defined as</p>
<p><a href="http://i.stack.imgur.com/LRsHj.gif" rel="nofollow"><img src="http://i.stack.imgur.com/LRsHj.gif" alt="enter image description here"></a></p>
<p>where </p>
<p><a href="http://i.stack.imgur.com/l9vnM.gif... | 1 | 2016-08-21T23:54:57Z | 39,070,045 | <p>What you've defined will work only when <code>x</code> is a single <code>float</code>. If what you want is to be able to pass a numpy array, say <code>np.array([0.2, 0.3])</code> and get [N(>0.2), N(>0.3)], then you can use the function as you've already defined and just call the <code>vectorize</code> method. So if... | 1 | 2016-08-22T00:36:55Z | [
"python",
"integration",
"normal-distribution"
] |
Python - Integrating entire list with the Gaussian distribution | 39,069,846 | <p>I'm trying to plot the integral of this normal distribution for values greater than x defined as</p>
<p><a href="http://i.stack.imgur.com/LRsHj.gif" rel="nofollow"><img src="http://i.stack.imgur.com/LRsHj.gif" alt="enter image description here"></a></p>
<p>where </p>
<p><a href="http://i.stack.imgur.com/l9vnM.gif... | 1 | 2016-08-21T23:54:57Z | 39,082,201 | <p>You can directly use <a href="http://docs.scipy.org/doc/scipy-0.16.0/reference/generated/scipy.stats.norm.html" rel="nofollow">scipy.stats.norm</a>'s survival function for 1 - F(x):</p>
<pre><code>import scipy.stats as ss
x = np.linspace(-3, 3, 100)
y = ss.norm.sf(x) # you can pass its mean and std. dev. as well
p... | 1 | 2016-08-22T14:31:07Z | [
"python",
"integration",
"normal-distribution"
] |
Gtk+ FlowBox selection not working | 39,069,891 | <p>I'm currently developing a PyGObject app and I'm having issues selecting specific children in a Gtk+ FlowBox. Even after selecting the FlowBox selection mode (SINGLE) populating the FlowBox and writing code to select a specific child, the first child is always selected.</p>
<pre><code>#!/usr/bin/python
import gi
g... | 1 | 2016-08-22T00:02:46Z | 39,085,154 | <p>I think you have located a bug in GTK, it seems that something in <code>show_all</code> is messing up. My first guess was that it was caused by the fact that the <code>FlowBox</code> wasn't realized so I changed your code to use the <code>show</code> signal (<code>realize</code> but <code>show</code> is emitted late... | 1 | 2016-08-22T17:12:25Z | [
"python",
"gtk",
"gtk3",
"gnome",
"pygobject"
] |
Understanding how to specify the newshape parameter for numpy's reshape() | 39,069,988 | <p>I am new to python data analysis, and trying to figure out how to manipulate a multi-dimensional array to a different dimension. Tutorials or forums online don't explain how to specify the parameters of "newshape" for <code>numpy.reshape(a, newshape, order='C')</code> </p>
<p>Here is an example I am trying to und... | 2 | 2016-08-22T00:22:29Z | 39,070,025 | <p>The <code>newshape</code> argument has to be passed as a tuple (or something compatible) to <code>numpy.reshape</code>. But here's the catch: all the non-keyword arguments passed to <code>numpy.ndarray.reshape</code> (e.g. <code>b.reshape</code> in your example) will be caught by the argument <code>newshape</code>. ... | 1 | 2016-08-22T00:30:43Z | [
"python",
"numpy"
] |
Understanding how to specify the newshape parameter for numpy's reshape() | 39,069,988 | <p>I am new to python data analysis, and trying to figure out how to manipulate a multi-dimensional array to a different dimension. Tutorials or forums online don't explain how to specify the parameters of "newshape" for <code>numpy.reshape(a, newshape, order='C')</code> </p>
<p>Here is an example I am trying to und... | 2 | 2016-08-22T00:22:29Z | 39,070,133 | <p>Here is another perspective for understanding the <code>shape</code> of an array if that is part of what you are asking. The <code>shape</code> parameter <code>(2, 4, 2, 4)</code> specifies the length along each of the four different axises of the array. If you conceptually consider it as list of lists then it means... | 0 | 2016-08-22T00:56:31Z | [
"python",
"numpy"
] |
Understanding how to specify the newshape parameter for numpy's reshape() | 39,069,988 | <p>I am new to python data analysis, and trying to figure out how to manipulate a multi-dimensional array to a different dimension. Tutorials or forums online don't explain how to specify the parameters of "newshape" for <code>numpy.reshape(a, newshape, order='C')</code> </p>
<p>Here is an example I am trying to und... | 2 | 2016-08-22T00:22:29Z | 39,070,570 | <p>A similar question from a week ago: <a href="http://stackoverflow.com/questions/38928669/how-to-understand-ndarray-reshape-function">How to understand ndarray.reshape function?</a></p>
<p><code>np.reshape(a, newshape)</code> gets recast as <code>a.reshape(newshape)</code>. But <code>a.reshape</code> is a builtin, ... | 2 | 2016-08-22T02:17:30Z | [
"python",
"numpy"
] |
Django Celery Periodic Task not running (Heroku)? | 39,070,042 | <p>I have a Django application that I've deployed with Heroku. I'm trying to user celery to create a periodic task every minute. However, when I observe the logs for the worker using the following command:</p>
<pre><code>heroku logs -t -p worker
</code></pre>
<p>I don't see my task being executed. Perhaps there is a... | 0 | 2016-08-22T00:35:26Z | 39,070,229 | <p>You need separate worker for the beat process (which is responsible for executing periodic tasks):</p>
<pre><code>web: gunicorn activiist.wsgi --log-file -
worker: celery worker --app=trending.tasks.app
beat: celery --app=trending.tasks.app
</code></pre>
<p>Worker isn't necessary for periodic tasks so the relevant... | -1 | 2016-08-22T01:15:38Z | [
"python",
"django",
"heroku",
"celery"
] |
Passing variable for module import and use | 39,070,053 | <p>so I am trying to use a variable brand which is selected by the user. The variable is then to be used to call a given module in Python. currently on line 7 you can see 'apple.solutions()'. However, I essentially want to be able to use something on the lines 'brand.solutions()' - although I know this will not work as... | 0 | 2016-08-22T00:38:47Z | 39,070,271 | <p>What you may be looking for is a call to your Main() function:</p>
<pre><code>if __name__ == "__main__":
Main()
</code></pre>
<p>The code above should go at the end of your main program. It checks whether the main program is imported or not, then executes the <code>Main()</code> function if it is not imported... | 0 | 2016-08-22T01:23:16Z | [
"python",
"arrays",
"variables",
"parameter-passing",
"python-module"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.