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
Why is the option to start web2py scheduler no longer working in widget?
38,193,768
<p>I recently move to the latest version of web2py to try and resolve an issue with the scheduler.</p> <p>However now the widget will not let me start the scheduler thread.</p> <p>I have a scheduler.py file in the models folder.</p> <p>I can start the scheduler by passing passing paramerter <code>-K app_name</code> ...
0
2016-07-05T00:44:51Z
38,195,045
<p>I think maybe <a href="https://github.com/web2py/web2py/commit/b517c898b84769d82127d5ce3df8e09b77816790#diff-e3d5ad780b88ca2841fadbd25ece7475R327" rel="nofollow">this commit</a> did it. Not sure of the exact reason, though there is some discussion <a href="https://groups.google.com/forum/#!msg/web2py-developers/uJoQ...
1
2016-07-05T04:08:54Z
[ "python", "scheduled-tasks", "web2py" ]
python pass variables with wget and check result
38,193,779
<p>im so new to python im try to pass variables with Wget</p> <p>code:</p> <pre><code>USERID = 201 RES = os.system("wget http://localhost/ -O /usr/setting.txt") if RES == error: print RES else print 'good' </code></pre> <p>what i need to pass is </p> <pre><code>http://localhost/?userid=203 or username=jam...
0
2016-07-05T00:46:53Z
38,194,129
<p>Given the somewhat strange constraint that you must use <code>os.system()</code> you can construct the command string like this:</p> <pre><code>import os user_id = 201 dest_filename = '/tmp/setting.txt' command = 'wget http://localhost/userid={} -O {}'.format(user_id, dest_filename) res = os.system(command) if...
1
2016-07-05T01:50:22Z
[ "python", "variables", "wget" ]
Share data across Flask view functions
38,193,816
<p>I am using Flask to build a very small one-page dynamic website. I want to share a list of variables and their values across functions without using a class.</p> <p>I looked into Flask's <code>View</code> class, however I feel as if my application isn't large enough nor complex enough to implement a class-based ver...
2
2016-07-05T00:52:59Z
38,203,607
<p>I believe what you are looking for is the <a href="http://flask.pocoo.org/docs/0.11/api/#flask.g" rel="nofollow">application local <code>g</code></a>. According to the documentation</p> <blockquote> <p>Just store on this whatever you want.</p> </blockquote> <p>It meets your needs here exactly.</p> <pre><code>fr...
4
2016-07-05T12:34:34Z
[ "python", "flask" ]
How to copy rows from one df to another with matching value
38,193,845
<p>Lets say I have one df like this:</p> <pre><code> A B 0 John 131234 1 Sam 3454 2 Mandy 6521 3 Frank 134536 </code></pre> <p>And another df:</p> <pre><code> X Y Z 0 Erick Green Pencil 1 Sam Red Phone 2 David Orange PC 3 Mandy Blue Notebook </code></pre> <p>How ...
0
2016-07-05T00:59:28Z
38,194,015
<pre><code>import pandas as pd import numpy as np df0 = pd.DataFrame(np.array([ ('John', 131234), ('Sam', 3454), ('Mandy', 6521), ('Frank', 134536) ]), columns=['A', 'B'] ) df1 = pd.DataFrame(np.array([ ('Erick', 'Green', 'Pencil'), ('Sam', 'Red', 'Pho...
0
2016-07-05T01:30:07Z
[ "python", "pandas", "merge" ]
How to copy rows from one df to another with matching value
38,193,845
<p>Lets say I have one df like this:</p> <pre><code> A B 0 John 131234 1 Sam 3454 2 Mandy 6521 3 Frank 134536 </code></pre> <p>And another df:</p> <pre><code> X Y Z 0 Erick Green Pencil 1 Sam Red Phone 2 David Orange PC 3 Mandy Blue Notebook </code></pre> <p>How ...
0
2016-07-05T00:59:28Z
38,195,839
<p>use pandas <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html" rel="nofollow">merge</a> for joining:</p> <pre><code>df Out[24]: A B 0 John 131234 1 Sam 3454 2 Mandy 6521 3 Frank 134536 df1 Out[25]: X Y Z 0 Erick Green ...
0
2016-07-05T05:36:21Z
[ "python", "pandas", "merge" ]
How to dynamically change a function interface, e.g. f() -> f(a, b, c='default')
38,193,907
<p>I would like to dynamically create methods in a class B that have the same name and 'interface' (with that I mean args/kwargs/defaults list) as the methods in class A, but different code.</p> <p>Generic interfaces like f(*args, **kwargs) are not desirable.</p> <p>Generating the methods and adding them dynamically ...
2
2016-07-05T01:10:12Z
38,194,031
<p>You can't modify a function's signature once it's created. You'll have to do as you describe. The source of the <a href="https://github.com/micheles/decorator/blob/master/src/decorator.py" rel="nofollow"><code>decorator</code></a> library may be useful to you, as it contains a mechanism for making a function with ...
0
2016-07-05T01:32:50Z
[ "python" ]
How to properly mask a numpy 2D array?
38,193,958
<p>Say I have a two dimensional array of coordinates that looks something like</p> <p><code>x = array([[1,2],[2,3],[3,4]])</code></p> <p>Previously in my work so far, I generated a mask that ends up looking something like</p> <p><code>mask = [False,False,True]</code></p> <p>When I try to use this mask on the 2D coo...
3
2016-07-05T01:18:46Z
38,194,016
<p>Is this what you are looking for?</p> <pre><code>import numpy as np x[~np.array(mask)] # array([[1, 2], # [2, 3]]) </code></pre> <p>Or from <a href="http://docs.scipy.org/doc/numpy/reference/maskedarray.baseclass.html#numpy.ma.MaskedArray.mask" rel="nofollow">numpy masked array</a>:</p> <pre><code>newX = n...
3
2016-07-05T01:30:28Z
[ "python", "numpy", "matrix", "mask", "masked-array" ]
How to properly mask a numpy 2D array?
38,193,958
<p>Say I have a two dimensional array of coordinates that looks something like</p> <p><code>x = array([[1,2],[2,3],[3,4]])</code></p> <p>Previously in my work so far, I generated a mask that ends up looking something like</p> <p><code>mask = [False,False,True]</code></p> <p>When I try to use this mask on the 2D coo...
3
2016-07-05T01:18:46Z
38,194,100
<p>In your last example, the problem is not the mask. It is your use of <code>compressed</code>. From the docstring of <code>compressed</code>:</p> <pre><code>Return all the non-masked data as a 1-D array. </code></pre> <p>So <code>compressed</code> flattens the nonmasked values into a 1-d array. (It has to, becau...
1
2016-07-05T01:46:09Z
[ "python", "numpy", "matrix", "mask", "masked-array" ]
How to properly mask a numpy 2D array?
38,193,958
<p>Say I have a two dimensional array of coordinates that looks something like</p> <p><code>x = array([[1,2],[2,3],[3,4]])</code></p> <p>Previously in my work so far, I generated a mask that ends up looking something like</p> <p><code>mask = [False,False,True]</code></p> <p>When I try to use this mask on the 2D coo...
3
2016-07-05T01:18:46Z
38,194,439
<p>Your <code>x</code> is 3x2:</p> <pre><code>In [379]: x Out[379]: array([[1, 2], [2, 3], [3, 4]]) </code></pre> <p>Make a 3 element boolean mask:</p> <pre><code>In [380]: rowmask=np.array([False,False,True]) </code></pre> <p>That can be used to select the rows where it is True, or where it is False...
2
2016-07-05T02:37:16Z
[ "python", "numpy", "matrix", "mask", "masked-array" ]
Python: Can't turn string into JSON
38,193,959
<p>For the past few hours, I've been fighting to get a string into a JSON dict. I've tried everything from json.loads(... which throws an error:</p> <pre><code>requestInformation = json.loads(entry["request"]["postData"]["text"]) //throws this error json.decoder.JSONDecodeError: Expecting property name enclosed in do...
0
2016-07-05T01:18:47Z
38,194,054
<p>You'll need a r before JSON String, or replace all \ with \\</p> <p>This works:</p> <pre><code> import json validasst_json = r'''{ "postData": { "mimeType": "application/json", "text": "{items:[{n:'PackageChannel.GetUnitsInConfigurationForUnitType',ps:[{n:'unitType',v:\"Analys...
-1
2016-07-05T01:39:08Z
[ "python", "json", "decode" ]
Python: Can't turn string into JSON
38,193,959
<p>For the past few hours, I've been fighting to get a string into a JSON dict. I've tried everything from json.loads(... which throws an error:</p> <pre><code>requestInformation = json.loads(entry["request"]["postData"]["text"]) //throws this error json.decoder.JSONDecodeError: Expecting property name enclosed in do...
0
2016-07-05T01:18:47Z
38,194,309
<p>the <code>json</code> module wants a string where the keys are also wrapped in double quotes</p> <p>so the string below would work:</p> <pre><code>mystring = '{"items":[{"n":"PackageChannel.GetUnitsInConfigurationForUnitType", "ps":[{"n":"unitType","v":"ActionTemplate"}]}]}' myjson = json.loads(mystring) </code></...
0
2016-07-05T02:18:44Z
[ "python", "json", "decode" ]
Sikuli without sacrificing mouse and keyboard
38,194,034
<p>I am not very familiar with Sikuli.</p> <ol> <li>Can I use Sikuli with python 3.4 or only 2.7?</li> <li>In a Sikuli project, the script takes over the mouse and keyboard, meaning you can't work on something else while this is running. Obviously this is a big waste of time. Is there any way to run Sikuli and work on...
-1
2016-07-05T01:34:19Z
38,194,313
<ol> <li>Sikuli is not using Python but Jython. If you need more information you should refer to Jython <a href="http://www.jython.org/" rel="nofollow">official documentation</a>.</li> <li>Sikuli is using Java Robot library to control keyboard an mouse and physically controls both. There is no way to work around that.<...
1
2016-07-05T02:19:29Z
[ "python", "python-2.7", "python-3.x", "automation", "sikuli" ]
Sikuli without sacrificing mouse and keyboard
38,194,034
<p>I am not very familiar with Sikuli.</p> <ol> <li>Can I use Sikuli with python 3.4 or only 2.7?</li> <li>In a Sikuli project, the script takes over the mouse and keyboard, meaning you can't work on something else while this is running. Obviously this is a big waste of time. Is there any way to run Sikuli and work on...
-1
2016-07-05T01:34:19Z
38,831,549
<ol start="2"> <li><p>You can actually use sikuli while also doing other work. It's not done directly through sikuli though. I have a script that does it but I don't have direct access so I'll just give the semantics. It's done using VNC sessions.</p> <p>In a bash script, start a vnc session</p> <p>Point the display ...
0
2016-08-08T14:13:21Z
[ "python", "python-2.7", "python-3.x", "automation", "sikuli" ]
Python filter doesn't work as expected
38,194,037
<p>I have the following Python code:</p> <pre><code>a = [1,2,3,'4','55',6] filter(int,a) </code></pre> <p>The output is:</p> <pre><code>[1, 2, 3, '4', '55', 6] </code></pre> <p><code>filter()</code> is supposed to remove the elements from the provided sequence which translate into false, and return only those eleme...
-1
2016-07-05T01:35:05Z
38,194,041
<p>Use <a href="https://docs.python.org/3/library/functions.html#isinstance" rel="nofollow"><code>isinstance</code></a> instead:</p> <pre><code>&gt;&gt;&gt; a =[1,2,3,'4','55',6] &gt;&gt;&gt; filter(lambda x: isinstance(x, int),a) [1, 2, 3, 6] </code></pre> <p><a href="https://docs.python.org/3/library/functions.html...
3
2016-07-05T01:36:34Z
[ "python" ]
Python filter doesn't work as expected
38,194,037
<p>I have the following Python code:</p> <pre><code>a = [1,2,3,'4','55',6] filter(int,a) </code></pre> <p>The output is:</p> <pre><code>[1, 2, 3, '4', '55', 6] </code></pre> <p><code>filter()</code> is supposed to remove the elements from the provided sequence which translate into false, and return only those eleme...
-1
2016-07-05T01:35:05Z
38,194,047
<p><code>filter()</code> calls the callable that it is given (<code>int</code>) with each item in the iterable and returns those that are Truthy. Since <code>int('56')</code> results in <code>56</code>, it is Truthy and is included in the results. You may want something like this:</p> <pre><code>filter(lambda x: isi...
2
2016-07-05T01:37:35Z
[ "python" ]
Python filter doesn't work as expected
38,194,037
<p>I have the following Python code:</p> <pre><code>a = [1,2,3,'4','55',6] filter(int,a) </code></pre> <p>The output is:</p> <pre><code>[1, 2, 3, '4', '55', 6] </code></pre> <p><code>filter()</code> is supposed to remove the elements from the provided sequence which translate into false, and return only those eleme...
-1
2016-07-05T01:35:05Z
38,194,158
<p>Try this:</p> <pre><code>[x for x in a if isinstance(x, int)] </code></pre> <p>or</p> <pre><code>filter(lambda x: isinstance(x, int), a) </code></pre>
0
2016-07-05T01:54:53Z
[ "python" ]
Python filter doesn't work as expected
38,194,037
<p>I have the following Python code:</p> <pre><code>a = [1,2,3,'4','55',6] filter(int,a) </code></pre> <p>The output is:</p> <pre><code>[1, 2, 3, '4', '55', 6] </code></pre> <p><code>filter()</code> is supposed to remove the elements from the provided sequence which translate into false, and return only those eleme...
-1
2016-07-05T01:35:05Z
38,194,160
<p>I agree with @niemmi's and @zondo's solution i.e.</p> <pre><code>filter(lambda x: isinstance(x, int), a) </code></pre> <p>Now the question is why filter(int, a) didn't work ?</p> <p>Filter ultimately call <strong>function(val)</strong> and if this returns false then it filtered it out.</p> <pre><code>&gt;&gt;&gt...
1
2016-07-05T01:55:18Z
[ "python" ]
Portfolio tracker in python
38,194,043
<p>I'm making a portfolio tracker using <a href="http://pandas.pydata.org/" rel="nofollow">pandas</a> remote data function, however, I'm running into a problem passing in multiple stock names and tickers.</p> <p>I would like to create separate data frames by the company name and I'm attempting to use <code>**kwargs</c...
0
2016-07-05T00:54:43Z
38,194,098
<p>The problem is that you keep overwriting the key value, so you are effectively only saving the last data set.</p> <p>You should track the keys and their results separately, something like this:</p> <pre><code>results = {} # this is an empty dictionary for key, value in kwargs.iteritems(): results[key] = web.D...
0
2016-07-05T01:45:55Z
[ "python", "python-2.7", "pandas", "yahoo-finance" ]
How can I connect two points in 3D scatter plot with arrow?
38,194,247
<p>I am trying to connect two points in a 3D scatter plot with an arrow. I tried using <code>quiver</code> with the following code</p> <pre><code>import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D fig = plt.figure(figsize=(20, 15)) ax = fig.add_subplot(111, projection='3d') xs1 = [40,50,34] ys1 ...
1
2016-07-05T02:09:28Z
38,194,621
<p>Construct own class based on <code>FancyArrow</code> to plot in 3d dimension:</p> <pre><code>import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d import proj3d from matplotlib.patches import FancyArrowPatch class Arrow3D(FancyArrowPatch): def __init__(self, xs, ys, ...
1
2016-07-05T03:02:00Z
[ "python", "matplotlib" ]
Represent xgboost model as utf-8
38,194,253
<p>For some historical reasons I can only train xgboost model on one machine, and use on the other one, and for transfering my model I am constrained to use only json files => I need to squeeze my xgboost into json.</p> <p>I tried:</p> <pre><code>json.dumps({'model': pickle.dumps(bst)}) </code></pre> <p>But I get er...
0
2016-07-05T02:10:38Z
38,335,855
<p>Solution was to use base64 library</p> <pre><code>import base64 pickle.dumps({'model': base64.b64encode(pickle.dumps(model))} </code></pre>
0
2016-07-12T17:52:35Z
[ "python", "json", "serialization", "pickle", "xgboost" ]
matlab convolution "same" to numpy.convolve
38,194,270
<p>I noticed that when I use conv(a, b, 'same') in matlab, it would return say M of length 200, but when I use numpy.convolve(a, b, 'same') it would return N of length 200, but shifted by one element compared to M (N[1:] would be the same as M[0:-1] and M[-1] would not be in N, N[0] not in M), how can I fix this?</p> ...
2
2016-07-05T02:12:55Z
38,194,669
<p>My guess is that the length of the shorter input array is even. In this case, there is an ambiguity in how it should be handled when the method is "same". Apparently Matlab and numpy adopted different conventions.</p> <p>There is an example of the use of the 'same' method on the Matlab documentation web page (<a ...
2
2016-07-05T03:08:34Z
[ "python", "matlab", "numpy" ]
How to update a variable in "realtime" using functions which take many seconds to return a value
38,194,297
<p>What logic should be used to update a variable such as a current mean in real time? </p> <p>For example in the script below <code>obs_mean()</code> produces a mean by listening to incoming sensor data. The function <code>listen_to_observations()</code> is an example function which behaves similarly to the real sens...
1
2016-07-05T02:17:11Z
38,194,573
<p>You could just break up your array line into separate statements, and compute the mean after every observation:</p> <pre><code>import numpy as np import random import time current_mean = None def listen_to_observations(): #listen to a stream of observations time.sleep(1) yield random.random() def obs...
0
2016-07-05T02:55:19Z
[ "python", "python-3.x", "multiprocessing", "real-time", "sensor" ]
Why it's giving me True as output as "None" is not a boolean type... so why "not None = True"
38,194,301
<p>I tried this code to see what happens , but i cant get the logic behind it , i was expecting an error ... just for curiosity </p> <h1>python2.7</h1> <pre><code>x = not None print x </code></pre>
0
2016-07-05T02:17:27Z
38,194,315
<p>When Python evaluates <code>not</code>, it tries to convert the value to a boolean. In this case, None is "falsy" (<a href="https://docs.python.org/2.4/lib/truth.html" rel="nofollow">https://docs.python.org/2.4/lib/truth.html</a>), so <code>not None</code> evaluates to <code>True</code>.</p> <p>So, <code>x = not N...
4
2016-07-05T02:19:56Z
[ "python", "python-2.7" ]
Why it's giving me True as output as "None" is not a boolean type... so why "not None = True"
38,194,301
<p>I tried this code to see what happens , but i cant get the logic behind it , i was expecting an error ... just for curiosity </p> <h1>python2.7</h1> <pre><code>x = not None print x </code></pre>
0
2016-07-05T02:17:27Z
38,194,318
<p><code>None</code> evaluates to <code>False</code>. The opposite of <code>False</code> is <code>True</code>. Thus, the result of <code>not None</code> is <code>True</code>. The boolean type conversion happens automatically, similar to what happens in <code>3 + True</code>, which gives <code>4</code>.</p>
0
2016-07-05T02:20:02Z
[ "python", "python-2.7" ]
Why it's giving me True as output as "None" is not a boolean type... so why "not None = True"
38,194,301
<p>I tried this code to see what happens , but i cant get the logic behind it , i was expecting an error ... just for curiosity </p> <h1>python2.7</h1> <pre><code>x = not None print x </code></pre>
0
2016-07-05T02:17:27Z
38,194,348
<p>Because <code>not</code> is a boolean type operator (a logical NOT), it converts None into a boolean. None as a boolean is False. The opposite of False, or <code>not None</code> is True, thus printing True.</p> <pre><code>&gt;&gt;&gt; print(bool(None)) False &gt;&gt;&gt; print(not bool(None)) True </code></pre>
1
2016-07-05T02:23:24Z
[ "python", "python-2.7" ]
500 error from allauth when moving django app from local to production
38,194,371
<p>I'm having difficulty moving my django 1.9.3 app from local development to production on Heroku, specifically using allauth (0.25.2) to login via Twitter.</p> <p>It appears I'm having the same problem as <a href="http://stackoverflow.com/questions/37894531/django-allauth-not-working-on-production">django allauth no...
0
2016-07-05T02:27:17Z
38,196,106
<p>Taking e4c5's suggestion, I turned on debug in the production environment. This quickly lead to this question: <a href="https://stackoverflow.com/questions/15409366/django-socialapp-matching-query-does-not-exist#15428889">Django: SocialApp matching query does not exist</a> and the problem being with my SITE_ID confi...
0
2016-07-05T05:57:55Z
[ "python", "django", "heroku", "django-allauth" ]
Python Windows get key press length and time between each press
38,194,488
<p>I'm trying to make a button recorder for a game I'm working on, but it requires timings (around 100 or so)</p> <p>I need a program that can record when I press the spacebar in another program, for how long it's held down for (<code>heldtime</code>), and the time in between the next press in milliseconds (<code>wait...
0
2016-07-05T02:42:56Z
38,194,592
<p>You can use this to learn how to set a timer: <a href="http://stackoverflow.com/questions/17211188/how-to-create-a-timer-on-python">How to create a timer on python</a></p> <p>And use this to learn how to create events to listen for the spacebar being pressed (provided you're using the Tkinter module to write your ...
0
2016-07-05T02:57:32Z
[ "python", "python-2.7" ]
Extracting noun phrases from NLTK using python
38,194,579
<p>I am new to both python and nltk. I have converted the code from <a href="https://gist.github.com/alexbowe/879414" rel="nofollow">https://gist.github.com/alexbowe/879414</a> to the below given code to make it run for many documents/text chunks. But I got the following error</p> <pre><code> Traceback (most recent ca...
2
2016-07-05T02:56:19Z
38,194,665
<p>You need to either:</p> <ul> <li>decorate each of <code>normalize</code>, <code>acceptable_word</code>, and <code>leaves</code> with @staticmethod, or</li> <li>add a <code>self</code> parameter as the first parameter of these methods.</li> </ul> <p>You're calling <code>self.leaves</code> which will pass <code>self...
2
2016-07-05T03:07:44Z
[ "python", "nltk" ]
Array on Ctypes
38,194,723
<p>What is the difference between:</p> <pre><code>c_int(24) 24 * c_int (24 * c_int)() (24 * c_int) &gt;&gt;&gt;c_int(24) == 24 * c_int False &gt;&gt;&gt; 24 * c_int == (24 * c_int) True &gt;&gt;&gt; 24 * c_int == (24 * c_int)() False </code></pre> <p>When I'm asking the difference it means what option above is a rea...
0
2016-07-05T03:18:23Z
38,233,491
<pre><code>&gt;&gt;&gt; from ctypes import * &gt;&gt;&gt; c_int(24) # Create instance of c_int (c_long is an alias) c_long(24) &gt;&gt;&gt; 24 * c_int # Creates an 24-element array type (NOT an instance) &lt;class '__main__.c_long_Array_24'&gt; &gt;&gt;&gt; (24 * c_int)() # Creates an instance of a 24-element array. ...
0
2016-07-06T20:45:39Z
[ "python", "python-2.7", "ctypes" ]
Resample all images in the database to the same voxel size
38,194,787
<p>I have 3 dicom stacks of size <code>512x512x133, 512x512x155 and 512x512x277</code>. I would like to resample all the stack to make the sizes <code>512x512x277, 512x512x277 and 512x512x277</code>. How to do that?</p> <p>I know I can do resampling using slice thickness and pixel spacing. But that would not ensure sa...
2
2016-07-05T03:28:19Z
38,194,923
<p>You can use <a href="http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.ndimage.interpolation.zoom.html" rel="nofollow"><code>scipy.ndimage.interpolate.zoom</code></a>, specifying the array of zoom factors for each axis like this:</p> <pre><code># example for first image zoomArray = desiredshape.astyp...
0
2016-07-05T03:50:31Z
[ "python", "matlab", "image-processing", "dicom" ]
Python: How to have a user input a string to test if equal to var
38,194,802
<p>So I am new to python and I know the very basics. I am making a sort of database, but you need a password to get in. I have a variable that is equal to the password, but I can't figure out how to have the user input something, then it tests if it is equal to the variable. I have a basic if statement, but I can't get...
-1
2016-07-05T03:30:30Z
38,194,851
<p>If you want to get user input (and mask it) you can do:</p> <pre><code>import getpass password = getpass.getpass() </code></pre> <p>For inputs that you don't want/need to mask in python, you can do:</p> <pre><code>user_input = raw_input("Please enter some text: ") </code></pre> <p>Note: <code>raw_input</code> is...
2
2016-07-05T03:38:29Z
[ "python", "variables", "input" ]
How to block key strokes from closing the window and making it non resizable?
38,194,815
<p>I have a GUI application which requires a non resizable full screen at all times and also it needs to prevent closing of window using keystrokes.I used resizable(false,false) but that does nothing on macOS. Hence I thought <em>overrideredirect</em> would do the job.<br/><br/> However when I use it,the entry widgets ...
1
2016-07-05T03:33:01Z
38,227,358
<p>I have a program that follows similar requirements, but in a restricted hardware access environment. My solution was to simply remove the hardware keyboard and build an on-screen keyboard without the problem keys. It's a bit of a hack, but if you can control the hardware it's worth a look.</p>
0
2016-07-06T15:03:41Z
[ "python", "osx", "tkinter", "fullscreen" ]
How to set the R_HOME environment variable to the R home directory?
38,194,876
<p>I am trying to import rpy2 into python and I am getting this error:</p> <pre><code>RuntimeError: The R home directory could not be determined. Try to install R &lt;https://www.r-project.org/&gt;, set the R_HOME environment variable to the R home directory, or add the directory of the R interpreter to the PATH envir...
1
2016-07-05T03:41:25Z
38,194,910
<p>It is the other way around -- the R in your <code>PATH</code> should know its home:</p> <pre><code>edd@don:~$ R RHOME /usr/lib/R edd@don:~$ </code></pre> <p>This echos the last line recommendation -- have your R in the <code>PATH</code>.</p> <p>On another machine with both R and R-devel, I choose to address the ...
2
2016-07-05T03:46:44Z
[ "python", "rpy2" ]
How can I create n number of files in python?
38,194,886
<p>say user gives a number n=3 then I have to create 3 files dynamically. How will I do that? What can be the names of those files. Specifically I want n number of .jpg file created.</p>
-2
2016-07-05T03:42:21Z
38,194,993
<p>Assuming you have an image stored in some format (maybe base 64 string?) already, you can do something like:</p> <pre><code>n = raw_input("Number of files: ") image_list = ... # your logic for the image data here n = int(n) for i in range(n): image = open("image" + str(i) + ".jpg", "w") image.write(image_li...
1
2016-07-05T04:00:37Z
[ "python", "image", "file" ]
DRF Create and Retrieve m2m with through model
38,194,890
<p>I want to save m2m relationship with through model</p> <h1>models.py</h1> <pre><code>from django.db import models class Student(utils.PersonalDetailsMixin, utils.ContactDetailsMixin, TimeStampedModel): guardians = models.ManyToManyField('core.Guardian', through='Relation') class Relation(models.Model): s...
0
2016-07-05T03:43:15Z
38,195,802
<p>You'll need to have the <code>MembershipSerializer</code> nested in the <code>GroupSerializer</code> replacing the <code>PersonSerializer</code> and have the <code>MembershipSerializer</code> that has a nested <code>PersonSerializer</code> in order for this to work.</p> <p>Alternatively, you could replace the <code...
1
2016-07-05T05:32:38Z
[ "python", "django", "django-rest-framework" ]
DRF Create and Retrieve m2m with through model
38,194,890
<p>I want to save m2m relationship with through model</p> <h1>models.py</h1> <pre><code>from django.db import models class Student(utils.PersonalDetailsMixin, utils.ContactDetailsMixin, TimeStampedModel): guardians = models.ManyToManyField('core.Guardian', through='Relation') class Relation(models.Model): s...
0
2016-07-05T03:43:15Z
38,197,981
<pre><code>class MembershipSerializer(serializers.ModelSerializer): person = serializers.PrimaryKeyRelatedField(queryset=Person.objects.all()) group = serializers.PrimaryKeyRelatedField(queryset=Group.objects.all()) class Meta: model = Membership fields = ('person', 'group', 'date_joined', ...
1
2016-07-05T07:49:55Z
[ "python", "django", "django-rest-framework" ]
multiprocessing.cpu_count returning wrong number of cores
38,194,951
<p>I try to use the following code to decide the number of cores of my laptop:</p> <pre><code>import multiprocessing multiprocessing.cpu_count() </code></pre> <p>The result is 8, but when I open the system report, I can see that I have only 1 CPU with 4 cores.</p> <p>What's wrong with <code>cpu_count()</code>?</p>
0
2016-07-05T03:54:57Z
38,195,013
<p>What CPU do you have, it might be counting the Physical cores + virtual cores.</p>
0
2016-07-05T04:03:39Z
[ "python" ]
multiprocessing.cpu_count returning wrong number of cores
38,194,951
<p>I try to use the following code to decide the number of cores of my laptop:</p> <pre><code>import multiprocessing multiprocessing.cpu_count() </code></pre> <p>The result is 8, but when I open the system report, I can see that I have only 1 CPU with 4 cores.</p> <p>What's wrong with <code>cpu_count()</code>?</p>
0
2016-07-05T03:54:57Z
38,195,037
<p>You have 4 physical cores, but 8 logical processors. For example, you may have a processor with <a href="https://en.wikipedia.org/wiki/Hyper-threading" rel="nofollow">hyper-threading</a>.</p> <p>From SuperUser: <a href="http://superuser.com/questions/168809/difference-between-cores-and-processors">Difference Betwee...
1
2016-07-05T04:08:03Z
[ "python" ]
Regex, test to see if characters other than exists
38,194,992
<p>I'd like to use regex to see if any character other than a certain set exists.</p> <p>For example, I'd like to test for the letters 'p', 'v', 'c' in a string. If any other characters are in the string, I want the test to return True. If only 'p', 'v', 'c' or a combination thereof exists, I want the test to return...
1
2016-07-05T04:00:25Z
38,195,097
<p>Use <code>set(..)</code></p> <pre><code>if set(yourString) - set("pvc"): return True else: return False </code></pre> <p>Edit: this should be turned into a single expression. <br></p> <pre><code>return set(your_string) - set('pvc') </code></pre>
6
2016-07-05T04:16:29Z
[ "python", "regex" ]
Regex, test to see if characters other than exists
38,194,992
<p>I'd like to use regex to see if any character other than a certain set exists.</p> <p>For example, I'd like to test for the letters 'p', 'v', 'c' in a string. If any other characters are in the string, I want the test to return True. If only 'p', 'v', 'c' or a combination thereof exists, I want the test to return...
1
2016-07-05T04:00:25Z
38,195,098
<pre><code>import re not (re.search('^[pvc]+$', string)) </code></pre> <p>Not sure what you want if string is empty, and this one will return true.</p>
2
2016-07-05T04:16:33Z
[ "python", "regex" ]
Regex, test to see if characters other than exists
38,194,992
<p>I'd like to use regex to see if any character other than a certain set exists.</p> <p>For example, I'd like to test for the letters 'p', 'v', 'c' in a string. If any other characters are in the string, I want the test to return True. If only 'p', 'v', 'c' or a combination thereof exists, I want the test to return...
1
2016-07-05T04:00:25Z
38,195,104
<p>I think this most straightforwardly captures your intent:</p> <pre><code>any(char not in 'pvc' for char in mystring) </code></pre> <p>It should be clear to anyone reading the code what you want to do.</p>
2
2016-07-05T04:17:53Z
[ "python", "regex" ]
Regex, test to see if characters other than exists
38,194,992
<p>I'd like to use regex to see if any character other than a certain set exists.</p> <p>For example, I'd like to test for the letters 'p', 'v', 'c' in a string. If any other characters are in the string, I want the test to return True. If only 'p', 'v', 'c' or a combination thereof exists, I want the test to return...
1
2016-07-05T04:00:25Z
38,195,223
<pre><code>import re x = 'pvc' regex = re.compile(r'[^p|v|c]') if regex.search(x) is not None: print True else: print False </code></pre>
0
2016-07-05T04:33:44Z
[ "python", "regex" ]
Converting python nested list with unequal elements in second layer to dataframe
38,195,021
<p>Say that I have a nested list with unequal number of elements in the second layer like <code>a=[[1,2,3],[4,5],[6,7,8,9]]</code>. I also have corresponding list containing date variables like <code>b=[['Mon','Tues','Wed'],['Mon','Wed'],['Mon','Tues','Wed','Thur']]</code>. I would like to convert <code>a</code> and <c...
1
2016-07-05T04:05:15Z
38,195,084
<p>I guess something like this <code>[dict(zip(keysA,keysB)) for keysA,keysB in zip(a,b)]</code> ... but it has nothing to do with pandas or numpy ...</p> <pre><code>&gt;&gt;&gt; a=[[1,2,3],[4,5],[6,7,8,9]] &gt;&gt;&gt; b=[['Mon','Tues','Wed'],['Mon','Wed'],['Mon','Tues','Wed','Thur']] &gt;&gt;&gt; print [dict(zip(key...
0
2016-07-05T04:14:41Z
[ "python", "pandas", "dataframe", "merge" ]
Converting python nested list with unequal elements in second layer to dataframe
38,195,021
<p>Say that I have a nested list with unequal number of elements in the second layer like <code>a=[[1,2,3],[4,5],[6,7,8,9]]</code>. I also have corresponding list containing date variables like <code>b=[['Mon','Tues','Wed'],['Mon','Wed'],['Mon','Tues','Wed','Thur']]</code>. I would like to convert <code>a</code> and <c...
1
2016-07-05T04:05:15Z
38,198,749
<p>Best I could come up with is to zip up each record into a dictionary, create a single row dataframe for that row then concat (or outerjoin) this to the previous rows. Here's the code:</p> <pre><code>a = [[1,2,3],[4,5],[6,7,8,9]] b = [['Mon','Tues','Wed'],['Mon','Wed'],['Mon','Tues','Wed','Thur']] df = pd.DataFrame(...
0
2016-07-05T08:34:54Z
[ "python", "pandas", "dataframe", "merge" ]
How to update openshift application which does not receive automatic updates?
38,195,089
<p>I'm trying to figure out how install security updates for my OpenShift application.</p> <p>It's a community created openshift 'flask' framework which does not seem to receive automatic updates:<br> <a href="https://hub.openshift.com/quickstarts/116-flask" rel="nofollow">https://hub.openshift.com/quickstarts/116-fla...
-1
2016-07-05T04:15:27Z
38,198,806
<p>Yours is a python app so you need to say what are it's dependencies from the <strong>setup.py</strong> file.</p> <p>Put it in there and fill the link to pypi where to find it</p> <pre><code>#!/usr/bin/env python from setuptools import setup setup( # GETTING-STARTED: set your app name: name='YourAppName',...
0
2016-07-05T08:37:49Z
[ "python", "flask", "openshift", "openshift-client-tools", "openshift-cartridge" ]
How to avoid Runtime error in this coding challenge?
38,195,113
<p>I am completing <a href="https://www.hackerrank.com/challenges/the-minion-game" rel="nofollow">this HackerRank</a> coding challenge. Essentially, the challenge asks us to find all the substrings of the input string without mixing up the letters. Then, we count the number of substrings that start with a vowel and cou...
1
2016-07-05T04:19:00Z
38,195,164
<p>The problem here is your algorithm.You are finding all the Sub strings of the text. It takes exponential time to solve the problem. That's why you got run time errors here. You have to use another good algorithm to solve this problem rather than using sub strings.</p>
2
2016-07-05T04:27:10Z
[ "python", "string", "python-3.x" ]
How to avoid Runtime error in this coding challenge?
38,195,113
<p>I am completing <a href="https://www.hackerrank.com/challenges/the-minion-game" rel="nofollow">this HackerRank</a> coding challenge. Essentially, the challenge asks us to find all the substrings of the input string without mixing up the letters. Then, we count the number of substrings that start with a vowel and cou...
1
2016-07-05T04:19:00Z
38,195,341
<p>Here's a quick and dirty partial solution based on my hints:</p> <pre><code>input_str = raw_input() kevin = 0 for i, c in enumerate(input_str): if c.lower() in "aeiou": kevin += len(input_str) - i print kevin </code></pre> <p>Basically, iterate over each character, and if it is in the set of vowels, Ke...
4
2016-07-05T04:47:51Z
[ "python", "string", "python-3.x" ]
Python - Server listening from two UDP sockets
38,195,174
<p>Im new in Python. And I can't make the server listen to two ports at the same time. This is the code I have written until now:</p> <pre><code>sock_client1 = socket.socket(socket.AF_INET, # Internet socket.SOCK_DGRAM) # UDP sock_client1.bind((SEND_IP, SEND_CLIENT_PORT)) sock_client1....
0
2016-07-05T04:28:29Z
38,202,284
<blockquote> <pre><code>ready_client1 = select.select([sock_client1], [], [], None) ready_client2 = select.select([sock_client2], [], [], None) </code></pre> </blockquote> <p>Try using a single <code>select</code>:</p> <pre><code>ready_read, ready_write, exceptional = select.select( [sock_client1, sock_client2], ...
1
2016-07-05T11:27:08Z
[ "python", "sockets", "udp" ]
How can I get the foreign key object value?
38,195,237
<p>I have 3 tables as follows. User table has student info. LecMst table has lecture info. And LecReq table has lecture info students have registered.</p> <p>models.py</p> <pre><code>class User(models.Model): usn = models.CharField(max_length=20, primary_key=True, verbose_name='usn') nm = models.CharFie...
0
2016-07-05T04:35:06Z
38,196,636
<p>You can access foreign model object directly like model.foreign_model_field.field</p> <p>So try.</p> <p>For lecture name try: {{ member.leccode_id.lecname }} For student name try: {{ member.usn_id.nm }}</p>
0
2016-07-05T06:32:53Z
[ "python", "django", "foreign-key-relationship", "relationships" ]
How can I get the foreign key object value?
38,195,237
<p>I have 3 tables as follows. User table has student info. LecMst table has lecture info. And LecReq table has lecture info students have registered.</p> <p>models.py</p> <pre><code>class User(models.Model): usn = models.CharField(max_length=20, primary_key=True, verbose_name='usn') nm = models.CharFie...
0
2016-07-05T04:35:06Z
38,196,842
<p>The related objects can be accessed easily as:</p> <pre><code>{{ member.leccode_id.lecname }} </code></pre> <p>More information on <a href="https://docs.djangoproject.com/en/1.9/topics/db/queries/#lookups-that-span-relationships" rel="nofollow">Django Docs: Lookups that span relationships</a>.</p> <p>Please also ...
1
2016-07-05T06:45:30Z
[ "python", "django", "foreign-key-relationship", "relationships" ]
How can I get the foreign key object value?
38,195,237
<p>I have 3 tables as follows. User table has student info. LecMst table has lecture info. And LecReq table has lecture info students have registered.</p> <p>models.py</p> <pre><code>class User(models.Model): usn = models.CharField(max_length=20, primary_key=True, verbose_name='usn') nm = models.CharFie...
0
2016-07-05T04:35:06Z
38,197,091
<p>So, I guess what you are trying to get is:</p> <p>for every lecture print, the student (name and number) registered in that lecture along with the lecture code.</p> <pre><code>lectures_info = LecReq.objects.prefetch_related('leccode_id', 'usn_id') for lecture in lectures_info: print lecture.leccode_id.leccode...
1
2016-07-05T06:59:59Z
[ "python", "django", "foreign-key-relationship", "relationships" ]
while loop stuck at same condtion
38,195,258
<p>I have a code which creates a snapshot and then checks if it is done, i wrote the following code, but for some reason it doesn't update the <code>state</code> variable and the while loops keep printing the same thing even if the snapshot has been <code>completed</code></p> <p>The following is the code :</p> <pre><...
1
2016-07-05T04:37:22Z
38,195,960
<pre><code>snapshot = ec2.create_snapshot(VolumeId='vol-f9e7d220', Description='fra01-he-trial-ansible01') </code></pre> <p>This line is only executed once and at that instance the <code>state</code> is "<code>pending</code>". You have to recheck the state of <code>snapshot</code> variable again inside while loop.</p>...
1
2016-07-05T05:46:19Z
[ "python", "boto3" ]
while loop stuck at same condtion
38,195,258
<p>I have a code which creates a snapshot and then checks if it is done, i wrote the following code, but for some reason it doesn't update the <code>state</code> variable and the while loops keep printing the same thing even if the snapshot has been <code>completed</code></p> <p>The following is the code :</p> <pre><...
1
2016-07-05T04:37:22Z
38,211,175
<p>As Pratik mentioned, your statement is only executing once and never updating. You can update your resource with <code>.load()</code>. Even better though, I recommend you use the <a href="http://boto3.readthedocs.io/en/latest/reference/services/ec2.html#EC2.Waiter.SnapshotCompleted" rel="nofollow">waiter</a>. This w...
1
2016-07-05T19:26:49Z
[ "python", "boto3" ]
Parsing JSON in python for second object
38,195,274
<p>I have a sample JSON in this format: </p> <p>JSON FILE:</p> <pre><code>{ "Name": "ABC", "Phone":"123", "Address":[{"City":"City-1"},{"Country":"Country-1"}] } { "Name": "ABC-1", "Phone":"123-1", "Address":[{"City":"City-2"},{"Country":"Country-2"}] } </code></pre> <p>Is there any approach to pa...
0
2016-07-05T04:39:19Z
38,195,748
<p>There is error in your json file. I modified your json and written code for traverse each element in it.</p> <blockquote> <p>Error:</p> </blockquote> <pre><code>Error: Parse error on line 9: ... "Country-1" }]}{ "Name": "ABC-1", -------------------^ Expecting 'EOF', '}', ',', ']', got '{' </code></pre> <bloc...
1
2016-07-05T05:27:51Z
[ "python", "json" ]
Parsing JSON in python for second object
38,195,274
<p>I have a sample JSON in this format: </p> <p>JSON FILE:</p> <pre><code>{ "Name": "ABC", "Phone":"123", "Address":[{"City":"City-1"},{"Country":"Country-1"}] } { "Name": "ABC-1", "Phone":"123-1", "Address":[{"City":"City-2"},{"Country":"Country-2"}] } </code></pre> <p>Is there any approach to pa...
0
2016-07-05T04:39:19Z
38,195,993
<p>Each record on json file is separated by ','. So, your file should look like:</p> <pre><code>[{ "Name": "ABC", "Phone": "123", "Address": [{ "City": "City-1" }, { "Country": "Country-1" }] }, { "Name": "ABC-1", "Phone": "123-1", "Address": [{ "City": "City-2"...
0
2016-07-05T05:48:39Z
[ "python", "json" ]
Parsing JSON in python for second object
38,195,274
<p>I have a sample JSON in this format: </p> <p>JSON FILE:</p> <pre><code>{ "Name": "ABC", "Phone":"123", "Address":[{"City":"City-1"},{"Country":"Country-1"}] } { "Name": "ABC-1", "Phone":"123-1", "Address":[{"City":"City-2"},{"Country":"Country-2"}] } </code></pre> <p>Is there any approach to pa...
0
2016-07-05T04:39:19Z
38,196,112
<p>First of all this is not valid json format, </p> <p>You can check <a href="http://jsonlint.com/" rel="nofollow">here</a> you json format</p> <p>You should use this try.json file</p> <pre><code>{ "data":[{ "Name": "ABC", "Phone":"123", "Address":[{"City":"City-1"},{"Country":"Country-1"...
0
2016-07-05T05:58:31Z
[ "python", "json" ]
Write a single poly-linear string to multiple lines in .txt
38,195,312
<p>I have encountered a strange problem which I am struggling to resolve. When I run a <code>re.findall()</code> through a .txt file, and then try to print and write the results. all of the results I would expect appear, but they do so in different formats. The code (modified from a similar thread I found earlier):</p>...
0
2016-07-05T04:44:07Z
38,195,442
<p>I'll start with your last comment. What <code>str(i)</code> does is it converts <code>i</code> to its string representation (which is defined in <code>i</code>'s class's <code>__str__</code> method). If you call <code>str(4)</code> you get <code>'4'</code>, for example. This is unnecessary in this case because <code...
1
2016-07-05T04:57:47Z
[ "python", "regex" ]
Matplotlib widget used on a plot produced by another matplotlib widget
38,195,415
<p>I am trying to use matplotlib LassoSelector to select some points from a scatter plot and produce a separate figure for selected points only. When I try to use another matplotlib widget on the second plot it doesn't work but there is no error or warning message. Below is a minimal example with LassoSelector and Span...
2
2016-07-05T04:55:30Z
38,198,574
<p><code>matplotlib</code> widgets are event driven, so wait for user input. The problem with you code is you are trying to create a new figure with a new event handler <code>SpanSelector</code>. I'm not sure if you can add new events as a result of previous ones and with <code>SpanSelector</code> commented out, I get ...
0
2016-07-05T08:24:53Z
[ "python", "matplotlib", "widget", "matplotlib-widget" ]
Having trouble comparing two indexes in python tkinter
38,195,458
<p>I don't understand the logic here:</p> <pre><code>import tkinter t = tkinter.Text() print(t.compare('1.2', '&lt;', '1.3')) print(t.compare('1.2', '&gt;', '1.3')) print(t.compare('1.2', '==', '1.3')) </code></pre> <p>This outputs False, False, True. I thought that you were supposed to be able to compare indexes wit...
1
2016-07-05T04:59:15Z
38,195,528
<p><code>compare</code> is based on the text in the <code>Text</code> widget object.</p> <p>Initially, text is empty. So any indexing will return empty string; they are compared equal.</p> <p>Insert some strings into the text widget, then you will see difference:</p> <pre><code>&gt;&gt;&gt; t.insert(0.0, 'asdf') &gt...
0
2016-07-05T05:07:51Z
[ "python", "python-3.x", "tkinter" ]
How do I reference local variables across my code without using the global functions
38,195,496
<p>I am working on an inventory system for a game I am working on, I've wrote these blocks of code for the system so far. I want the system to work without the use of global functions because I've read that you should avoid using global functions. </p> <pre><code>while not done: global inventory pygame.mouse.s...
0
2016-07-05T05:04:34Z
38,195,560
<p>Consider why do you want to share one local variable between many functions? Maybe better way for you is to simply create a class, where <code>inventory</code> or something more descriptive will be as a object variable.</p> <pre><code>class MyGame: def __init__(): # something self.inventory = Tr...
0
2016-07-05T05:10:17Z
[ "python", "pygame", "python-3.4" ]
How do I reference local variables across my code without using the global functions
38,195,496
<p>I am working on an inventory system for a game I am working on, I've wrote these blocks of code for the system so far. I want the system to work without the use of global functions because I've read that you should avoid using global functions. </p> <pre><code>while not done: global inventory pygame.mouse.s...
0
2016-07-05T05:04:34Z
38,195,712
<blockquote> <p>because I've read that you should avoid using [global statements]</p> </blockquote> <p>I think you've misunderstood. The <code>global</code> keyword is not bad in and of itself. Rather, if your implementation <em>requires use of</em> the <code>global</code> keyword then your implementation is bad (in...
2
2016-07-05T05:25:08Z
[ "python", "pygame", "python-3.4" ]
How do I reference local variables across my code without using the global functions
38,195,496
<p>I am working on an inventory system for a game I am working on, I've wrote these blocks of code for the system so far. I want the system to work without the use of global functions because I've read that you should avoid using global functions. </p> <pre><code>while not done: global inventory pygame.mouse.s...
0
2016-07-05T05:04:34Z
38,195,826
<p>In general, if you frequently reference a variable whose value is assigned once and not changed, define it at module scope near the top of your file according to the <a href="https://www.python.org/dev/peps/pep-0008/#constants" rel="nofollow">PEP 8 style guide</a> so it is clearly a constant to anyone reading your c...
1
2016-07-05T05:35:25Z
[ "python", "pygame", "python-3.4" ]
Jupyter Shortcut not working
38,195,536
<p>I am working my code on Jupyter(Python). Normally, the shortcut to insert cell below is 'b' and for above is 'a', but when I do that search bar opens instead of insertion of cell.<a href="http://i.stack.imgur.com/HlUJt.png" rel="nofollow"><img src="http://i.stack.imgur.com/HlUJt.png" alt="Jupyter shortcut problem"><...
0
2016-07-05T05:08:23Z
38,195,812
<p>Your issue is probably because of your browser settings. <code>b</code> must be set to something else or you are not on <em>command mode</em>.</p> <p><strong>Jupyter shortcuts:</strong></p> <blockquote> <p><strong>Command Mode (press Esc to enable)</strong></p> <p>Enter : enter edit mode</p> <p>Shift-E...
0
2016-07-05T05:33:54Z
[ "python", "jupyter", "jupyter-notebook" ]
Python plot fix size
38,195,557
<p>thanks for reading my question !</p> <p>I created plot using Pyplot, this is my data : </p> <p><a href="http://i.stack.imgur.com/Jc1ch.png" rel="nofollow"><img src="http://i.stack.imgur.com/Jc1ch.png" alt="enter image description here"></a></p> <p>Length of "point" array is : 114745</p> <p>Length of "id_item" ar...
-1
2016-07-05T05:10:06Z
38,197,385
<p>There are two ways to fix your plot:</p> <ol> <li>Make the plot so large that you have to scroll down pages to see every session ID. </li> <li>Reduce your data / don't display everything.</li> </ol> <p>Personally, I'd take option 2. At a certain point it becomes impossible or just really ugly to display a certain...
1
2016-07-05T07:15:38Z
[ "python", "matplotlib" ]
Connect to Database on Server using Python without putting Database password
38,195,637
<p>I have a situation as Follows.. I am writing a python program.which asks users to enter username and password to begin with.Now I grab user name and password from database stored Online on web server Hoisted by GoDady and compare it with user entered Credentials .</p> <p>Approach I used to do so is as follows:</p...
-1
2016-07-05T05:18:02Z
38,196,350
<p>You can use environment variables for this case.</p> <p>You have to first <code>export</code> your variable and then access in the same script as:</p> <pre><code>import os password = os.environ['Your-password-variable'] </code></pre> <p>This might help: <a href="https://godjango.com/blog/working-with-environment-...
0
2016-07-05T06:14:19Z
[ "php", "python", "mysql", "database", "api" ]
Convert API Request Response to List python
38,195,686
<p>I wrote a python API request call, the script looks like this: </p> <pre><code>import requests from requests_oauthlib import OAuth1 import json def PULL(): url = "someURL" ConsumerKey = "someKey" ConsumerSecret = "someSecret" Token = "someToken" TokenSecret = "someToken" ...
0
2016-07-05T05:23:12Z
38,195,749
<p>When you are after not having the curly braces and the <code>u'...'</code>unicode string literals on output, than simply do not <code>print data</code> but instead:</p> <pre><code>for key, value in data: print '%s: %s' % (key, value) </code></pre> <p>That should give:</p> <pre><code>watermarked: 0 orientation...
0
2016-07-05T05:27:58Z
[ "python", "json", "api" ]
Poor performance of RandomForestClassifier
38,195,766
<p>I wrote the following Python code for running the RandomForestClassifier on the Forest CoverType dataset from the UCI ML repo (using default parameter settings). The results are very poor, however, with an accuracy around 60%, while this technique should be able to reach over 90% (with e.g. Weka). I already tried ...
2
2016-07-05T05:29:06Z
38,200,081
<p>You can try the following to improve your score:-</p> <ol> <li><p>Train your model on all the attributes available to you. It will over train but it will give you an idea how much accuracy you can reach on training set.</p></li> <li><p>Next drop the least important features by using clf.feature_importances_</p></li...
0
2016-07-05T09:40:43Z
[ "python", "scikit-learn", "weka", "random-forest" ]
Poor performance of RandomForestClassifier
38,195,766
<p>I wrote the following Python code for running the RandomForestClassifier on the Forest CoverType dataset from the UCI ML repo (using default parameter settings). The results are very poor, however, with an accuracy around 60%, while this technique should be able to reach over 90% (with e.g. Weka). I already tried ...
2
2016-07-05T05:29:06Z
38,200,613
<p>Did you get 90% with the same dataset and the same estimator? Because the data-set is splitted among </p> <blockquote> <p>first 11,340 records used for training data subset</p> <p>next 3,780 records used for validation data subset</p> <p>last 565,892 records used for testing data subset</p> </blockquote...
0
2016-07-05T10:05:44Z
[ "python", "scikit-learn", "weka", "random-forest" ]
Poor performance of RandomForestClassifier
38,195,766
<p>I wrote the following Python code for running the RandomForestClassifier on the Forest CoverType dataset from the UCI ML repo (using default parameter settings). The results are very poor, however, with an accuracy around 60%, while this technique should be able to reach over 90% (with e.g. Weka). I already tried ...
2
2016-07-05T05:29:06Z
38,225,635
<p>I managed to get a good improvement on your model by using <code>GridSearchCV</code> </p> <pre><code>from sklearn.datasets import fetch_covtype from sklearn.ensemble import RandomForestClassifier from sklearn import cross_validation from sklearn import grid_search import numpy as np covtype = fetch_covtype() clf ...
1
2016-07-06T13:46:21Z
[ "python", "scikit-learn", "weka", "random-forest" ]
formal definition of tensor in theano
38,195,904
<p>I am trying to make char-rnn which predicts the next character regarding previous characters with Theano.</p> <p>So, there exists 4 notable tensors(or matrices).</p> <blockquote> <p>x: inputs shaped [timelength, inputsize]</p> <p>h: hidden states shaped [timelength, hiddensize]</p> <p>y: outputs shaped...
1
2016-07-05T05:41:54Z
38,197,258
<p>The original sequence is a vector of integers, coding characters. This is transformed into a one-hot encoding, giving inputs. The one-hot encoding of a character with index 5 is a vector where the 5th element is 1 and the rest are zeros. It looks like you're setting up targets to also use a one-hot encoding. This ca...
0
2016-07-05T07:09:05Z
[ "python", "machine-learning", "neural-network", "theano", "recurrent-neural-network" ]
Google App Engine - Error when running dev_appserver.py - No module named appengine.api
38,195,967
<p>After trying to get Google App Engine working locally, I think it's best to ask this question here, and answer it myself. I'm sure some of you might be having this problem. </p> <p>After installing the GAE SDK for Python, I tried running the tutorial. I cloned their 'Hello World' app from GitHub, and tried to run i...
0
2016-07-05T05:46:51Z
38,196,084
<p>What happened to me was there were a few libraries developed by Google already added to my PYTHONPATH. So when dev_appserver.py was trying execute the following line,</p> <pre><code>from google.appengine.api import appinfo </code></pre> <p>it was throwing an error saying "ImportError: No module named appengine.api...
1
2016-07-05T05:56:12Z
[ "python", "python-2.7", "google-app-engine" ]
Google App Engine - Error when running dev_appserver.py - No module named appengine.api
38,195,967
<p>After trying to get Google App Engine working locally, I think it's best to ask this question here, and answer it myself. I'm sure some of you might be having this problem. </p> <p>After installing the GAE SDK for Python, I tried running the tutorial. I cloned their 'Hello World' app from GitHub, and tried to run i...
0
2016-07-05T05:46:51Z
38,203,313
<p>Update: the issue was fixed in SDK version 1.9.40.</p> <p>This is likely caused by <a href="https://code.google.com/p/googleappengine/issues/detail?id=12963" rel="nofollow">GAE Issue 12963</a>, which still affects the current (1.9.38) SDK version. See <a href="http://stackoverflow.com/questions/37755195/importerror...
0
2016-07-05T12:20:27Z
[ "python", "python-2.7", "google-app-engine" ]
How can I integrate a wordpress front-end on top of my existing Django web application
38,195,982
<p>I have built a new website using wordpress which looks great and has required blogging functionality. </p> <p>Our old site was built using Django and looked awful but had required backend functionality built into it thanks to Django. For example on one page it has a drop down box and you select options from it and ...
2
2016-07-05T05:47:55Z
38,196,067
<p>Have you tried, <a href="https://github.com/agiliq/django-wordpress" rel="nofollow">https://github.com/agiliq/django-wordpress</a> ?</p> <p>I haven't used it yet. </p>
0
2016-07-05T05:54:34Z
[ "php", "python", "django", "wordpress" ]
How can I integrate a wordpress front-end on top of my existing Django web application
38,195,982
<p>I have built a new website using wordpress which looks great and has required blogging functionality. </p> <p>Our old site was built using Django and looked awful but had required backend functionality built into it thanks to Django. For example on one page it has a drop down box and you select options from it and ...
2
2016-07-05T05:47:55Z
38,211,676
<p>I will share my experience in creating a hybrid solution and although for me it was two different PHP frameworks the approach could be the same. It's not a ready-to-go solution, but maybe it will help. I will list key points. </p> <ol> <li>To have both Wordpress and django on the same url you have to install them o...
1
2016-07-05T19:56:02Z
[ "php", "python", "django", "wordpress" ]
git.exc.GitCommandNotFound: [WinError 5] Access is denied
38,196,318
<p>Im learning Python.</p> <p>Getting below exception while trying to clone a repos</p> <pre><code> Traceback (most recent call last): File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 622, in execute **subprocess_kwargs File "C:\Users\Selva...
1
2016-07-05T06:11:44Z
38,196,382
<p>seems like an authority error, be sure to run your script as an administrator</p>
0
2016-07-05T06:17:24Z
[ "python", "git", "ssh" ]
git.exc.GitCommandNotFound: [WinError 5] Access is denied
38,196,318
<p>Im learning Python.</p> <p>Getting below exception while trying to clone a repos</p> <pre><code> Traceback (most recent call last): File "C:\Users\Selvakumar\AppData\Local\Programs\Python\Python36-32\lib\site-packages\git\cmd.py", line 622, in execute **subprocess_kwargs File "C:\Users\Selva...
1
2016-07-05T06:11:44Z
38,197,510
<p>The OP confirms it is a PATH/variable issue</p> <blockquote> <blockquote> <p>Does your PATH references git binary?</p> </blockquote> <p>Yes, that was the mistake I did. I missed to <code>git.exe</code> in <code>GIT_PYTHON_GIT_EXECUTABLE</code> path variable.<br> Given like this as <code>C:\Program Fi...
1
2016-07-05T07:21:55Z
[ "python", "git", "ssh" ]
Import Django settings from external script
38,196,334
<p>I have a python script within my Django project designed to run seperate from the Django app. I want to use the settings.py on my Django App how can I do that. </p> <p>When I try to import </p> <pre><code>from django.conf import settings </code></pre> <p>i get</p> <pre><code>ImportError: No module named DjangoTa...
0
2016-07-05T06:13:06Z
38,196,878
<p>Read <a href="https://docs.djangoproject.com/en/1.9/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage" rel="nofollow">https://docs.djangoproject.com/en/1.9/topics/settings/#calling-django-setup-is-required-for-standalone-django-usage</a></p> <p>So you basically will need to put this at t...
1
2016-07-05T06:47:42Z
[ "python", "django", "tastypie" ]
Import Django settings from external script
38,196,334
<p>I have a python script within my Django project designed to run seperate from the Django app. I want to use the settings.py on my Django App how can I do that. </p> <p>When I try to import </p> <pre><code>from django.conf import settings </code></pre> <p>i get</p> <pre><code>ImportError: No module named DjangoTa...
0
2016-07-05T06:13:06Z
38,206,077
<p>Based on @Sardorbek Imomaliev, you should also make your DjangoTastypie in your PYTHONPATH, you can do this in your script.</p> <pre><code>import os import sys import django from django.conf import settings sys.path.append("path/to/DjangoTastypie") # path to the parent dir of DjangoTastypie os.environ.setdefault(...
1
2016-07-05T14:30:26Z
[ "python", "django", "tastypie" ]
Is it possible to scroll Tkinter Listboxes without a scrollbar?
38,196,401
<p>I would like to create GUI on my RPi so that I can scroll through Listbox like I do in my iPhone, without the use of a scrollbar. In other words, by just touching the listbox and 'flicking' your finger up/down, I would like to be able to scroll.</p> <p>Can this scrolling method be done with TKinter or any GUI for R...
1
2016-07-05T06:18:20Z
38,217,517
<p>Yes it is.</p> <p>Just have a look how the binding of scrollbars work.</p> <p>How can you achieve the desired effect? Bin Mouse-Move events (touch move is nothing else) and use it to connect it to yview / xview depending on what scroll you want to have.</p> <p>(e.g. check the direction your mouse moves inside you...
1
2016-07-06T06:29:01Z
[ "python", "tkinter", "listbox", "raspberry-pi" ]
Why does Python 3 urllib redirect to Yahoo?
38,196,438
<p>I am using urlopen in urllib.request in Python 3.5.1 (64-bit version on Windows 10) to load content from www.wordreference.com for a French project. Somehow, whenever I request anything outside the domain itself, page content is instead loaded from yahoo.com.</p> <p>Here, I print the first 350 characters from <a hr...
1
2016-07-05T06:20:27Z
38,196,657
<p>I tried the following code and it's working. </p> <pre><code>import requests page = requests.get("http://www.wordreference.com/enfr/test") content = page.text print(content.encode('utf-8')[:350]) </code></pre>
-2
2016-07-05T06:34:15Z
[ "python", "python-3.x", "windows-10", "urllib", "urlopen" ]
How to stop a simplehttpserver in python from httprequest handler?
38,196,446
<p>I am new to python and wrote a simple httpserver in python. I am trying to shut down the server from the request to the server. How can I achieve this functionality of calling a function of the server from the handler? </p> <pre><code>class MyHandler(SimpleHTTPRequestHandler): def do_GET(self): if self....
4
2016-07-05T06:21:12Z
38,196,725
<p>In short, do not use <code>server.serve_forver(..)</code>. The request handler has a <code>self.server</code> attribute that you can use to communicate with the main server instance to set some sort of flag that tell the server when to stop.</p> <pre><code>import threading from BaseHTTPServer import BaseHTTPRequest...
2
2016-07-05T06:38:32Z
[ "python", "python-2.7", "http" ]
How to stop a simplehttpserver in python from httprequest handler?
38,196,446
<p>I am new to python and wrote a simple httpserver in python. I am trying to shut down the server from the request to the server. How can I achieve this functionality of calling a function of the server from the handler? </p> <pre><code>class MyHandler(SimpleHTTPRequestHandler): def do_GET(self): if self....
4
2016-07-05T06:21:12Z
38,198,193
<p>The server is normally accessible from the handler through the <code>server</code> attribute. A HTTPServer that was started with <code>server_forerver</code> can be shut down with its... <code>shutdown()</code> method. Unfortunately, even if it is not documented, you cannot call shutdown from the thread that runs th...
1
2016-07-05T08:03:46Z
[ "python", "python-2.7", "http" ]
Python: How to get else statement to run x number of times?
38,196,699
<p>I have a script to telnet router and if it can't ping 8.8.8.8 to reboot router, but I don't want it to reboot the router more than three times in a row. If it fails to ping 8.8.8.8 after three times I want it to keep pinging 8.8.8.8 until it comes back up again and start all over again.</p> <pre><code>import subpro...
1
2016-07-05T06:37:11Z
38,196,953
<p>You are missing indentations, so I hope I got your logic right, anyhow the following should do what you want.</p> <p>In your case there is little sense in using the else statement because that will only put you in a position where you have to create another while loop. Another fix is moving the <code>output = subpr...
0
2016-07-05T06:51:56Z
[ "python", "telnet", "ping", "cisco" ]
Python: How to get else statement to run x number of times?
38,196,699
<p>I have a script to telnet router and if it can't ping 8.8.8.8 to reboot router, but I don't want it to reboot the router more than three times in a row. If it fails to ping 8.8.8.8 after three times I want it to keep pinging 8.8.8.8 until it comes back up again and start all over again.</p> <pre><code>import subpro...
1
2016-07-05T06:37:11Z
38,197,081
<p>you could try doing this:</p> <p>if I understood correctly, what you are trying to do is to make a script the will continuously try to ping 8.8.8.8 and if it fails it will reboot the router (at most 3 times) if the rebooting didn't help the script should ping 8.8.8.8 until it succeed. after that the script will sta...
0
2016-07-05T06:59:35Z
[ "python", "telnet", "ping", "cisco" ]
How to make s3 bucket public in python
38,196,758
<p>I have an already created bucket in amazon s3. I want to make its content publicly available without any authentication. I have tried from documents of boto</p> <blockquote> <p>To set a canned ACL for a bucket, use the set_acl method of the Bucket object. The argument passed to this method must be one of the four...
0
2016-07-05T06:40:32Z
38,212,717
<p>You will need to create a <strong>Bucket Policy</strong>, which defines permissions on the bucket as a whole.</p> <p>See 'Bucket Policy' in: <a href="https://docs.aws.amazon.com/AmazonS3/latest/dev/access-control-overview.html#access-control-resources-manage-permissions-basics" rel="nofollow">Managing Access to S3 ...
0
2016-07-05T21:04:25Z
[ "python", "amazon-s3" ]
Identifying local processes and associated ports with python
38,196,868
<p>Does python or any linux/unix languages have a library which allows it to find ports available on the localhost based on processes name? </p> <p>I would like to identify all associated ports with the service name <code>ssh</code>.</p> <p><code>lsof</code>, <code>netstat</code> <code>ps</code> or <code>grep</code> ...
0
2016-07-05T06:46:59Z
38,197,549
<p>This got me what I needed, thank you. </p> <pre><code>ss -l -p -n | grep ",pid=`pgrep ssh`," | grep ::: | cut -d : -f 4 </code></pre>
0
2016-07-05T07:24:13Z
[ "python", "shell" ]
Error while deploying flask app to Heroku
38,196,952
<p>I'm trying to deploy flask app to Heroku. This app is running fine locally when i run it using <code>heroku local web</code></p> <p>But when I try to deploy it using <code>git push heroku master</code> I get error </p> <pre><code>AttributeError: 'module' object has no attribute 'HTTPSConnection' </code></pre> <p>...
2
2016-07-05T06:51:56Z
38,197,313
<p>This error is being generated by the heroku. It turns out that I was not using right configuration for building app. some how I missed <code>runtime.txt</code> file, which contains the following text.</p> <pre><code>python-2.7.11 </code></pre>
3
2016-07-05T07:11:43Z
[ "python", "heroku", "flask" ]
Send a variable from outside the python console OR stop a script from outside
38,196,981
<p>I wrote a Python script that executes an optimization and runs days to get a solution (due to the costly objective function). In all days work it will be sufficient to just stop the calculation at some point because the solution is good enough for me (but not for the optimization algorithm).</p> <p>The problem is, ...
0
2016-07-05T06:53:53Z
38,197,140
<p>maybe you can use a do-while loop. holding your target in a varible outside the loop and start looping the calculatio while &lt;= your target calculation. </p>
0
2016-07-05T07:02:47Z
[ "python" ]
Send a variable from outside the python console OR stop a script from outside
38,196,981
<p>I wrote a Python script that executes an optimization and runs days to get a solution (due to the costly objective function). In all days work it will be sufficient to just stop the calculation at some point because the solution is good enough for me (but not for the optimization algorithm).</p> <p>The problem is, ...
0
2016-07-05T06:53:53Z
38,197,401
<p>For Windows, I would use <a href="https://docs.python.org/2/library/msvcrt.html" rel="nofollow"><code>msvcrt.getch()</code></a></p> <p>For example, this script will loop until a key is pressed, then, if it is <code>q</code>, prompt for the user to quit: (Note that the <code>if</code> statement uses <a href="https:/...
0
2016-07-05T07:16:33Z
[ "python" ]
Send a variable from outside the python console OR stop a script from outside
38,196,981
<p>I wrote a Python script that executes an optimization and runs days to get a solution (due to the costly objective function). In all days work it will be sufficient to just stop the calculation at some point because the solution is good enough for me (but not for the optimization algorithm).</p> <p>The problem is, ...
0
2016-07-05T06:53:53Z
38,199,130
<p>If you poll your "variable" infrequently (say at most once every 20 seconds) then the overhead of testing for a file is negligible. Something like</p> <pre><code>import os QUITFILE = "/home/myscript/quit_now.txt" # and for convenience, delete any old QUITFILE that may exist at init time ... # days later if os.pa...
0
2016-07-05T08:54:48Z
[ "python" ]
How come empty value is matching with array value in python
38,196,996
<p>I am matching an empty value with an array element which has one value in it and the array does not have any empty values. However, still this script works.</p> <pre><code>import re b = "" links_check_arr = ['Arunsdsdds'] for links_find in links_check_arr: if b in links_find: print links_find ...
3
2016-07-05T06:55:04Z
38,197,075
<p>An empty string is always considered to be part of any string:</p> <pre><code>&gt;&gt;&gt; "" in "abcd" True </code></pre>
3
2016-07-05T06:59:06Z
[ "python", "string", "python-2.x" ]
How come empty value is matching with array value in python
38,196,996
<p>I am matching an empty value with an array element which has one value in it and the array does not have any empty values. However, still this script works.</p> <pre><code>import re b = "" links_check_arr = ['Arunsdsdds'] for links_find in links_check_arr: if b in links_find: print links_find ...
3
2016-07-05T06:55:04Z
38,197,079
<p>The empty string is a substring of <em>every</em> string in Python. This is because the substring of length 0 of any string <code>s[0:0]</code> is equal to the empty string.</p> <p>A proper way to check if a string <code>s</code> is not empty is simply <code>if not s:</code>, as empty strings are "falsey".</p> <p>...
1
2016-07-05T06:59:16Z
[ "python", "string", "python-2.x" ]
How come empty value is matching with array value in python
38,196,996
<p>I am matching an empty value with an array element which has one value in it and the array does not have any empty values. However, still this script works.</p> <pre><code>import re b = "" links_check_arr = ['Arunsdsdds'] for links_find in links_check_arr: if b in links_find: print links_find ...
3
2016-07-05T06:55:04Z
38,197,445
<p>tristan gives a detailed answer in the post <a href="http://stackoverflow.com/questions/27603885/why-python-returns-true-when-checking-if-an-empty-string-is-in-another">Why Python returns True when checking if an empty string is in another?</a>. The important sentence is there: </p> <blockquote> <p>Empty strings ...
0
2016-07-05T07:18:54Z
[ "python", "string", "python-2.x" ]
python testsuite doesn't show output on console
38,197,069
<p>This is my sample code</p> <pre><code>class StreamToLogger(object): def __init__(self, logger, log_level=logging.INFO): self.logger = logger self.log_level = log_level self.linebuf = '' def write(self, buf): for line in buf.rstrip().splitlines(): self.logger.log(...
0
2016-07-05T06:58:48Z
38,198,217
<p>For me it is not really clear, what you would like to do. Writing all the console outputs of the logging module to a file and to the console as well? If so do that:</p> <pre class="lang-py prettyprint-override"><code># Create a logging object logger = logging.getLogger ( 'STDOUT+FILE' ) logger.setLevel ( logging.DE...
0
2016-07-05T08:05:12Z
[ "python", "stdout", "stderr", "python-unittest" ]
python testsuite doesn't show output on console
38,197,069
<p>This is my sample code</p> <pre><code>class StreamToLogger(object): def __init__(self, logger, log_level=logging.INFO): self.logger = logger self.log_level = log_level self.linebuf = '' def write(self, buf): for line in buf.rstrip().splitlines(): self.logger.log(...
0
2016-07-05T06:58:48Z
38,223,949
<p>I did a new analyze of your code. The problem there is </p> <ol> <li>you define two streams for stdout and stderr. TextTextRunner uses only one stream: sys.stderr per default. </li> <li>TextTestRunner uses sys.stderr per default and this ist not your sys.stderr. That seems strange, see later. So your code works as ...
1
2016-07-06T12:25:51Z
[ "python", "stdout", "stderr", "python-unittest" ]
sklearn "numpy.dtype has the wrong size, try recompiling" in both pycharm and terminal
38,197,086
<p>I got "numpy.dtype has the wrong size, try recompiling" in both pycharm and terminal when compiling Sci-kit learning. I've upgraded all packages(numpy, scikit to the latest), nothing works.Python version is 2.7. Please help. Appreciate! </p> <pre><code> checking for nltk Traceback (most recent call last): ...
2
2016-07-05T06:59:43Z
38,199,830
<p>The error "numpy.dtype has the wrong size, try recompiling" means that sklearn was compiled against a numpy more recent than the numpy version sklearn is now trying to import. To fix this, you need to make sure that sklearn is compiled against the version of numpy that it is now importing, or an earlier version. ...
1
2016-07-05T09:29:48Z
[ "python", "numpy", "scikit-learn" ]
mesh decimation in python
38,197,212
<p>I have a high resolution triangular mesh with about 2 million triangles. I want to reduce the number of triangles and vertices to about ~10000 each, while preserving its general shape as much as possible. </p> <p>I know this can be done in Matlab using reducepatch. Another alternative is qslim package. Also there i...
1
2016-07-05T07:06:27Z
38,200,316
<p>Here is a minimal python prototype translated from its c++ equivalent vtk example (<a href="http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Decimation" rel="nofollow">http://www.vtk.org/Wiki/VTK/Examples/Cxx/Meshes/Decimation</a>), as <a href="http://stackoverflow.com/users/4299720/mrpedru22">MrPedru22</a> well sugg...
2
2016-07-05T09:52:48Z
[ "python", "vtk", "meshlab" ]
matlab data file to pandas DataFrame
38,197,449
<p>Is there a standard way to convert <em>matlab</em> <code>.mat</code> (matlab formated data) files to Panda <code>DataFrame</code>? </p> <p>I am aware that a workaround is possible by using <code>scipy.io</code> but I am wondering whether there is a straightforward way to do it.</p>
1
2016-07-05T07:19:04Z
38,197,530
<p>I found 2 way: scipy or mat4py.</p> <ol> <li>mat4py</li> </ol> <blockquote> <p>Load data from MAT-file</p> <p>The function loadmat loads all variables stored in the MAT-file into a simple Python data structure, using only Python’s dict and list objects. Numeric and cell arrays are converted to row-ord...
0
2016-07-05T07:23:08Z
[ "python", "database", "matlab", "pandas" ]
matlab data file to pandas DataFrame
38,197,449
<p>Is there a standard way to convert <em>matlab</em> <code>.mat</code> (matlab formated data) files to Panda <code>DataFrame</code>? </p> <p>I am aware that a workaround is possible by using <code>scipy.io</code> but I am wondering whether there is a straightforward way to do it.</p>
1
2016-07-05T07:19:04Z
38,197,546
<p>Ways to do this:<br> As you mentioned scipy</p> <pre><code>import scipy.io as sio test = sio.loadmat('test.mat') </code></pre> <p>Using the <a href="http://uk.mathworks.com/help/matlab/matlab-engine-for-python.html?requestedDomain=www.mathworks.com" rel="nofollow">matlab engine</a>: </p> <pre><code>import matlab....
0
2016-07-05T07:24:02Z
[ "python", "database", "matlab", "pandas" ]
import java package into a jython project in Eclipse or PyCharm
38,197,501
<p>Using Eclipse + PyDev + jython. Need to import a java package to use a Java class inside a Python program (using Max OSX).</p> <p>For import, I mean statement in Python like <code>from com.a.b.c</code>. Wondering where should I put the Java jar file which contains <code>com.a.b.c</code>? Thanks.</p> <p>BTW, if any...
1
2016-07-05T07:21:36Z
38,197,542
<p>Use simple java import. Do not complicate your program.</p>
-1
2016-07-05T07:23:43Z
[ "java", "python", "eclipse", "pycharm", "jython" ]