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
Project different embedded structures to same name
38,234,053
<p>I am writing a python script that performs these tasks:</p> <ul> <li>Query a MongoDB Collection with embeded documents</li> <li>Aggregate and Project to change the field names that are returned in the query to match a "u_" convention</li> <li>Import the values to ServiceNow via REST API</li> </ul> <p><strong>ISSUE...
4
2016-07-06T21:26:53Z
38,234,886
<p>You want the $unwind, $group and $setUnion operators included in the aggregate function. It will allow you to flatten you list of hostnames.name and then union them with the other hostnames.</p>
1
2016-07-06T22:33:34Z
[ "python", "mongodb", "pymongo", "aggregation-framework" ]
Python variable outside of function Syntax error?
38,234,103
<p>I'm relatively new to programming. </p> <p>I've been attempting to write and run my first program and i'm getting stuck with an error. I attempted removing the <strong><em>int(raw_input()) on line 22</em></strong> a few times and make a few other adjustment's however my skill isn't quite all there to solve this mys...
1
2016-07-06T21:30:40Z
38,234,262
<p>There are two errors that I can spot here. The first one is on line 20. You have opened 3 parentheses and only closed one of them. Change line 22 to this:</p> <pre><code>numb = int(raw_input("How many points would you like to add?\n &gt; ")) </code></pre> <p><em>There is no need for the third bracket, just use 2.<...
3
2016-07-06T21:42:15Z
[ "python", "syntax" ]
Pandas matplotlib.pyplot add legend by a column value
38,234,115
<p><a href="http://i.stack.imgur.com/luI1D.png" rel="nofollow"><img src="http://i.stack.imgur.com/luI1D.png" alt="enter image description here"></a>I'm using Pandas to make a scatter plot. My data look like this:</p> <pre><code>Locations Lenovo Global Region Primary Function Subsidiaries Apr_2015_to_Mar_2016_[kWh] Apr...
0
2016-07-06T21:31:29Z
38,235,149
<p>Maybe this is what you need in the last line:</p> <pre><code>plt.legend(legend.values,loc=4) </code></pre>
0
2016-07-06T22:59:14Z
[ "python", "pandas", "matplotlib" ]
How to cast float to string with no decimal places
38,234,130
<p>I'm using <code>openpyxl</code> to read values from a spreadsheet. These values are being read as floats, I am not entirely sure why.</p> <pre><code>import openpyxl as opx wb = opx.load_workbook(SKU_WORKBOOK_PATH, use_iterators=True, data_only=True) ws = wb.worksheets[0] for row in ws.iter_rows(): foo = str(int(...
1
2016-07-06T21:32:30Z
38,234,145
<p>If you will never have decimals like <code>0.0</code> you can <code>str.rstrip</code> it will make <code>6978279.0</code> <code>6978279</code> removing zeros from the end of any other decimals is not going to change its value <code>1.12300</code> will be <code>1.233</code>:</p> <pre><code>In [20]: "1.234200".rstrip...
2
2016-07-06T21:33:32Z
[ "python", "openpyxl" ]
How to cast float to string with no decimal places
38,234,130
<p>I'm using <code>openpyxl</code> to read values from a spreadsheet. These values are being read as floats, I am not entirely sure why.</p> <pre><code>import openpyxl as opx wb = opx.load_workbook(SKU_WORKBOOK_PATH, use_iterators=True, data_only=True) ws = wb.worksheets[0] for row in ws.iter_rows(): foo = str(int(...
1
2016-07-06T21:32:30Z
38,234,851
<p>If you need int or float returned (may be for arithmetic operations), you can use a function like this:</p> <pre><code>def strip_num_or_float(value): try: value= int(value) except TypeError: value = value.normalize() return value </code></pre>
0
2016-07-06T22:29:56Z
[ "python", "openpyxl" ]
Read text file into dictionary to be used later for adding/modifying/deleting
38,234,190
<p>Let me preface by saying I'm not 100% sure if using a dictionary is the best course of action for this task but that is what I believe I need to use to accomplish this.</p> <p>I have a .txt file that is formatted like this:</p> <pre><code>first_name last_name rate hours first_name last_name rate hours first_name l...
0
2016-07-06T21:36:48Z
38,234,457
<p>i think the problem you are facing is how to find unique key<br> to create unique key, simply add all string together than hash it. </p> <pre><code>res = {} with open('employees.txt') as file: for line in file: res[line] = line.split(' ') </code></pre>
0
2016-07-06T21:57:18Z
[ "python", "python-3.x", "dictionary", "file-processing" ]
Read text file into dictionary to be used later for adding/modifying/deleting
38,234,190
<p>Let me preface by saying I'm not 100% sure if using a dictionary is the best course of action for this task but that is what I believe I need to use to accomplish this.</p> <p>I have a .txt file that is formatted like this:</p> <pre><code>first_name last_name rate hours first_name last_name rate hours first_name l...
0
2016-07-06T21:36:48Z
38,234,479
<p>You make some of the code easier by creating a <code>Person</code> class.</p> <pre><code>class Person: def __init__(self, first, last, rate, hours): self.first = first self.last = last self.rate = rate self.hours = hours def matches_name(self, name): return name.lower() ...
0
2016-07-06T21:59:00Z
[ "python", "python-3.x", "dictionary", "file-processing" ]
Read text file into dictionary to be used later for adding/modifying/deleting
38,234,190
<p>Let me preface by saying I'm not 100% sure if using a dictionary is the best course of action for this task but that is what I believe I need to use to accomplish this.</p> <p>I have a .txt file that is formatted like this:</p> <pre><code>first_name last_name rate hours first_name last_name rate hours first_name l...
0
2016-07-06T21:36:48Z
38,234,500
<p>Presuming you have space delimited data, you can just use the csv library.</p> <pre><code>import csv labels = ['first_name', 'last_name', 'rate', 'hours'] data = csv.DictReader(open('./test.txt'), delimiter=' ', fieldnames=labels) result = [] for row in data: result.append(row) print result </code></pre> <p>...
1
2016-07-06T22:00:39Z
[ "python", "python-3.x", "dictionary", "file-processing" ]
Read text file into dictionary to be used later for adding/modifying/deleting
38,234,190
<p>Let me preface by saying I'm not 100% sure if using a dictionary is the best course of action for this task but that is what I believe I need to use to accomplish this.</p> <p>I have a .txt file that is formatted like this:</p> <pre><code>first_name last_name rate hours first_name last_name rate hours first_name l...
0
2016-07-06T21:36:48Z
38,234,749
<h3>You can easily achieve all the desired operations with <code>pandas</code>:</h3> <pre><code>&gt;&gt;&gt; import pandas as pd </code></pre> <p>First convert your file to csv format (comma separated text file), then:</p> <p>assuming your file is in txt:</p> <pre><code>&gt;&gt;&gt; txt = """ 'F...
0
2016-07-06T22:21:48Z
[ "python", "python-3.x", "dictionary", "file-processing" ]
How to count the number of values that are being summed
38,234,209
<p>How can I count the number of values that are being summed?</p> <p>I have a really large df, but lets say I have a df like this:</p> <pre><code>df1: A B C 0 John Pen Apple 1 John Printer Pie 2 John Charger Burger 3 Erick Battery Pizza 4 Mandy Keyboard Bread 5 Mandy Phon...
0
2016-07-06T21:38:09Z
38,234,442
<p>try this:</p> <pre><code>In [153]: df = df.groupby('A', as_index=False)['B1'].agg(['sum','count']).reset_index() In [154]: df = pd.merge(df3, df, on='A', how='left').rename(columns={'B1':'Sum'}).fillna('') In [155]: df Out[155]: A B sum count 0 Erick Yes 1 John Yes 18 3 2 David No 3 Mandy ...
1
2016-07-06T21:55:59Z
[ "python", "pandas", "count", "sum" ]
How to count the number of values that are being summed
38,234,209
<p>How can I count the number of values that are being summed?</p> <p>I have a really large df, but lets say I have a df like this:</p> <pre><code>df1: A B C 0 John Pen Apple 1 John Printer Pie 2 John Charger Burger 3 Erick Battery Pizza 4 Mandy Keyboard Bread 5 Mandy Phon...
0
2016-07-06T21:38:09Z
38,234,645
<p>Try using the groupby method count()</p> <pre><code>df = pd.merge(df1, df2, left_on='B', right_on='A', suffixes=('','1')) groups = df.groupby('A', as_index=False) df = groups['B1'].sum() df['count'] = groups.count()['B1'] df = pd.merge(df3, df, on='A', how='left').rename(columns {'B1':'Sum'}).fillna('') </code></...
1
2016-07-06T22:11:38Z
[ "python", "pandas", "count", "sum" ]
How do I reset the ALLOWNONE status of a wxDatePickerCtrl?
38,234,238
<p>The code below uses sqlalchemy to check an sqlite3 mapped table(Ppe) for dates. It then uses these dates to populate a field on a wxForm on a comboBox event.</p> <pre><code>def refresh_ppe( self, event ): selected_user = str(self.m_comboBox31.GetValue()) session = start_session() updater = s...
0
2016-07-06T21:40:10Z
38,317,767
<p>The <code>wxDP_ALLOWNONE</code> is a flag so it shouldn't be losing that unless it is explicitly removed. I assume that what you mean is the visual state of the widget and what is done for that is up to the native control and how it chooses to represent the current value. The usual pattern for things like this in w...
0
2016-07-11T23:29:46Z
[ "python", "sqlite3", "sqlalchemy", "wxpython", "wxformbuilder" ]
Merge/join a dataframe based on nearest datetime to different dataframe
38,234,251
<p>I have a pandas dataframe of a pretty high length (100,000+), and I want to merge this dataframe with another based on closest element (by index) to a different dataframe object. For example, let us say that object 1 is the following: </p> <pre><code> DateTime x_1 y_1 2016-07-05 08:30:00 1 ...
1
2016-07-06T21:41:13Z
38,234,584
<p>Do the <code>reindex</code> on the unique values of the other index. You'll pick up the duplicates during the join.</p> <pre><code>object3 = object2.join(object1.reindex(object2.index.unique(), method='nearest')) </code></pre> <p>The resulting output:</p> <pre><code> x_2 y_2 x_1 y_1 DateTi...
3
2016-07-06T22:07:08Z
[ "python", "datetime", "pandas", "dataframe" ]
Elif statement to check for sheet range
38,234,389
<p>I have several Excel files some with 10 worksheets others with 8. In my code I looping through all files and selecting a sheet range of 2 to 9. However, since I have some workbooks with 8 sheets I would like to do the same loop or action in these workbooks instead of getting the "sheets = wb.worksheets[n] IndexError...
-1
2016-07-06T21:51:46Z
38,234,514
<p>The <code>if...elif</code> isn't entirely necessary. </p> <p>You can use <a href="https://docs.python.org/2.7/library/itertools.html#itertools.islice" rel="nofollow"><code>itertools.islice</code></a> to <em>slice</em> your <code>Sheets</code>:</p> <pre><code>from itertools import islice for file in files: wb ...
2
2016-07-06T22:01:21Z
[ "python" ]
PyQt Make Custom PushButton / inheritance from class which has arguments
38,234,397
<p>I'm new at PyQt I want to build my own Check Box which inheritance from QCheckBox.</p> <pre><code>class Valve(QtGui.QCheckBox): def __init__(self, x, y, inputs=[], outputs=[]): QtGui.QCheckBox.__init__(self) self.sources = inputs self.outputs = outputs self.move(x, y) def is...
0
2016-07-06T21:52:20Z
38,256,036
<p>You'd want to pass <code>MainWindow</code> as the parent of your checkbox:</p> <pre><code>class Valve(QtGui.QCheckBox): def __init__(self, parent, x, y, inputs=[], outputs=[]): QtGui.QCheckBox.__init__(self, parent) class MainWindow(QtGui.QWidget): def initUI(self): self.button1 = Valve(s...
0
2016-07-07T22:06:08Z
[ "python", "inheritance", "pyqt", "pyqt4" ]
opencv videocapture hangs/freeze when camera disconnected instead of returning "False"
38,234,407
<p>I'm using OpenCV-Python 3.1 Following the example code from here: <a href="http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.html" rel="nofollow">http://opencv-python-tutroals.readthedocs.io/en/latest/py_tutorials/py_gui/py_video_display/py_video_display.ht...
2
2016-07-06T21:53:06Z
40,129,056
<p>I'm experiencing the same issue with the webcam of my MacBook, when the lid is closed (i.e. cam not available). After a quick look at the doc, the <code>VideoCapture</code> constructor doesn't seem to have any <code>timeout</code> parameter. So the solution has to involve forcibly interrupting this call from Python....
0
2016-10-19T10:40:22Z
[ "python", "c++", "opencv", "video", "camera" ]
roots of piecewise cubic hermite interpolator with python
38,234,448
<p>I would like to do some piecewise cubic hermite interpolation and get the <strong>roots</strong> of the polynomials. (I used to do this in matlab but would now like to implement this in python 3.4).<br> I tried to use the scipy PchipInterpolator. Interpolation is OK but when I tried to retrieve the roots I got this ...
4
2016-07-06T21:56:15Z
38,235,352
<p>This is a bug in scipy.</p> <p>(Please report it on <a href="https://github.com/scipy/scipy/issues" rel="nofollow">https://github.com/scipy/scipy/issues</a>)</p> <p>As a workaround, you can convert to the power basis manually:</p> <pre><code>In [1]: from scipy.interpolate import pchip In [2]: import numpy as np ...
3
2016-07-06T23:20:47Z
[ "python", "matlab", "scipy", "interpolation" ]
Python: Replace "dumb quotation marks" with “curly ones” in a string
38,234,488
<p>I have a string like this:</p> <h1>"But that gentleman," looking at Darcy, "seemed to think the country was nothing at all."</h1> <p>I want this output:</p> <h1>“But that gentleman,” looking at Darcy, “seemed to think the country was nothing at all.”</h1> <p>Likewise, dumb single quotes should be convert...
2
2016-07-06T21:59:26Z
38,234,634
<p>Glancing through the documentation, it <em>looks</em> like you're stuck with <code>.replace</code> on top of the smartypants:</p> <pre><code>smartypants(r'"smarty" \"pants\"').replace('&amp;#x201C;', '“').replace('&amp;#x201D;', '”') </code></pre> <p>Might read better if you alias the magic strings, though:</p...
0
2016-07-06T22:10:48Z
[ "python", "string", "typography" ]
Python: Replace "dumb quotation marks" with “curly ones” in a string
38,234,488
<p>I have a string like this:</p> <h1>"But that gentleman," looking at Darcy, "seemed to think the country was nothing at all."</h1> <p>I want this output:</p> <h1>“But that gentleman,” looking at Darcy, “seemed to think the country was nothing at all.”</h1> <p>Likewise, dumb single quotes should be convert...
2
2016-07-06T21:59:26Z
38,234,962
<p>Assuming good input, this can be done using regular expressions:</p> <pre><code># coding=utf8 import re sample = '\'Sample Text\' - "But that gentleman," looking at Darcy, "seemed to think the \'country\' was nothing at all." \'Don\'t convert here.\'' print re.sub(r"(\s|^)\'(.*?)\'(\s|$)", r"\1‘\2’\3", re.sub(r...
0
2016-07-06T22:41:48Z
[ "python", "string", "typography" ]
Python: Replace "dumb quotation marks" with “curly ones” in a string
38,234,488
<p>I have a string like this:</p> <h1>"But that gentleman," looking at Darcy, "seemed to think the country was nothing at all."</h1> <p>I want this output:</p> <h1>“But that gentleman,” looking at Darcy, “seemed to think the country was nothing at all.”</h1> <p>Likewise, dumb single quotes should be convert...
2
2016-07-06T21:59:26Z
38,234,964
<p>You can use the <code>HTMLParser</code> to unescape the html entities returned from smartypants:</p> <pre><code>In [32]: from HTMLParser import HTMLParser In [33]: s = "&amp;#x201C;But that gentleman,&amp;#x201D;" In [34]: print HTMLParser().unescape(s) “But that gentleman,” In [35]: HTMLParser().unescape(s)...
1
2016-07-06T22:41:56Z
[ "python", "string", "typography" ]
numpy.linalg.lstsqr Errors
38,234,594
<p>I have two matrices, model_con and observed_con. model_con is 15x1096, and filled with float values ranging from 0 to about 5. observed_con is size 1096 with float values within approximately the same range. When I run this code: </p> <pre><code>for j in range(1000): N = [] for i in range(800): N.ap...
1
2016-07-06T22:08:07Z
38,234,861
<p>As you've written it, Cs has shape (15,800) and Os has shape (800,). But lstsq requires Os to be shape (15,) since you're trying to find the least squares solution to Cs x = Os (minimizing ||Cs x - Os||^2 over x). If you change 800 to 15 you'll see that you won't get any errors, but I don't know what you're trying t...
2
2016-07-06T22:30:46Z
[ "python", "numpy" ]
numpy.linalg.lstsqr Errors
38,234,594
<p>I have two matrices, model_con and observed_con. model_con is 15x1096, and filled with float values ranging from 0 to about 5. observed_con is size 1096 with float values within approximately the same range. When I run this code: </p> <pre><code>for j in range(1000): N = [] for i in range(800): N.ap...
1
2016-07-06T22:08:07Z
38,235,515
<p>False alarm, I found an error in my creation of the matrices. Sorry everybody!</p>
0
2016-07-06T23:39:58Z
[ "python", "numpy" ]
object_hook does not address the full json
38,234,765
<p>I have trouble understanding the way the object_hook function parses the json it is supplied by json.loads. </p> <p>Consider the following:</p> <pre><code>import json j = '{"key": "Program1",\ "value": {"codes": [], "name": "John Doe", "cities": ["New York", "Houston"]}}' class Humans: def __init__(self,...
1
2016-07-06T22:23:30Z
38,270,137
<p><code>object_hook</code> is applied to <em>every</em> object/dict nested in the json, from the deepest to the highest. So <code>{"codes": [], "name": "John Doe", "cities": ["New York", "Houston"]}</code> is provided to the hook first.</p> <p>Your example can be fixed with the following <code>object_hook</code>:</p>...
1
2016-07-08T15:15:34Z
[ "python", "json" ]
Cython and Python class coexistence in ipython?
38,234,776
<p>What is the best approach to have the same classes coexist in ipython environment.</p> <p>I want to gradually migrate some classes in hierarchy (starting from the root classes) from Python to Cython. I want to be able to have both versions running (in ipython env), so I can compare performance, and be able to fall-...
0
2016-07-06T22:24:02Z
38,235,410
<p>You can use the <code>import x as y</code> method for renaming definitions within modules. For example, if <code>foo.py</code> contains a function <code>func</code> and <code>bar.pyx</code> also contains the function <code>func</code> (perhaps this is you trying to write a Cython version of <code>foo.func()</code>) ...
3
2016-07-06T23:27:27Z
[ "python", "ipython", "cython", "jupyter" ]
kivy dynamically add and remove dropdown entries
38,234,848
<p>my app should dynamically add and remove items in the dropdown menu. The adding of buttons works, but I didn't get it working to remove the added buttons.</p> <p>py:</p> <pre><code>import kivy kivy.require('1.7.2') # replace with your current kivy version ! from kivy.app import App from kivy.uix.screenmanager imp...
0
2016-07-06T22:29:50Z
38,253,691
<p>Use <a href="https://kivy.org/docs/api-kivy.uix.widget.html#kivy.uix.widget.Widget.clear_widgets" rel="nofollow"><code>clear_widgets()</code></a> to get the result you want - removing all buttons from dropdown - or store some reference to those buttons in dropdown somewhere and remove only desired ones.</p> <pre><c...
0
2016-07-07T19:21:48Z
[ "python", "kivy" ]
list comprehension where list itself is None
38,234,951
<p>Is there a way for me to deal with the case where the list my_list itself can be None in the list comprehension:</p> <pre><code>[x for x in my_list] </code></pre> <p>I tried this:</p> <pre><code>[x for x in my_list if my_list is not None else ['1']] </code></pre> <p>However, it doesn't seem to work.</p>
3
2016-07-06T22:40:45Z
38,234,988
<p>I think this does what you want:</p> <pre><code>&gt;&gt;&gt; my_list = None &gt;&gt;&gt; [x for x in my_list] if my_list is not None else ['1'] ['1'] </code></pre> <p>The change here is moving the ternary statement outside of the list comprehension.</p> <p>Alternatively, if we add some parens, we can keep the ter...
8
2016-07-06T22:44:06Z
[ "python", "list-comprehension" ]
list comprehension where list itself is None
38,234,951
<p>Is there a way for me to deal with the case where the list my_list itself can be None in the list comprehension:</p> <pre><code>[x for x in my_list] </code></pre> <p>I tried this:</p> <pre><code>[x for x in my_list if my_list is not None else ['1']] </code></pre> <p>However, it doesn't seem to work.</p>
3
2016-07-06T22:40:45Z
38,235,538
<p>Your code is equivalent to making a copy of the list if it is not None else setting whatever to <code>["1"]</code>:</p> <pre><code> whatever = my_list[:] if my_list is not None else ['1'] </code></pre> <p>But I have a feeling what you really want is maybe a single <code>if my_list is None</code>:</p> <pre><code>i...
2
2016-07-06T23:42:04Z
[ "python", "list-comprehension" ]
list comprehension where list itself is None
38,234,951
<p>Is there a way for me to deal with the case where the list my_list itself can be None in the list comprehension:</p> <pre><code>[x for x in my_list] </code></pre> <p>I tried this:</p> <pre><code>[x for x in my_list if my_list is not None else ['1']] </code></pre> <p>However, it doesn't seem to work.</p>
3
2016-07-06T22:40:45Z
38,296,265
<p>Another simple solution is the following:</p> <pre><code>[x for x in my_list or ['1']] </code></pre> <p>However your code is almost correct: you have just to take into account of operator priorities by adding a couple of parenthesis:</p> <pre><code>[x for x in (my_list if my_list is not None else ['1'])] </code><...
1
2016-07-10T20:38:30Z
[ "python", "list-comprehension" ]
Google App Engine Local Dev Server Does not Route to Remote Cloud Storage Bucket
38,234,985
<p>I am trying to access files that are hosted on a remote cloud storage bucket through the <code>dev_appserver.py</code> dev server.</p> <p>This direct link to google cloud storage works:</p> <pre><code>https://leanplum-wordpress.storage.googleapis.com/leanplum-black.svg </code></pre> <p>where as the local via the ...
1
2016-07-06T22:43:59Z
38,272,792
<p>You need to make sure that auth will be configured with your google cloud project and that the client will connect to the production google cloud storage rather than the local development (which happens by default when local development server run is detected).</p> <p>See <a href="https://github.com/GoogleCloudPlat...
1
2016-07-08T17:56:17Z
[ "python", "google-app-engine", "google-cloud-storage" ]
Google App Engine Local Dev Server Does not Route to Remote Cloud Storage Bucket
38,234,985
<p>I am trying to access files that are hosted on a remote cloud storage bucket through the <code>dev_appserver.py</code> dev server.</p> <p>This direct link to google cloud storage works:</p> <pre><code>https://leanplum-wordpress.storage.googleapis.com/leanplum-black.svg </code></pre> <p>where as the local via the ...
1
2016-07-06T22:43:59Z
39,842,012
<p>We're still having this issue. We believe this is an issue that's originating from the Appengine Wordpress plugin.</p> <p>We came up with the following workaround to get the images loading properly:</p> <p>Create a Bookmarklet in Google Chrome and add the following url:</p> <pre><code>javascript:var start = var t...
0
2016-10-03T23:34:18Z
[ "python", "google-app-engine", "google-cloud-storage" ]
Sovren Resume Parser - Python
38,235,008
<p>I am trying to use the Sovren Resume Parser API and I am pretty new to APIs. My application is in Django-Python and thus, I would like to implement call and receive this API using a Python Script. </p> <p>Documentation - <a href="http://resumeparsing.com/" rel="nofollow">http://resumeparsing.com/</a></p> <p>I need...
0
2016-07-06T22:45:53Z
38,250,290
<pre><code>from zeep import Client client = Client('http://services.resumeparsing.com/ResumeService.asmx?wsdl') response = client.service.GetAccountInfo(request={'AccountId': 'AccountId','ServiceKey':'ServiceKey'}) print(response) </code></pre> <p>Using the Zeep module did the trick! This works with Python3 as well!...
1
2016-07-07T16:05:31Z
[ "python", "api" ]
Aggregating Fiscal Week data into monthly sum in pandas
38,235,026
<p>I have a dataset that looks like the following:</p> <pre><code> YR_FW YIELD 0 201401 12.3 1 201402 10.2 2 201403 7.2 3 201404 8.0 4 201405 1.2 ... .... .... 96 201446 102.3 97 201447 101.7 98 201448 89.5 99 201449 72.2 100 201450 88.0 101 ...
2
2016-07-06T22:47:11Z
38,235,085
<p>I would convert these to datetimes first:</p> <pre><code>In [11]: df["YR_FW"] = pd.to_datetime(df["YR_FW"].astype("str") + "-0", format="%Y%W-%w") In [12]: df Out[12]: YR_FW YIELD 0 2014-01-12 12.3 1 2014-01-19 10.2 2 2014-01-26 7.2 3 2014-02-02 8.0 4 2014-02-09 1.2 </code></pre> <p>Note that...
3
2016-07-06T22:52:55Z
[ "python", "pandas" ]
Aggregating Fiscal Week data into monthly sum in pandas
38,235,026
<p>I have a dataset that looks like the following:</p> <pre><code> YR_FW YIELD 0 201401 12.3 1 201402 10.2 2 201403 7.2 3 201404 8.0 4 201405 1.2 ... .... .... 96 201446 102.3 97 201447 101.7 98 201448 89.5 99 201449 72.2 100 201450 88.0 101 ...
2
2016-07-06T22:47:11Z
38,237,145
<p>Unfortunately, I don't have enough data to fully check the code, but this is what I arrived to right now. If we suppose that we have:</p> <pre><code>import pandas as pd import numpy as np df = pd.DataFrame({"YR_FW":[201401,201402,201403,201405,201506],"YIELD":[12.3,10.2,7.2,1.2,3.8]}) YR_FW YIELD 0 201...
0
2016-07-07T03:30:53Z
[ "python", "pandas" ]
Python exe - Cx_Freeze - ImportError DLL load failed
38,235,099
<p>In my machine (Windows), I can use my executable of my python program. But if I try on the machine of another person(Windows), it doesn't work.</p> <p>The executable blocks at the line : from unqlite import UnQLite</p> <p>I have fixed his dependency in packages variable: options={'build_exe':{'include_files':inclu...
0
2016-07-06T22:54:00Z
38,306,009
<p>Well, I have finally found the solution.</p> <p>I took a monitor software to look at the DLL load in my machine. I filtred all files with my process and the DLL in loaded path.</p> <p>In one hand, it was <strong>one python DLL</strong> which were missing. On an other hand, Cython expected <strong>one library from ...
0
2016-07-11T11:38:55Z
[ "python", "dll", "environment", "cx-freeze", "unqlite" ]
Python - Nested Classes (Parent-Child [New to Classes])
38,235,151
<p>I have this data </p> <pre><code>{Wednesday : {22 : {Type = x, Temp = x, Speed = x, Direction = x} {23 : {Type = x, Temp = x, Speed = x, Direction = x} </code></pre> <p>I am trying t...
1
2016-07-06T22:59:44Z
38,235,344
<p>Although numbers are not considered to be valid identifiers in Python (but that could be funny for trolling: <code>0 = 1 = 2 = 3 = 42</code>), things like <code>_3</code> are, but are generally considered to be <em>"private"</em> attributes by the python community (myself included), so i use <code>at</code> followed...
1
2016-07-06T23:19:47Z
[ "python", "python-3.x" ]
Python dictionary data manipulation
38,235,183
<p>I have the following dataset in Python:</p> <blockquote> <p>data = [{'id': '431876400186007/insights/page_fans_country/lifetime', 'name': 'page_fans_country', 'description': 'Lifetime: Aggregated Facebook location data, sorted by country, about the people who like your Page. (Unique Users)', 'title': 'Lifetime Li...
-3
2016-07-06T23:02:50Z
38,235,279
<p><code>print data[0]['values'][0]['value']</code> seems to work. It prints out this:</p> <pre><code>{'BD': 80, 'BE': 367, 'FR': 388, 'BG': 732, 'BR': 609, 'RU': 99, 'NL': 418, 'NO': 97, 'RO': 488, 'CH': 187, 'CO': 98, 'GR': 273321, 'CA': 317, 'CZ': 188, 'CY': 1820, 'GB': 2063, 'SK': 81, 'SE': 495, 'DK': 77, 'DE': 44...
1
2016-07-06T23:12:18Z
[ "python", "list", "dictionary" ]
Python dictionary data manipulation
38,235,183
<p>I have the following dataset in Python:</p> <blockquote> <p>data = [{'id': '431876400186007/insights/page_fans_country/lifetime', 'name': 'page_fans_country', 'description': 'Lifetime: Aggregated Facebook location data, sorted by country, about the people who like your Page. (Unique Users)', 'title': 'Lifetime Li...
-3
2016-07-06T23:02:50Z
38,235,284
<p>If I'm not mistaken, it looks like the <code>values</code> array is an aggregate snapshot, not a period value. Meaning that you should be able to just pull the last value and use that:</p> <pre><code>countryData = data[0]['values'][-1]['value'] </code></pre> <p><code>[0]</code> pulls the first (and only) item of t...
2
2016-07-06T23:12:44Z
[ "python", "list", "dictionary" ]
Python don't register in MySQL server
38,235,520
<p>there’s something wrong in my python script: when I try to put some data in my database and print it, it looks like it’s working, but when I rerun the code, or if I check the phpmyadmin, there’s no data saved in the db. Does anyone have some idea on how to solve this problem?</p> <pre><code>import mysql.conne...
0
2016-07-06T23:40:15Z
38,235,570
<p>You will need to add <code>conn.commit()</code> before <code>conn.close()</code>. That should solve the problem. </p>
0
2016-07-06T23:45:07Z
[ "python", "mysql" ]
Understanding and testing [self._class_._module_]._file_
38,235,566
<p>When reading a python-based software, I feel confused about a line of python code: <code>path = sys.modules[self.__class__.__module__].__file__</code>. </p> <p>I can guess it was trying to return the file name in class file, but I'm not very clear about the exact usage of this. I saved the related code segment int...
0
2016-07-06T23:44:54Z
38,237,055
<p>Classes in python have a <code>__module__</code> attribute which contains the name of the module in which the class was defined. Additionally, each module contains a <a href="https://docs.python.org/3.5/reference/import.html#__file__" rel="nofollow"><strong><code>__file__</code></strong></a> attribute which has the ...
0
2016-07-07T03:15:36Z
[ "python", "python-2.7", "python-3.x" ]
Extract data from API object in Python
38,235,672
<p>I am using an NLTK API to get the information by passing some text.</p> <pre><code>import requests r = requests.post("http://text-processing.com/api/sentiment/",data={'text':'I am a good boy'}) print(r.text) </code></pre> <p>The following is the Output.</p> <pre><code>{"probability": {"neg": 0.50955199890675162, ...
1
2016-07-06T23:58:05Z
38,235,722
<p>You need to call <code>r.json()</code> then access by key, .text will just give you a json string :</p> <pre><code>import requests r = requests.post("http://text-processing.com/api/sentiment/",data={'text':'I am a good boy'}) jsn_dict = r.json() </code></pre> <p>Then:</p> <pre><code>jsn_dict["probability"]["neutr...
3
2016-07-07T00:03:59Z
[ "python", "dictionary", "nltk" ]
Can I use filter() in django template?
38,235,718
<p>What I'd like to do is using filter() in django template like belows:</p> <p><code>models.py</code></p> <pre><code>from django.db import models From Django. utils import Timezone class Category(models.Model): url = models.CharField(max_length=200) site_name = models.CharField(max_length=50) board_name...
0
2016-07-07T00:03:29Z
38,235,914
<p>You can do it on view level by</p> <pre><code>def post_list(request, site_name=None, page=1): categories = Category.objects.filter(site_name=site_name.upper(), notice=True).order_by('board_name') return render(request, 'SNU/post_list.html',{'site_name':site_name.uppe...
0
2016-07-07T00:29:59Z
[ "python", "django", "django-templates" ]
When does __getattribute__ not get involved in attribute lookup?
38,235,750
<p>Consider the following:</p> <pre><code>class A(object): def __init__(self): print 'Hello!' def foo(self): print 'Foo!' def __getattribute__(self, att): raise AttributeError() a = A() # Works, prints "Hello!" a.foo() # throws AttributeError as expected </code></pre> <p>The imp...
3
2016-07-07T00:07:21Z
38,236,007
<blockquote> <p>The implementation of <code>__getattribute__</code> obviously fails all lookups</p> </blockquote> <p>Let's say it fails for all vanilla lookups.</p> <p>So how did <code>__getattribute__</code> itself get called in the first place since it is also an attribute of the class?</p> <hr> <p>An attribute...
1
2016-07-07T00:43:12Z
[ "python", "attributes" ]
How to get my objective-c client to talk to my python server?
38,235,804
<p>So I'm messing around with some iOS dev stuff and wanted to try to send some a string from the Xcode simulator to a server I've got running in python. I've never had two different programming languages talk so I thought that would be cool.</p> <p>I followed some objective-c socket tutorials online, and this is what...
1
2016-07-07T00:14:24Z
38,237,403
<p>Your code is working fine so I think you are likely making a simple error. Be sure to check the following: </p> <ul> <li>Start your python script first. From terminal: <code>python yourfilename.py</code></li> <li>Run your objective c code after the python server is listening <em>and</em> ensure that the code you've...
0
2016-07-07T04:08:26Z
[ "python", "ios", "objective-c", "sockets" ]
How to upload images to Google Cloud Storage using Google App Engine?
38,235,811
<p>I am trying to figure out a way to upload an image into Google Cloud Storage using Google App Engine.</p> <p>I have checked:</p> <p><a href="http://stackoverflow.com/questions/9237747/sending-images-to-google-cloud-storage-using-google-app-engine">Sending images to google cloud storage using google app engine</a><...
2
2016-07-07T00:15:42Z
38,239,097
<p>Uploading images through App Engine has three problems:</p> <p>First, it's very inefficient. You are using your App Engine instance hours to simply pass-through data from a user's browser to Google Cloud Storage.</p> <p>Second, it's slower (again, because you use an intermediary).</p> <p>Finally, App Engine does ...
2
2016-07-07T06:48:43Z
[ "python", "google-app-engine", "google-cloud-storage" ]
How to upload images to Google Cloud Storage using Google App Engine?
38,235,811
<p>I am trying to figure out a way to upload an image into Google Cloud Storage using Google App Engine.</p> <p>I have checked:</p> <p><a href="http://stackoverflow.com/questions/9237747/sending-images-to-google-cloud-storage-using-google-app-engine">Sending images to google cloud storage using google app engine</a><...
2
2016-07-07T00:15:42Z
38,340,107
<p>I upvoted the above answer as you should try to avoid passing data through App Engine if possible. If you really need to upload an image (or any other data) from App Engine to Google Cloud Storage in Python, the answer is as ChrisC73 pointed out to use the <a href="https://cloud.google.com/appengine/docs/python/goog...
1
2016-07-12T22:55:06Z
[ "python", "google-app-engine", "google-cloud-storage" ]
How to upload images to Google Cloud Storage using Google App Engine?
38,235,811
<p>I am trying to figure out a way to upload an image into Google Cloud Storage using Google App Engine.</p> <p>I have checked:</p> <p><a href="http://stackoverflow.com/questions/9237747/sending-images-to-google-cloud-storage-using-google-app-engine">Sending images to google cloud storage using google app engine</a><...
2
2016-07-07T00:15:42Z
38,419,324
<p>I ended up using <a href="https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/app-engine-cloud-storage-sample" rel="nofollow">https://cloud.google.com/appengine/docs/python/googlecloudstorageclient/app-engine-cloud-storage-sample</a> (The GCS client @ChrisC73 pointed out.</p> <p>Also, referred t...
0
2016-07-17T08:31:19Z
[ "python", "google-app-engine", "google-cloud-storage" ]
Python: Generate a geometric progression using list comprehension
38,235,829
<p>In Python, Can I generate a geometric progression using list comprehensions alone? I don't get how to refer to elements that were added to the list. </p> <p>That would be like <a href="http://stackoverflow.com/questions/18800804/writing-python-code-to-calculate-a-geometric-progression">Writing python code to calcul...
1
2016-07-07T00:18:16Z
38,235,877
<p>List comprehensions don't let you refer to previous values. You could get around this by using a <a href="https://docs.python.org/3/library/itertools.html#itertools.accumulate" rel="nofollow">more appropriate tool</a>:</p> <pre><code>from itertools import accumulate from operator import mul length = 10 ratio = 2 pr...
1
2016-07-07T00:23:48Z
[ "python", "list", "python-3.x", "list-comprehension" ]
Python: Generate a geometric progression using list comprehension
38,235,829
<p>In Python, Can I generate a geometric progression using list comprehensions alone? I don't get how to refer to elements that were added to the list. </p> <p>That would be like <a href="http://stackoverflow.com/questions/18800804/writing-python-code-to-calculate-a-geometric-progression">Writing python code to calcul...
1
2016-07-07T00:18:16Z
38,236,122
<p>If a geometric progression is defined by <code>a_n = a * r ** (n - 1)</code> and <code>a_n = r * a_(n - 1)</code>, then you could just do the following:</p> <pre><code>a = 2 r = 5 length = 10 geometric = [a * r ** (n - 1) for n in range(1, length + 1)] print(geometric) # [2, 10, 50, 250, 1250, 6250, 31250, 156250...
0
2016-07-07T01:00:23Z
[ "python", "list", "python-3.x", "list-comprehension" ]
Using Index for scatter plot Legend
38,235,870
<p>I've created a DataFrame with some stock information. When I try to use the index as the data labels it does not work. This makes it so I cannot differentiate the stocks, especially when I add more. When I plot the legend it shows the index list, dtype, and name. It seems to be combining every point into one label.<...
1
2016-07-07T00:23:20Z
38,238,032
<p>I could be wrong but I think <code>label=df.index</code> will not work when your index is unique text labels you want to plot individually. If your index is unique (or if it's a groupby), you can use a <code>for</code> loop to plot individual ticker rows in a single plot as well as give them a unique color (<code>c=...
1
2016-07-07T05:23:53Z
[ "python", "pandas", "matplotlib", "scatter-plot" ]
How do bit masks work in Python?
38,235,892
<p>Hi I wrote a program to see if a bit is "on" in class, but I'm not quite sure what it means by "on" and "off", and how bit masks work.</p> <p>Here's the code:</p> <pre><code>def check_bit4(input): mask = 0b1000 checker = input &amp; mask if checker &gt; 0: return("on") else: return(...
0
2016-07-07T00:26:58Z
38,236,015
<p>Computers represent integers with bits. This is a binary representation of a number (that is, using base 2). The only numbers in binary are 0 and 1, or "off" and "on". If you are not familiar with binary, you should read up on it, but basically you count in binary like this:</p> <pre><code>0000 0001 0010 0011 01...
1
2016-07-07T00:44:50Z
[ "python" ]
Pandas DataFrame to_dict fails after drop_duplicates
38,235,922
<p>I have a DataFrame, let's just call it <code>df</code>.</p> <p><code>return df.to_dict(orient="records")</code> dutifully spits out a list of dicts.</p> <p>But if I do</p> <pre><code>df.drop_duplicates return df.to_dict(orient="records") </code></pre> <p>it fails and says:</p> <blockquote> <p>'function' objec...
1
2016-07-07T00:30:40Z
38,235,935
<p>I think you miss <code>()</code>, because without the <code>()</code> the <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.drop_duplicates.html" rel="nofollow"><code>drop_duplicates</code></a> just refers to the function, so <code>df</code> becomes a copy of the function, not the resul...
2
2016-07-07T00:31:50Z
[ "python", "pandas", "dictionary", "dataframe" ]
in selenium the get command doesn't navigate to given URL and displays that it's missing a 'self' argument
38,235,968
<p>I'm using PyCharm with Python 3.5 and Selenium to write a program which pulls up google.com in Chrome. However, the get command says is takes two arguments: self and url. What is a self variable? Here is my code:</p> <pre><code>from selenium import webdriver #using .Chrome() gives me an error, but .Chrome doesn't ...
1
2016-07-07T00:35:47Z
38,237,230
<p>The following works</p> <pre><code>from selenium import webdriver driver = webdriver.Chrome() driver.get("http://www.google.com") </code></pre> <p>Please provide the error if this doesn't work for you.</p>
1
2016-07-07T03:43:42Z
[ "python", "google-chrome", "selenium", "pycharm" ]
initialize pandas DataFrame with defined dtypes
38,235,992
<p>The <code>pd.DataFrame</code> docstring specifies a scalar argument for the whole dataframe:</p> <p><code>dtype : dtype, default None Data type to force, otherwise infer</code></p> <p>Seemingly it is indeed intended to be a scalar, as following leads to an error:</p> <pre><code>dfbinseq = pd.DataFrame([], ...
2
2016-07-07T00:40:55Z
38,236,065
<p>You could use <code>convert_objects</code> to deduce better dtypes.... This is for multiple columns in pd.Dataframe?</p>
0
2016-07-07T00:51:29Z
[ "python", "pandas", "dataframe" ]
initialize pandas DataFrame with defined dtypes
38,235,992
<p>The <code>pd.DataFrame</code> docstring specifies a scalar argument for the whole dataframe:</p> <p><code>dtype : dtype, default None Data type to force, otherwise infer</code></p> <p>Seemingly it is indeed intended to be a scalar, as following leads to an error:</p> <pre><code>dfbinseq = pd.DataFrame([], ...
2
2016-07-07T00:40:55Z
38,236,097
<p>You can set <code>dtype</code> to <code>Series</code>:</p> <pre><code>import pandas as pd df = pd.DataFrame({'A':pd.Series([], dtype='str'), 'B':pd.Series([], dtype='int'), 'C':pd.Series([], dtype='float')}) print (df) Empty DataFrame Columns: [A, B, C] Index: [] print (df.d...
2
2016-07-07T00:56:12Z
[ "python", "pandas", "dataframe" ]
Count number of neurons and weights in a Caffe solution
38,236,013
<p>I have a Caffe project I have acquired with a <code>prototxt</code> model description and a <code>caffemodel</code> tuned parameter file (about 16 Mb in size). Is there an easy way to find out how many neurons and weights there is in the model, either from static analysis or at runtime?</p> <p>I can visualise the <...
0
2016-07-07T00:44:20Z
38,236,712
<p>Yes, you can count the weight parameters from the prototxt file, without even looking at the caffemodel. For a convolution layer, you can look at how many filters are there and what is the filter size. For example, if the convolution size is 3x3 and number of filters is 64, number of parameters for that layer would ...
2
2016-07-07T02:24:33Z
[ "python", "neural-network", "caffe" ]
How to write to a txt file ascii characters in python?
38,236,055
<p>I'm implementing a XOR method, and I want to write the ciphered message to a txt file, but in the way I'm doing it, I get strange characters instead of the message.</p> <p>Here is the code:</p> <pre><code>from itertools import cycle msg = 'RUNNINGFAST' key = 'SADSTORY' cipher = ''.join(chr(ord(c)^ord(k)) for c,k...
0
2016-07-07T00:50:39Z
38,236,111
<p>You actually are getting all the output in the text file. The "problem" is that your cipher is using the full range of all ASCII chars, which includes some non-printable chars. </p> <p>Example, <code>SOH</code> is the "start of heading" symbol, which doesn't really mean anything visually.</p> <p><a href="http://ww...
1
2016-07-07T00:58:33Z
[ "python", "ascii", "writetofile" ]
How to write to a txt file ascii characters in python?
38,236,055
<p>I'm implementing a XOR method, and I want to write the ciphered message to a txt file, but in the way I'm doing it, I get strange characters instead of the message.</p> <p>Here is the code:</p> <pre><code>from itertools import cycle msg = 'RUNNINGFAST' key = 'SADSTORY' cipher = ''.join(chr(ord(c)^ord(k)) for c,k...
0
2016-07-07T00:50:39Z
38,236,121
<p>I think you need to use another text editor. Windows' notepad doesn't render the control characters correctly.</p> <p>Try to use Programmers Notepad or Notepad++ for example.</p>
0
2016-07-07T01:00:14Z
[ "python", "ascii", "writetofile" ]
Format a decorator in Python
38,236,170
<p>RANT - Why do people say 'a decorator is a function that returns another function'? That definition makes no sense, because if that's all a decorator is, why wouldn't you just use the second function and not fool with the first at all? - END RANT</p> <p>Fortunately, I found a much more sensible definition here: <a ...
-2
2016-07-07T01:05:42Z
38,236,480
<p>Edit: I just realized you had an article linked that literally explains what decorators are step by step... but this is already typed up so...</p> <p>There's a feature called closures / function closures in Python.</p> <p>It's been awhile since I tried to explain / understand what happens at a lower level with clo...
3
2016-07-07T01:49:23Z
[ "python", "string-formatting", "python-decorators" ]
Why multiprocessing.Process behave differently on windows and linux for global object and function arguments
38,236,211
<p>The following code has different output when running on windows and linux (both with python2.7)</p> <pre><code>'''import_mock.py''' to_mock = None </code></pre> <pre class="lang-python prettyprint-override"><code>'''test.py''' import import_mock from multiprocessing import Process class A(object): def __init...
6
2016-07-07T01:11:10Z
38,236,445
<p>On Linux (and other Unix-like OSs), Python's <code>multiprocessing</code> module using <code>fork()</code> to create new child processes that efficiently inherit a copy of the parent process's memory state. That means the interpreter doesn't need to pickle the objects that are beging passed as the <code>Process</cod...
6
2016-07-07T01:45:40Z
[ "python", "multiprocessing" ]
Why multiprocessing.Process behave differently on windows and linux for global object and function arguments
38,236,211
<p>The following code has different output when running on windows and linux (both with python2.7)</p> <pre><code>'''import_mock.py''' to_mock = None </code></pre> <pre class="lang-python prettyprint-override"><code>'''test.py''' import import_mock from multiprocessing import Process class A(object): def __init...
6
2016-07-07T01:11:10Z
38,236,630
<p>Adding to @Blckknght's answer: on Windows, each process imports the original module "from scratch", while on Unix-y systems only the main process runs the whole module, while all other processes see whatever exists at the time <code>fork()</code> is used to create the new processes (no, <em>you're</em> not calling ...
3
2016-07-07T02:10:55Z
[ "python", "multiprocessing" ]
Naive bayes scikit learn warning "DeprecationWarning: Passing 1d arrays"
38,236,294
<p>I know that passing 1d array is deprecated in Naive Bayes classifier, which I do not know why. However, For some reasons, once I built my model, I want to loop through a list of items and for each item I should call the naive classifier to predict the class. So, imagine my training set is X and my target class set i...
1
2016-07-07T01:23:47Z
38,236,325
<p>Your testing data should have the same structure as your training data, modifying your testing <code>xx</code> to:</p> <pre><code>xx=[[1,1,0,0]] </code></pre> <p>will get rid of the warning.</p>
1
2016-07-07T01:27:40Z
[ "python", "scikit-learn", "naivebayes" ]
Changing the colour of all canvas items (rectangles) pressed by a mouse click and drag (Tkinter)
38,236,351
<p>I am designing an application for creating pixel art in Python. I currently have it so that the user can specify a required grid size (width * height) and it will create a grid of the specified height, with each grid square representing a point in a 2D list.</p> <p>I used Tkinter's canvas widget and it's create_rec...
0
2016-07-07T01:32:39Z
38,256,215
<p>You can create bindings that set a flag on button press, and release the flag on button release. You can set a binding on mouse motion that colors the item under the cursor when the flag is set. </p> <p>It would look something like this:</p> <pre><code>class Example(object): def __init__(self, parent): ...
0
2016-07-07T22:24:07Z
[ "python", "tkinter", "tkinter-canvas" ]
Are PIP packages curated? Is it safe to install them?
38,236,366
<p>With Debian or Ubuntu packages, there is <em>some</em> quality control. Is PIP similar, or is it a complete free-for-all? Can anyone upload any code they want under any name that they want?</p> <p>There seem to be some junk packages like <a href="https://pypi.python.org/pypi/opencv/0.0.1" rel="nofollow">https://pyp...
3
2016-07-07T01:34:46Z
38,238,493
<p>No, there are no checks on the code that is uploaded to PyPI (the Python Package Index, which is where pip downloads packages unless explicitly instructed otherwise). It is up to the maintainer of each package to ensure that whatever they make available on PyPI doesn't contain malware (unless they intend for it to b...
3
2016-07-07T06:04:18Z
[ "python", "security", "pip" ]
convert 2 arrays into a matrix in python
38,236,401
<p>I have a coordinates file which I read into a matrix in python. I want to create a delauney triangulation and plot it with the coordinates joined together with lines. I have the following code which creates the delauney but I am unsure how to plot it. Any help would be greatly appreciated. The code is as follows:</p...
-1
2016-07-07T01:38:50Z
38,236,466
<p>Take a look at the the scipy docs for <a href="http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.spatial.Delaunay.html" rel="nofollow">Delaunay</a>, which includes an example of how to plot the tessellation. </p>
0
2016-07-07T01:47:18Z
[ "python", "matplotlib", "triplot" ]
Getting Theano Bleeding Edge version to work in Windows
38,236,507
<p>Originally I had the non bleeding edge version of Theano which works fine in Anaconda 2. But I need the bleeding edge version for openCL use. However after putting "pip install --upgrade --no-deps git+git://github.com/Theano/Theano.git" into the command prompt (which successfully installs the bleeding edge version) ...
0
2016-07-07T01:53:14Z
39,461,366
<p>Not really.</p> <p>However, i had bad luck using Anaconda and Theano. Actually, you have to do <strong>Conda install theano</strong> , im not sure you can use bleeding edge like that on anaconda.</p> <hr> <p>I would advise you to check <a href="http://stackoverflow.com/questions/35630020/installing-theano/377807...
0
2016-09-13T02:25:54Z
[ "python", "git", "pip", "anaconda", "theano" ]
How to use applymap , lamda and dataframe together to filter / modify dataframe in python?
38,236,539
<p>So I 'm trying to figure it out how to replace <code>NaN</code> in <code>pd.DataFrame</code> .. ? Here in the example I created the 3x3 dataframe, having value in <code>df[1][2] = 'a'</code> and the rest are <code>NaN</code></p> <p>My understanding is that I can use <code>if</code> with in <code>lambda</code> and d...
3
2016-07-07T01:58:05Z
38,236,582
<p>Instead of using <code>apply</code>, you could use <code>fillna</code>. </p> <pre><code>df.fillna('o') </code></pre> <p>For more information about <a href="http://pandas.pydata.org/pandas-docs/stable/missing_data.html" rel="nofollow">Working with missing data</a>. You could also use <code>apply</code> with <code...
4
2016-07-07T02:03:32Z
[ "python", "function", "pandas", "lambda" ]
How to use applymap , lamda and dataframe together to filter / modify dataframe in python?
38,236,539
<p>So I 'm trying to figure it out how to replace <code>NaN</code> in <code>pd.DataFrame</code> .. ? Here in the example I created the 3x3 dataframe, having value in <code>df[1][2] = 'a'</code> and the rest are <code>NaN</code></p> <p>My understanding is that I can use <code>if</code> with in <code>lambda</code> and d...
3
2016-07-07T01:58:05Z
38,236,589
<p><code>np.nan</code> does not really return the value you are expecting, in order to create a valid predicate, you can use <code>pd.isnull</code>:</p> <pre><code>df = pd.DataFrame(index=range(0,3),columns=range(0,3)) df[1][2] = 'a' f = lambda x: 'o' if pd.isnull(x) else x df.applymap(f) # 0 1 2 #0 o o o ...
2
2016-07-07T02:04:35Z
[ "python", "function", "pandas", "lambda" ]
SWIG Or Boost -for Mapping C structures to Python
38,236,598
<p>I have requirement to map C Structures to Python. Any suggestion what will be the best approach to go for SWIG or Boost with least complexity. </p>
-1
2016-07-07T02:06:15Z
38,236,961
<p>If your structures are in pure C, then it's very easy with both methods. Or, you may consider <code>ctypes</code>, though my favorite is SWIG -- it automates things a lot.</p>
0
2016-07-07T03:03:18Z
[ "python", "c", "boost", "swig", "boost-python" ]
Object oriented programming: IS-A vs HAS-A relationships?
38,236,622
<p>I am learning about object oriented programming from </p> <blockquote> <p>Problem solving with Algorithms and Data structures</p> </blockquote> <p>book using the online version available on interactive python website. Link is mentioned below.</p> <p><a href="http://interactivepython.org/runestone/static/pythond...
0
2016-07-07T02:09:54Z
38,236,766
<p>You are missing two things here: implied function parameters and duck typing.</p> <p>Firstly, the syntax <code>tgate.setNextPin(self)</code> calls the function <code>setNextPin(tgate, self)</code>. The first parameter is the object for which the method is being called (usually named self). You are getting confuse...
0
2016-07-07T02:33:36Z
[ "python", "python-3.x", "oop" ]
Is a format-only update a frivolous Git commit?
38,236,636
<p>I have a Python project that I'm working on for research. I've been working on two different machines, and I recently discovered that half of my files used tabs and the other half used spaces.</p> <p>Python objected to this when I attempted to edit and run a file from one machine on the other, so I'd like to switch...
3
2016-07-07T02:12:04Z
38,236,665
<p>Unfortunately there is no way around the fact that at the textual level, this is a big change. The best you can do is not mix whitespace changes with any other changes. The topic of a such a commit should be nothing but the whitespace change.</p> <p>If this screwup is unpublished (only in your private repos), you c...
3
2016-07-07T02:16:26Z
[ "python", "git" ]
Is a format-only update a frivolous Git commit?
38,236,636
<p>I have a Python project that I'm working on for research. I've been working on two different machines, and I recently discovered that half of my files used tabs and the other half used spaces.</p> <p>Python objected to this when I attempted to edit and run a file from one machine on the other, so I'd like to switch...
3
2016-07-07T02:12:04Z
38,236,672
<p>There is, it's called a <code>rebase</code> - however, you'd probably want to add spaces to every file retroactively in each commit where you edited that file, which would be extremely tedious.</p> <p>However, there is absolutely nothing wrong with having a commit like this. A commit represents a change a distinct ...
5
2016-07-07T02:17:10Z
[ "python", "git" ]
Is a format-only update a frivolous Git commit?
38,236,636
<p>I have a Python project that I'm working on for research. I've been working on two different machines, and I recently discovered that half of my files used tabs and the other half used spaces.</p> <p>Python objected to this when I attempted to edit and run a file from one machine on the other, so I'd like to switch...
3
2016-07-07T02:12:04Z
38,284,795
<p>It is perfectly valid. Coupling a white space reformat with other changes in the same file could obfuscate the non white space changes. The commit has a single responsibility to reformat white space. </p>
0
2016-07-09T18:07:23Z
[ "python", "git" ]
Python determine if time is between two hours in variables
38,236,652
<pre><code>settingsNightStart = settings[28] settingsNightStop = settings[29] if datetime.time(settingsNightStart) &lt;= datetime.time.now() &lt;= datetime.time(settingsNightStop): Night = 1 </code></pre> <p>I have two variables coming from a database that users store there starting time and ending time in 24 hr...
0
2016-07-07T02:14:55Z
38,236,945
<p>suppose you have <code>start_hour</code> and <code>stop_hour</code>:</p> <p><code> this_hour = datetime.now().hour if start_hour &gt; stop_hour: night = start_hour &lt; this_hour or this_hour &lt; stop_hour else: night = start_hour &lt; this_hour &lt; stop_hour </code></p>
0
2016-07-07T02:59:44Z
[ "python" ]
How can I initialize a list and append objects of any type to it in Python
38,236,702
<p>I am trying to write a Python program that will initialize a list and add objects of any type to the list. I believe that I have initialized the list properly in my <code>__init__</code> method, but I cannot seem to pass any objects to it using the <code>.join()</code> method. I chose the <code>.join()</code> method...
0
2016-07-07T02:22:46Z
38,236,729
<p>You're not referencing the <code>contents</code> on the object instance (<code>self</code>) in the <code>put_in_bag</code> method; instead you're trying to join the argument to the argument itself and not touching the instance at all. Also, <code>join</code> is not a Python method on <code>list</code>s. Since you're...
1
2016-07-07T02:26:32Z
[ "python" ]
python3.5/pandas - converting multiple columns into datetime
38,236,778
<p>So I am trying to convert 2 columns into 1 datetime column. Input columns look like this:</p> <pre><code>date hour 1/1/2015 1 1/1/2015 2 1/1/2015 3 </code></pre> <p>where the values of <code>df.date</code> is a <code>string</code> and the values of <code>df.hour</code> is an <...
2
2016-07-07T02:36:14Z
38,236,866
<p>You can paste the two columns together as a single column and then convert with a corresponding <code>format</code> parameter:</p> <pre><code>pd.to_datetime(df['date'] + ' ' + df['hour'].astype(str), format = "%d/%m/%Y %H") # 0 2015-01-01 01:00:00 # 1 2015-01-01 02:00:00 # 2 2015-01-01 03:00:00 # dtype: date...
1
2016-07-07T02:48:16Z
[ "python", "datetime", "pandas" ]
python3.5/pandas - converting multiple columns into datetime
38,236,778
<p>So I am trying to convert 2 columns into 1 datetime column. Input columns look like this:</p> <pre><code>date hour 1/1/2015 1 1/1/2015 2 1/1/2015 3 </code></pre> <p>where the values of <code>df.date</code> is a <code>string</code> and the values of <code>df.hour</code> is an <...
2
2016-07-07T02:36:14Z
38,236,872
<p>Basically, you will need to use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.to_datetime.html" rel="nofollow"><code>pandas.to_datetime</code></a> and <a href="https://pymotw.com/2/datetime/" rel="nofollow"><code>datetime.timedelta</code></a>.</p> <pre><code>from datetime import timedelta df...
2
2016-07-07T02:49:07Z
[ "python", "datetime", "pandas" ]
python3.5/pandas - converting multiple columns into datetime
38,236,778
<p>So I am trying to convert 2 columns into 1 datetime column. Input columns look like this:</p> <pre><code>date hour 1/1/2015 1 1/1/2015 2 1/1/2015 3 </code></pre> <p>where the values of <code>df.date</code> is a <code>string</code> and the values of <code>df.hour</code> is an <...
2
2016-07-07T02:36:14Z
38,239,903
<p>This is another approach:</p> <pre><code>In [224]: df['datetime'] = pd.to_datetime(df['date']) + pd.TimedeltaIndex(df['hour'], unit='h') df Out[224]: date hour datetime 0 1/1/2015 1 2015-01-01 01:00:00 1 1/1/2015 2 2015-01-01 02:00:00 2 1/1/2015 3 2015-01-01 03:00:00 </code></pre>...
1
2016-07-07T07:35:26Z
[ "python", "datetime", "pandas" ]
How to unittest Flask websocket server (Flask-SocketIO)
38,236,808
<p>I wonder how can I unittest on my flask websocket server. My application supports quite many interface on REST API(Flask-restful) and Web Socket(Flask-SocketIO). All of websocket "emit" are proceed on celery process. I have problem unit-testing those websocket logic. </p> <ol> <li><p>Several guys said, First I have...
0
2016-07-07T02:40:55Z
38,254,323
<p>Some people prefer separate apps for HTTP and WebSocket, but that is not something I would recommend blindly. There are cases in which it makes sense to do so, others that do not, specially if you are using Flask-SocketIO, which gives you a fairly powerful integration.</p> <p>The Flask-SocketIO extension includes a...
0
2016-07-07T20:02:46Z
[ "python", "unit-testing", "flask", "websocket", "flask-socketio" ]
Use Unicode Greek letters in Matplotlib
38,236,825
<p>In MATLAB, if you type "\alpha" in an axis label it will render a 'plain-text' Greek character alpha, without the need for Latex. I hoping to do the same with Matplotlib's Pyplot. </p> <p>Following <a href="http://stackoverflow.com/questions/28905938/how-to-use-unicode-symbols-in-matplotlib">How to use unicode symb...
2
2016-07-07T02:42:43Z
38,237,092
<p>Generally, I think it is due to that your are running it in <code>Windows</code>, Am I right?</p> <p>In <code>Windows</code>, you will need to specify the exact location of your font directory, instead of just the file name.</p> <p>Here is what I do, after the <a href="http://www.stixfonts.org/install.html" rel="n...
3
2016-07-07T03:21:12Z
[ "python", "matplotlib", "unicode" ]
Specify Parquet properties pyspark
38,236,892
<p>How to specify Parquet Block Size and Page Size in PySpark? I have searched everywhere but cannot find any documentation for the function calls or the import libraries.</p>
2
2016-07-07T02:52:30Z
38,236,953
<p>According to <a href="https://mail-archives.apache.org/mod_mbox/spark-user/201410.mbox/%3C9DEF4C39-DFC2-411B-8987-5B9C33842974@videoamp.com%3E" rel="nofollow">spark-user archives</a></p> <pre><code>sc.hadoopConfiguration.setInt("dfs.blocksize", some_value) sc.hadoopConfiguration.setInt("parquet.block.size", some_va...
1
2016-07-07T03:01:15Z
[ "python", "apache-spark", "pyspark", "parquet" ]
Logistic Regression with scikit-learn giving key error while printing output
38,237,005
<p>I am trying to use logistic regression to classify message into 'spam' or 'ham'. I used data source from <a href="http://archive.ics.uci.edu/%20ml/datasets/SMS+Spam+Collection" rel="nofollow">http://archive.ics.uci.edu/ ml/datasets/SMS+Spam+Collection</a> And I found that TFIDF is the right way to get features from...
1
2016-07-07T03:10:19Z
38,237,498
<p>Start with this: </p> <pre><code>print sms_predictions for i, prediction in enumerate(sms_predictions[:5]): print i, prediction #print 'Prediction: %s. Message: %s' % (prediction, X_test_data[i]) </code></pre>
1
2016-07-07T04:20:56Z
[ "python", "pandas", "scikit-learn" ]
Running tests from coverage.py vs running coverage from test runner
38,237,057
<p>During the <a href="http://pythontesting.net/podcast/coverage-ned-batchelder/" rel="nofollow">Coverage.py with Ned Batchelder</a> python&amp;testing podcast, Brian and Ned briefly discussed that, if you need to run tests with coverage, <em>it is preferred to run tests from <code>coverage.py</code></em> executing the...
1
2016-07-07T03:15:51Z
38,243,662
<p>I guess I am uniquely qualified to answer this question :)</p> <p>mwchase and mgilson have it right in their comments: using a plugin means you are depending on that plugin's behavior being correct and understandable. In the name of being helpful, plugins will have their own logic that may have been the best idea ...
1
2016-07-07T10:54:32Z
[ "python", "unit-testing", "testing", "code-coverage", "coverage.py" ]
If found keywords print line else print python
38,237,095
<p>i am trying to write a code where i can search certain keywords from different files ; if found print line and hostname ; else not found print "Test Passed" and host name</p> <pre><code>Hostsfile.txt router1 router2 router1.txt not ready is ready reset me if required blah blahhh blahh router2.txt blah blahhh ...
0
2016-07-07T03:21:49Z
38,237,202
<p>I think this what you are looking for</p> <p>it will only print passed once if it passed</p> <pre><code>hosts = open((hostsfile) , "r") keys = ['Not Ready','RESET'] hosts = [hosts for hosts in (hosts.strip() for hosts in open(hostsfile)) if hosts] for host2 in hosts: f = [f for f in (f.strip() for f in open("ro...
2
2016-07-07T03:39:53Z
[ "python", "if-statement", "search" ]
Django channels - Echo example not working
38,237,120
<p>I'm following the instructions in the <a href="http://channels.readthedocs.io/en/latest/getting-started.html" rel="nofollow">documentation site</a>, but I got stuck in the echo example, the websocket is created correctly and it's connected to the server but when I send anything to the server I'm not getting any resp...
9
2016-07-07T03:26:32Z
38,250,625
<p>I changed to an older version of twisted and it fixed it. Hth</p>
5
2016-07-07T16:20:59Z
[ "javascript", "python", "django", "websocket", "django-channels" ]
compare whether value in one column is between two values in another column python pandas
38,237,153
<p>I have two data frames as follow:</p> <pre><code>A = pd.DataFrame({"value":[3, 7, 5 ,18,23,27,21,29]}) B = pd.DataFrame({"low":[1, 6, 11 ,16,21,26], "high":[5,10,15,20,25,30], "name":["one","two","three","four","five", "six"]}) </code></pre> <p>I want to find whether "value" in A is between 'high' and low' in B, ...
2
2016-07-07T03:31:52Z
38,237,377
<p>I believe you are looking for something like this:</p> <pre><code>In [1]: import pandas as pd In [2]: A = pd.DataFrame({"value":[3, 7, 5 ,18,23,27,21,29]}) In [3]: In [3]: B = pd.DataFrame({"low":[1, 6, 11 ,16,21,26], "high":[5,10,15,20,25,30], "name":["one","two","three","four","five", "six"]}) In [4]: A Out[...
0
2016-07-07T04:04:36Z
[ "python", "pandas" ]
compare whether value in one column is between two values in another column python pandas
38,237,153
<p>I have two data frames as follow:</p> <pre><code>A = pd.DataFrame({"value":[3, 7, 5 ,18,23,27,21,29]}) B = pd.DataFrame({"low":[1, 6, 11 ,16,21,26], "high":[5,10,15,20,25,30], "name":["one","two","three","four","five", "six"]}) </code></pre> <p>I want to find whether "value" in A is between 'high' and low' in B, ...
2
2016-07-07T03:31:52Z
38,237,513
<p>You can use a list comprehension to iterate through the values in <code>A</code>, and then use <code>loc</code> to get the relevant mapped values. <code>le</code> is less than or equal to, and <code>ge</code> is greater than or equal to.</p> <p>For example, <code>v = 3</code> in the first row. Using simple boolea...
3
2016-07-07T04:23:03Z
[ "python", "pandas" ]
Error : ImportError: cannot import name LoginForm
38,237,180
<p>I am facing import error while importing LoginForm</p> <pre><code>import form </code></pre> <p>This import imports perfectly. But when I do </p> <pre><code>from form import LoginForm Traceback (most recent call last): File "&lt;pyshell#2&gt;", line 1, in &lt;module&gt; from form import LoginForm ImportError: can...
0
2016-07-07T03:35:59Z
38,238,020
<p>Do you have a file in your directory called form.py? Or is this file itself called form.py? If so, python could be loading that instead. Especially if you are using 2.7,where relative imports are prioritized. </p> <p>Try printing </p> <p>print(form._ <em>file</em> _) (Double underscore before and after file) </p...
0
2016-07-07T05:22:34Z
[ "python", "forms", "login", "flask-login" ]
Error : ImportError: cannot import name LoginForm
38,237,180
<p>I am facing import error while importing LoginForm</p> <pre><code>import form </code></pre> <p>This import imports perfectly. But when I do </p> <pre><code>from form import LoginForm Traceback (most recent call last): File "&lt;pyshell#2&gt;", line 1, in &lt;module&gt; from form import LoginForm ImportError: can...
0
2016-07-07T03:35:59Z
38,265,676
<p>Your import statement is fine. </p> <p>If form is a file in your directory, you need to post its content. Most likely it's missing the definition for a LoginForm class. </p> <p>See this tutorial from miguel to show an example:</p> <p><a href="http://blog.miguelgrinberg.com/post/the-flask-mega-tutorial-part-iii-we...
0
2016-07-08T11:37:38Z
[ "python", "forms", "login", "flask-login" ]
Producing a dictionary from a two lists companies
38,237,188
<p>I have two lists...one with advertising companies and the other with their clients...I am looking to have an output in dictionary format which shows me the advertising company with all of the clients they service.</p> <pre><code>{agency:{company1, company2 etc etc}} Advertising Agency Company WPP Alienware OMNICO...
-5
2016-07-07T03:37:52Z
38,237,264
<p>A simple way would be to use <a href="https://docs.python.org/3/library/collections.html#collections.defaultdict" rel="nofollow">collections.defaultdict</a>:</p> <pre><code>answer = defaultdict(set) for agency, company in zip(agencies, companies): answer[agency].add(company) </code></pre>
0
2016-07-07T03:48:31Z
[ "python", "list", "dictionary" ]
Setting a default sys.path for IPython Notebook
38,237,284
<p>I have all my .py files inside a folder script and all my IPython-notebooks under a folder named Notebook. </p> <p>There are multiple cross dependencies for each notebook file on one or more files on script.</p> <p>Having <code>sys.path.append</code> on top of every notebook seems cumbersome and I am hoping there ...
0
2016-07-07T03:51:18Z
38,288,291
<p>After some research I realized changing <code>PYTHONPATH</code> in <code>.bash_profile</code> should do the trick.</p> <p>Here are the two lines that I added to my <code>.bash_profile</code></p> <pre><code>PYTHONPATH="&lt;path where DeriveFinalResultSet.py exists&gt;:$PYTHONPATH" export PYTHONPATH </code></pre> <...
0
2016-07-10T03:25:19Z
[ "python", "ipython-notebook", "jupyter-notebook", "sys.path" ]
Setting a default sys.path for IPython Notebook
38,237,284
<p>I have all my .py files inside a folder script and all my IPython-notebooks under a folder named Notebook. </p> <p>There are multiple cross dependencies for each notebook file on one or more files on script.</p> <p>Having <code>sys.path.append</code> on top of every notebook seems cumbersome and I am hoping there ...
0
2016-07-07T03:51:18Z
38,288,353
<p>To avoid "hidden configurations" (i.e. things that aren't in source control/machine-specific) and to maintain a notebook/code separation like you describe, I do something like the below:</p> <pre><code>code/ mymodule.py mypackage/ __init__.py notebooks/ mynb.ipynb mynb2.ipynb paths.py ...
0
2016-07-10T03:41:09Z
[ "python", "ipython-notebook", "jupyter-notebook", "sys.path" ]
Unable to install django on python version 3.5?
38,237,295
<p>I have Python 3.5 so I think pip is already installed on my system. The website says:</p> <blockquote> <p>pip is already installed if you're using Python 2 >=2.7.9 or Python 3 >=3.4 downloaded from python.org, but you'll need to upgrade pip.</p> </blockquote> <p>Now, I downloaded the <code>get-pip.py</code> and ...
0
2016-07-07T03:52:45Z
38,239,866
<p>I think the problem is in unlinked <code>pip</code> command for Windows cmd. To resolve this issue on Linux, the most common way is to link executable from directory where it lives to <code>/usr/bin</code> by <code>ln -s</code> command. </p> <p>I dont't know how to do this in Windows, but one simple way to run <cod...
0
2016-07-07T07:32:53Z
[ "python", "django", "pip", "virtualenv", "python-3.5" ]
Trying to Compare a dictionary to a text file
38,237,419
<p>I am trying out python for a simple web scrapper that checks a website for names, puts them all in a dictionary with the link, then compares the names to a list I all ready have saved. The problem I am stuck on is trying to make a new dictionary with the names from the website that are not in the saved list.</p> <p...
1
2016-07-07T04:10:24Z
38,237,462
<p>Try to change</p> <pre><code>file_lines = f.readlines() </code></pre> <p>to </p> <pre><code>file_lines = f.read().splitlines() </code></pre> <p>The former one keeps the newline <code>\n</code> at the end of the line. </p> <p>In addition <code>final_dict.update({k, v})</code> should probably be <code>final_d...
2
2016-07-07T04:16:28Z
[ "python", "dictionary" ]
Trying to Compare a dictionary to a text file
38,237,419
<p>I am trying out python for a simple web scrapper that checks a website for names, puts them all in a dictionary with the link, then compares the names to a list I all ready have saved. The problem I am stuck on is trying to make a new dictionary with the names from the website that are not in the saved list.</p> <p...
1
2016-07-07T04:10:24Z
38,237,496
<p>Your algorithm isn't very efficient. For <em>each</em> item in <code>together</code>, it reads the entire file. If you handle each line in the file as you encounter it, it's much faster:</p> <pre><code>together = dict(zip(names, links)) with open('file.txt', 'r') as f: for line in f: if line in togethe...
2
2016-07-07T04:20:53Z
[ "python", "dictionary" ]
Scikit-learn dataset maker not accepting command-line arguments
38,237,421
<p>I'm working through a tutorial in Scikit-learn, and one section creates a dataset. This:</p> <pre><code>#Generate the example datapoints, red and blue. X, t = sklearn.datasets.make_circles(n_samples=100, shuffle=False, factor=0.3, noise=0.1) T = np.zeros((100,2)) T[t==1,1] = 1 T[t==0,0] = 1 #Seperate the datapoint...
0
2016-07-07T04:10:27Z
38,238,039
<p>From <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.seed.html" rel="nofollow">http://docs.scipy.org/doc/numpy/reference/generated/numpy.random.seed.html</a> and <a href="http://scikit-learn.org/stable/modules/generated/sklearn.datasets.make_circles.html" rel="nofollow">http://scikit-learn....
1
2016-07-07T05:24:35Z
[ "python", "numpy", "dataset", "scikit-learn", "command-line-arguments" ]
Mac App on El Capitan with Python Child Process
38,237,431
<p>I have been building an Mac app and part of its architecture is that it spins off a python child process to index some files in the background (there are simpler libraries to use for indexing for python). It launches the python by executing the python file directly. The parent Mac app and child python process then c...
0
2016-07-07T04:11:54Z
38,237,522
<p>Perhaps instead of using sockets, you could have your Python process communicate with the parent process by reading from stdin and/or writing to stdout? That would avoid any interactions with the firewall.</p>
0
2016-07-07T04:24:20Z
[ "python", "osx", "sockets" ]
How to disable the calculations log of pulp
38,237,449
<p>I am using "pulp" in python together with GUROBI to solve some optimization problems. For example, the calculations log for GUROBI is:</p> <pre><code>Optimize a model with 12 rows, 25 columns and 39 nonzeros Coefficient statistics: Matrix range [1e+00, 1e+00] Objective range [1e+00, 1e+00] Bounds range ...
0
2016-07-07T04:15:13Z
38,238,135
<p>I just found how we can do that: instead of default way of calling Gurobi which is:</p> <pre><code>pulp.GUROBI().solve(prob) </code></pre> <p>we need to write:</p> <pre><code>pulp.GUROBI(msg=0).solve(prob) </code></pre>
0
2016-07-07T05:33:40Z
[ "python", "gurobi", "pulp" ]
How to disable the calculations log of pulp
38,237,449
<p>I am using "pulp" in python together with GUROBI to solve some optimization problems. For example, the calculations log for GUROBI is:</p> <pre><code>Optimize a model with 12 rows, 25 columns and 39 nonzeros Coefficient statistics: Matrix range [1e+00, 1e+00] Objective range [1e+00, 1e+00] Bounds range ...
0
2016-07-07T04:15:13Z
38,559,688
<p>m0_as's answer is correct. Just want to share some more details. In PuLP library each solver class derives from the same base class LpSolver.</p> <pre><code>class LpSolver: """A generic LP Solver""" def __init__(self, mip = True, msg = True, options = [], *args, **kwargs): self.mip = mip se...
0
2016-07-25T04:23:49Z
[ "python", "gurobi", "pulp" ]
tkinter Buttons not calling functions
38,237,460
<p>I am a beginner programmer trying to create a program that allows the user to player Rock, Paper, Scissors using tkinter. I haven't learned tkinter in class, but this is my final project, so I was trying to learn something new to impress.</p> <p>I was able to figure out how to position everything, but my buttons do...
0
2016-07-07T04:16:19Z
38,325,683
<p>The display does not change because to change the text of the label <code>winOrLoss</code> you need to do: <code>winOrLoss.configure(text=win_or_loss)</code>, just changing <code>win_or_loss</code> won't change the label content. </p> <p>Another possibility is to use a StringVar:</p> <pre><code>win_or_loss = Strin...
0
2016-07-12T10:02:40Z
[ "python", "tkinter" ]
How to Properly Format RetroFit Header for Django
38,237,486
<p>I am trying to send an HTTP request using Django that includes a username and password in the header in order to retrieve a token.</p> <p>On my computer terminal I do the following command and it works properly:</p> <pre><code>http POST 127.0.0.1:8000/api-token-auth/ username='admin' password='whatever' </code></p...
0
2016-07-07T04:19:47Z
38,237,661
<p>If the values are dynamic you can use:</p> <pre><code>Call&lt;TokenJSON&gt; getToken(@Header("username") String var1, @Header("password") String var2); </code></pre> <p>Or if they are static you can use:</p> <pre><code>@Headers({"username: Bar", "password: Pong"}) Call&lt;TokenJSON&gt; getToken(); </code></pre>
0
2016-07-07T04:43:46Z
[ "android", "python", "django", "header", "retrofit" ]