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
How to create unittests for python prompt toolkit?
38,975,025
<p>I want to create unittests for my command line interface build with the Python <code>prompt-toolkit</code> (<a href="https://github.com/jonathanslenders/python-prompt-toolkit">https://github.com/jonathanslenders/python-prompt-toolkit</a>).</p> <ul> <li><strong>How can I emulate user interaction with the prompt-tool...
9
2016-08-16T12:30:33Z
39,049,257
<p>You could <a href="https://pypi.python.org/pypi/mock">mock</a> the prompt calls.</p> <p><strong>app_file</strong></p> <pre><code>from prompt_toolkit import prompt def word(): result = prompt('type a word') return result </code></pre> <p><strong>test_app_file</strong></p> <pre><code>import unittest from ...
7
2016-08-20T00:13:07Z
[ "python", "python-3.x" ]
Python - Matrix IndexError exception not working
38,975,148
<p>I am trying to write a function which enables a move 1 unit to the left (in the x-axis) in a grid. It should only work if there is a valid coordinate to the left, and if not (i.e. the start point is on the edge of the grid), the function should return <code>None</code>. Here is my attempt:</p> <pre><code>def left_m...
1
2016-08-16T12:37:31Z
38,975,256
<p>Here, you need to place the rest of the code inside the try statement. Otherwise, it will try, fail, and then run the rest of the code. </p> <pre><code>def left_move(point): if point[0]-1 != -1: LEFT = grid[point[1]][point[0]-1] if LEFT == '.': change = [-1,0] for idx, ...
2
2016-08-16T12:42:13Z
[ "python", "matrix", "indexing" ]
Python - Matrix IndexError exception not working
38,975,148
<p>I am trying to write a function which enables a move 1 unit to the left (in the x-axis) in a grid. It should only work if there is a valid coordinate to the left, and if not (i.e. the start point is on the edge of the grid), the function should return <code>None</code>. Here is my attempt:</p> <pre><code>def left_m...
1
2016-08-16T12:37:31Z
38,975,311
<p>This is because Python's interpretation of <code>-1</code> in array indexing is the last element of the array. <code>-1</code> is a legal way of referencing array elements and thus will not trigger an <code>IndexError</code> exception.</p> <pre><code>&gt;&gt;&gt; a = [0,1,2] &gt;&gt;&gt; print a[-1] 2 </code></pre>...
2
2016-08-16T12:45:01Z
[ "python", "matrix", "indexing" ]
Unable to copy using shutil
38,975,164
<p>I am using shutil.copy() to copy file form a location(say a/b/c/d/file.txt) to another location(e/f/g/h). But the problem is the command copies the file to location(i.e e/f/g/h) but the 'file.txt' is empty. I am working on a linux machine which is the slave for my jenkins, so I can't directly access the machine. Ple...
-1
2016-08-16T12:38:15Z
38,975,418
<p>shutil.copy(src, dst, *, follow_symlinks=True) Copies the file src to the file or directory dst. src and dst should be strings. If dst specifies a directory, the file will be copied into dst using the base filename from src. Returns the path to the newly created file.</p> <p>If follow_symlinks is false, and src is ...
0
2016-08-16T12:49:40Z
[ "python", "linux" ]
I am getting error when printing the pixel value of the read image in python-opencv, TypeError: 'NoneType' object has no attribute '__getitem__'
38,975,230
<p>I have freshly installed opencv, and checked that its properly installed by typing: pkg-config --modversion opencv at the command terminal.</p> <p>I started using pything-opencv for reading and displaying an image, but when I run my code, it throws an error: TypeError: 'NoneType' object has no attribute '<strong>g...
0
2016-08-16T12:41:02Z
38,975,278
<p>The returned image is <code>None</code> (you can see it when you print it), which is causing the other error down the line.</p> <p>This is most likely due to specifying the wrong image path ('messi5.jpg'). In the the documentation <a href="http://docs.opencv.org/3.0-beta/doc/py_tutorials/py_gui/py_image_display/py_...
0
2016-08-16T12:43:31Z
[ "python", "opencv", "caffe", "nonetype" ]
provide a mask to pandas dataframe as function argument
38,975,246
<p>I would like to use a mask as a function argument. What works:</p> <pre><code>data = pd.DataFrame([[50, 100, 1], [0, 2, 1]], columns=['a', 'b', 'c']) # the function argument kwargs = {'a': 0, 'b': 2, 'c':1} # generate a list of the elements temp = [] for item in kwargs.items(): temp.append('(data.{}'.format(i...
1
2016-08-16T12:41:49Z
38,978,716
<p>The following should work.</p> <pre><code>data[pd.DataFrame(data[k] == v for k, v in kwargs.items()).all()] </code></pre> <p>Using a generator comprehension, it creates a DataFrame of <code>bool</code>s for whether or not the <code>data</code> value is equivalent to the <code>kwargs</code> value. It calls <code>.a...
1
2016-08-16T15:22:10Z
[ "python", "pandas" ]
python combobox with return variable
38,975,269
<p>I'm trying to Tkinter with a Combox the press of a Button to output a variable, but do not get ahead here.</p> <pre><code>from tkinter import * import tkinter as tk from tkinter import ttk def select(): name_option = var.get() print (Number of choices) root = tk.Tk() var = StringVar(root) c...
0
2016-08-16T12:43:07Z
38,975,717
<p>change </p> <p><code>print (Number of choices)</code></p> <p>to</p> <p><code>print(name_option)</code></p> <p>or just change <code>select()</code> to:</p> <pre><code>def select(): print(var.get()) </code></pre>
0
2016-08-16T13:01:54Z
[ "python", "tkinter", "combobox" ]
python combobox with return variable
38,975,269
<p>I'm trying to Tkinter with a Combox the press of a Button to output a variable, but do not get ahead here.</p> <pre><code>from tkinter import * import tkinter as tk from tkinter import ttk def select(): name_option = var.get() print (Number of choices) root = tk.Tk() var = StringVar(root) c...
0
2016-08-16T12:43:07Z
38,975,990
<p>Change your function body to:</p> <pre><code>def select(): name_option = var.get() num = choices[name_option] print ("Number of choices", num) </code></pre> <p>I just added <code>num = choices[name_option]</code> which returns the value of the item (key) you select. And then print out <code...
0
2016-08-16T13:14:21Z
[ "python", "tkinter", "combobox" ]
How to count the number of calls to a method?
38,975,292
<p>I'm working with the pi2go lite robot. This is my code</p> <pre><code>import pi2go, time import sys import tty import termios import time pi2go.init() def stepCount(): countL += 0 countR += 0 speed = 60 try: pi2go.stepForward(60,16) print stepCount finally: pi2go.cleanup() </code></pre> <p>The qu...
-1
2016-08-16T12:43:57Z
38,975,331
<p>You were very close. <code>stepCount</code> is a function, so you should call it - that is add the parentheses at the end. </p> <pre><code>speed = 60 try: pi2go.stepForward(60,16) stepCount() </code></pre> <p>Also you didn't define <code>countL</code> and <code>countR</code>. So you need to define those befo...
0
2016-08-16T12:46:03Z
[ "python" ]
How to count the number of calls to a method?
38,975,292
<p>I'm working with the pi2go lite robot. This is my code</p> <pre><code>import pi2go, time import sys import tty import termios import time pi2go.init() def stepCount(): countL += 0 countR += 0 speed = 60 try: pi2go.stepForward(60,16) print stepCount finally: pi2go.cleanup() </code></pre> <p>The qu...
-1
2016-08-16T12:43:57Z
38,975,538
<pre><code>counter = dict(ok=0, fail=0, all=0) try: pi2go.stepForward(60,16) counter['ok'] += 1 except: counter['fail'] += 1 finally: counter['all'] += 1 pi2go.cleanup() </code></pre>
0
2016-08-16T12:54:07Z
[ "python" ]
Can I feed lame a blob and have it convert 'on the fly?'
38,975,299
<p>I have a situation where a <code>wav</code> blob will be posted to my django project and I will have to convert it to an mp3. I have the process down, but it seems a little verbose and I would like to cut it down a bit but IDK how to go about doing it. </p> <pre><code>wav_path = os.path.join(full_path, "%s%s.wav" %...
0
2016-08-16T12:44:14Z
38,975,582
<p>You could replace 'something' with 'cat' in your example.</p> <pre><code>cat infile.wav | lame - --comp 40 outfile.mp3 </code></pre> <p>But in case you already have the blob in python, you could directly pipe it via stdin, instead of going the detour of writing it to a .wav file. See <a href="http://stackoverflow....
1
2016-08-16T12:55:49Z
[ "python", "django", "bash", "lame" ]
2D mask for a specific color
38,975,339
<p>I solved a problem with a loop, but it is both slow and unpythonic. I'm looking for a mask solution. If I were interested in pixels with values for a specific channel, that would be simple: </p> <pre><code>img[img[:,:,0]==64] = [0,0,0] </code></pre> <p>to turn them all black. I want to change a specific color, e.g...
1
2016-08-16T12:46:13Z
38,975,477
<p>OK, I just used <code>numpy.logical_and()</code> and it did the trick! </p>
0
2016-08-16T12:51:36Z
[ "python", "image", "rgb", "scikit-image" ]
2D mask for a specific color
38,975,339
<p>I solved a problem with a loop, but it is both slow and unpythonic. I'm looking for a mask solution. If I were interested in pixels with values for a specific channel, that would be simple: </p> <pre><code>img[img[:,:,0]==64] = [0,0,0] </code></pre> <p>to turn them all black. I want to change a specific color, e.g...
1
2016-08-16T12:46:13Z
39,017,369
<p>You were almost there: </p> <pre><code>np.all(img == [192,0,128], axis=-1) </code></pre> <p>gives what you're looking for. You need to specify an axis to do the dimension reduction, which corresponds to the color channel axis here.</p>
1
2016-08-18T11:44:44Z
[ "python", "image", "rgb", "scikit-image" ]
Limiting the number of processes being run at once by subprocess.Popen
38,975,417
<p>I have a list of computationally intensive files that I'm running using Python's subprocess module. The idea is to use <code>Popen</code> rather than something like <code>check_call</code> to go through the list more quickly. However, when the list is larger than say 4 or 5 elements the computers, the program saps a...
0
2016-08-16T12:49:39Z
38,976,167
<p>Adding to what was suggested by Klaus: Something like that could work:</p> <pre><code>from multiprocessing import Pool import subprocess class Cps: def __init__(self): self.cps_dct = { 'a': { '1': 'file1', '2': 'file2', '3': 'file3', ...
2
2016-08-16T13:23:24Z
[ "python", "subprocess", "popen" ]
How to create contracts on Ethereum block-chain in python?
38,975,431
<p>I want to create contract on Ethereum to store data. I'm beginner on this domain...Do we have a better solution ? </p> <p>In this <a href="http://ethereum.stackexchange.com/questions/7884/how-can-i-store-data-in-ethereum-blockchain?noredirect=1&amp;lq=1">post</a>, someone tell me to download a plugin. This is one w...
2
2016-08-16T12:50:00Z
38,982,630
<blockquote> <p>I don't know where to start ... download Ethereum? Create an account?</p> </blockquote> <ol> <li><p>Install the command line tools. <a href="https://www.ethereum.org/cli" rel="nofollow">ethereum.org/cli</a></p> <p>I would not recommend to start with the <code>pyethapp</code> (Python) or the <code>et...
2
2016-08-16T19:05:02Z
[ "python", "storage", "blockchain", "ethereum" ]
PyMongo cursor - Modify and use value
38,975,441
<p>I am encountering difficulties with my PyMongo script: My documents have a field "used" : "false" or "true". I want to iterate over the documents whose "use" fields are "false" and use their "friends" field (which is an array of _id values) to add their own _id value to the friends field of every person who is also ...
0
2016-08-16T12:50:28Z
39,036,617
<p>For adding <code>Hans</code> to <code>Hugo</code> and <code>Kunigundes</code> friendslist:</p> <pre><code>for friend in cursor_pointing_to_Hans['friends']: friend_list=db.People.find({'person_id':friend})['friends'] friend_list.append(cursor_pointing_to_Hans['person_id']) db.People.update({'person_id':f...
0
2016-08-19T10:22:52Z
[ "python", "mongodb", "cursor", "pymongo" ]
Python remove elements from unknown list with a specific string
38,975,623
<p>There are similar questions to this but not quite what im looking for.</p> <p>Having created a list with all files from a specific path im looking to filter out anything that does not contain a specific sequence in a string.</p> <pre><code>def filter(): someFiles = os.listdir(somePath) listSize = len(someF...
0
2016-08-16T12:57:44Z
38,975,756
<pre><code>for i in range(0, listSize): if (".py" not in someFiles): someFiles.remove(i) </code></pre> <p>Note that you are trying to remove <code>i</code> from the list. <code>i</code> will be an index of an element in the list (<code>0</code>, <code>1</code>, etc) and not an actual element. This will rai...
3
2016-08-16T13:04:03Z
[ "python", "python-3.x" ]
Python remove elements from unknown list with a specific string
38,975,623
<p>There are similar questions to this but not quite what im looking for.</p> <p>Having created a list with all files from a specific path im looking to filter out anything that does not contain a specific sequence in a string.</p> <pre><code>def filter(): someFiles = os.listdir(somePath) listSize = len(someF...
0
2016-08-16T12:57:44Z
38,975,805
<p>First of all, you don't need to use for loop to iterate over a list in Python. Simpler version of what you've done would be</p> <pre><code>list2 = [] for filename in list1: if (".py" in filename): list2.append(filename) </code></pre> <p>but filtering a list (or more generally, an iterator) is so common...
1
2016-08-16T13:06:35Z
[ "python", "python-3.x" ]
test error message in python 3
38,975,640
<p>I have the following test method</p> <pre><code>def test_fingerprintBadFormat(self): """ A C{BadFingerPrintFormat} error is raised when unsupported formats are requested. """ with self.assertRaises(keys.BadFingerPrintFormat) as em: keys.Key(self.rsaObj).fingerprint('sha256-base') sel...
0
2016-08-16T12:58:18Z
38,977,895
<p>The <code>.message</code> attribute was removed from exceptions in Python 3. Use <code>.args[0]</code> instead:</p> <pre><code>self.assertEqual('Unsupported fingerprint format: sha256-base', em.exception.args[0]) </code></pre> <p>or use <code>str(em.exception)</code> to get the same value:</p> <pre><code>self...
2
2016-08-16T14:42:09Z
[ "python", "unit-testing", "python-3.x", "exception" ]
two keys with the same name "$or"
38,975,664
<p>This is a PARSE REST API question. I need to send some json to query the parse server using the Parse REST API. The json needs to contain two keys with the same name "$or". The first key/value is ignored and the second key/value is used by the server. I realise dictionaries can't have two keys with the same name. I'...
0
2016-08-16T12:59:24Z
38,975,949
<p>As shown in the <a href="http://parseplatform.github.io/docs/rest/guide/#query-constraints" rel="nofollow">doc</a>, <code>$or</code> accept an array with one or more conditions to optionally fulfill:</p> <pre><code>import json,httplib,urllib connection = httplib.HTTPSConnection('api.parse.com', 443) params = urllib...
2
2016-08-16T13:12:36Z
[ "python", "json", "parse.com" ]
Can internal dictionary order change?
38,975,722
<pre><code>exampleDict = {'a':1, 'b':2, 'c':3, 'd':4} </code></pre> <p>The above dictionary initially iterated through in this order:</p> <pre><code>b=2 d=4 a=1 c=3 </code></pre> <p>Then, I moved around a ton of files in my code, and now it iterates through in this order:</p> <pre><code>d=4 a=1 c=3 b=2 </code></pre...
4
2016-08-16T13:02:12Z
38,975,783
<p>Yes. If you do change the code between different calls to the dict, the order of iteration will change.</p> <p>From the <a href="https://docs.python.org/2/library/stdtypes.html#dict.items" rel="nofollow">docs</a></p> <blockquote> <p>If items(), keys(), values(), iteritems(), iterkeys(), and itervalues() are call...
-1
2016-08-16T13:05:12Z
[ "python", "dictionary", "hashmap" ]
Can internal dictionary order change?
38,975,722
<pre><code>exampleDict = {'a':1, 'b':2, 'c':3, 'd':4} </code></pre> <p>The above dictionary initially iterated through in this order:</p> <pre><code>b=2 d=4 a=1 c=3 </code></pre> <p>Then, I moved around a ton of files in my code, and now it iterates through in this order:</p> <pre><code>d=4 a=1 c=3 b=2 </code></pre...
4
2016-08-16T13:02:12Z
38,975,844
<p>Dict don't have a fixed order, from <a href="https://docs.python.org/2/library/stdtypes.html#dict.items" rel="nofollow">documentation</a></p> <blockquote> <p>CPython implementation detail: Keys and values are listed in an arbitrary order which is non-random, varies across Python implementations, and depends o...
4
2016-08-16T13:08:05Z
[ "python", "dictionary", "hashmap" ]
Can internal dictionary order change?
38,975,722
<pre><code>exampleDict = {'a':1, 'b':2, 'c':3, 'd':4} </code></pre> <p>The above dictionary initially iterated through in this order:</p> <pre><code>b=2 d=4 a=1 c=3 </code></pre> <p>Then, I moved around a ton of files in my code, and now it iterates through in this order:</p> <pre><code>d=4 a=1 c=3 b=2 </code></pre...
4
2016-08-16T13:02:12Z
38,976,376
<p>Curious about why you want them ordered. Any chance it's just for consistent logging/printing or similar? If so, you can sort the keys alphabetically. See other article: <a href="http://stackoverflow.com/questions/22264956/how-to-sort-dictionary-by-key-in-numerical-order-python">How to sort dictionary by key in nume...
0
2016-08-16T13:33:16Z
[ "python", "dictionary", "hashmap" ]
python shapely: retrieve the x,y,z value of a LinearRing
38,975,740
<p>I`m trying to plot a LinearRing that shows the difference of the crossover of two Polygons:</p> <pre><code>import mpl_toolkits.mplot3d as a3 import matplotlib.pyplot as plt from shapely.geometry import Polygon fig = plt.figure() ax = Axes3D(fig) poly1 = Polygon([(220.0, 780, 500), (840, 780, 500), (840, 180, 500)...
0
2016-08-16T13:03:10Z
39,347,934
<p>With the <code>exterior</code> attribute you are using, you can get the coords:</p> <pre><code>top1 = a3.art3d.Poly3DCollection([dif.exterior.coords],alpha=0.6) </code></pre> <p>Beware, with this code and also with your solution, you are loosing the interior rings of the polygon, if there are any.</p> <p>Notice t...
0
2016-09-06T11:26:46Z
[ "python", "shapely" ]
Pcolorfast image/array rotation
38,975,743
<p>I have the code below:</p> <pre><code>fig, ax = pyplot.subplots() graph = ax.pcolorfast(data, cmap='viridis', vmin = min, vmax = max) pyplot.colorbar(graph) pyplot.show() </code></pre> <p>and it plots what I wanted, however it is sideways. Is there a good way of rotating it -90 or 270 degrees? I have tried <code>a...
0
2016-08-16T13:03:12Z
38,976,203
<p>Is <code>a</code> supposed to be equal to <code>data</code> in your example? Tried your code with a random 2D array, and <code>np.transpose(a)</code> as well as <code>a.T</code> seem to properly rotate the figure, as opposed to what you indicate here ('returns the original plot'). If this is not the case for you, I ...
0
2016-08-16T13:25:06Z
[ "python", "numpy", "matplotlib", "rotation" ]
Extracting element from a bitarray using indexes in a list
38,975,747
<p>I got a list of index of element of a BitArray. I want to extract the elements.</p> <p>If I try on this simple example the classical method</p> <pre><code>from bitstring import BitArray barray = BitArray('0b101111011110101') index = [1,2,3,4] barray[index] </code></pre> <p>I got the error </p> <pre><code>IndexEr...
2
2016-08-16T13:03:25Z
38,975,820
<p>Well you could use <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.take.html" rel="nofollow"><code>np.take</code></a> to extract those as a NumPy boolean array -</p> <pre><code>np.take(barray,index) </code></pre> <p>Sample run -</p> <pre><code>In [156]: barray Out[156]: BitArray('0b101111011110...
0
2016-08-16T13:06:56Z
[ "python", "numpy", "bitarray" ]
Python numpy float16 datatype operations, and float8?
38,975,770
<p>when performing math operations on float16 Numpy numbers, the result is also in float16 type number. My question is how exactly the result is computed? Say Im multiplying/adding two float16 numbers, does python generate the result in float32 and then truncate/round the result to float16? Or does the calculation perf...
3
2016-08-16T13:04:32Z
38,977,958
<p>To the first question: there's no hardware support for <code>float16</code> on a typical processor (at least outside the GPU). NumPy does exactly what you suggest: convert the <code>float16</code> operands to <code>float32</code>, perform the scalar operation on the <code>float32</code> values, then round the <code>...
3
2016-08-16T14:45:27Z
[ "python", "numpy", "floating-point", "precision" ]
Python: Setup.py doesn't copy code to site-packages
38,975,786
<p>I wrote my own python package and when I try to install with:</p> <pre><code>python setup.py install </code></pre> <p>It installs the package and puts an <em>egg</em> file in site-packages folder, but the code stays in the original folder (on my desktop) instead of moving to site-packages too. The setup.py script ...
-1
2016-08-16T13:05:27Z
38,977,571
<p>No need. That egg file is a <a href="https://wiki.python.org/moin/egg" rel="nofollow">single file importable distribution format</a> containing your code. You should be able to import it as is.</p>
0
2016-08-16T14:27:39Z
[ "python", "windows", "python-2.7", "setup.py" ]
Elaborating very large array in Python
38,975,843
<p>I open a TIFF LAB image and return a big numpy array (4928x3264x3 float64) using python with this function:</p> <pre><code>def readTIFFLAB(filename): """Read TIFF LAB and retur a float matrix read 16 bit (2 byte) each time without any multiprocessing about 260 sec""" import numpy as np .... ...
0
2016-08-16T13:08:02Z
38,978,955
<p>Wow, your method is really slow indeed, try <a href="https://github.com/blink1073/tifffile" rel="nofollow">tifffile</a> library, you can find it <a href="http://www.lfd.uci.edu/~gohlke/pythonlibs/#distribute" rel="nofollow">here</a>. That library will open your file very fast, then you just need to make the proper c...
0
2016-08-16T15:32:12Z
[ "python", "arrays", "numpy", "image-processing" ]
Elaborating very large array in Python
38,975,843
<p>I open a TIFF LAB image and return a big numpy array (4928x3264x3 float64) using python with this function:</p> <pre><code>def readTIFFLAB(filename): """Read TIFF LAB and retur a float matrix read 16 bit (2 byte) each time without any multiprocessing about 260 sec""" import numpy as np .... ...
0
2016-08-16T13:08:02Z
38,992,264
<p>After doing what BPL suggest me I modify the result array as follow:</p> <pre><code># divide the color channel L = I[:, :, 0] a = I[:, :, 1] b = I[:, :, 2] # correct interpretation of a/b channel a.dtype = np.int16 b.dtype = np.int16 # scale the result L = L / 65535.0 * 100 a = a / 3276...
0
2016-08-17T09:02:17Z
[ "python", "arrays", "numpy", "image-processing" ]
Reusing a Tkinter window for a game of Tic Tac Toe
38,975,929
<p>I've written a program (listed below) which plays Tic Tic Toe with a Tkinter GUI. If I invoke it like this:</p> <pre><code>root = tk.Tk() root.title("Tic Tac Toe") player1 = QPlayer(mark="X") player2 = QPlayer(mark="O") human_player = HumanPlayer(mark="X") player2.epsilon = 0 # For playing the actual matc...
0
2016-08-16T13:11:56Z
38,977,007
<p>It looks like you only need to create the board one time as the reset method resets it for the new players. Each type you create a Game instance, you create a new Tk frame so you either need to destroy the old one or you can reuse the windows by not creating a new Game instance each time.</p> <p>A minor change to t...
1
2016-08-16T14:01:46Z
[ "python", "tkinter" ]
Healpy coordinate error after interpolation: appearance of bisector
38,975,961
<p>I have a coarse skymap made up of 128 points, of which I would like to make a smooth healpix map (see attached Figure, LHS). Figures referenced in the text:</p> <p><img src="http://i.stack.imgur.com/bv9P0.jpg" alt="here"></p> <p>I load my data, then make new longitude and latitude arrays of the appropriate pixel l...
1
2016-08-16T13:12:57Z
38,981,335
<p>I figured it out -- I had to add pi/2 to my thetas for the interpolation to work, so in the end need to apply the following transformation for the image to render correctly:</p> <pre><code>newnew_lats = pi - new_lats newnew_lons = pi + new_lons </code></pre> <p>There still seems to be a bit of an issue with the in...
1
2016-08-16T17:47:55Z
[ "python", "matplotlib", "maps", "astronomy", "healpy" ]
Healpy coordinate error after interpolation: appearance of bisector
38,975,961
<p>I have a coarse skymap made up of 128 points, of which I would like to make a smooth healpix map (see attached Figure, LHS). Figures referenced in the text:</p> <p><img src="http://i.stack.imgur.com/bv9P0.jpg" alt="here"></p> <p>I load my data, then make new longitude and latitude arrays of the appropriate pixel l...
1
2016-08-16T13:12:57Z
38,983,260
<p>I'm no expert in healpix (actually I've never used it before - I'm a particle physicist), but as far as I can tell it's just a matter of conventions: in a Mollweide projection, healpy places the north pole (positive latitude) at the bottom of the map, for some reason. I'm not sure why it would do that, or whether th...
0
2016-08-16T19:46:40Z
[ "python", "matplotlib", "maps", "astronomy", "healpy" ]
How to apply salt and pepper noise to only specific part of the image using python?
38,975,969
<p>I have a image of size (1200 X 1000) and I am creating multiple patches (using sliding window of 256 X 256 with a stride of 10) out of it. My ultimate goal to supply the patches to the convolutional neural networks. I wish to introduce some salt and pepper noise to the patches generated out of the image. The image i...
0
2016-08-16T13:13:12Z
38,976,197
<p>It's kind of crude, but why don't you apply the noise uniformly on a copy of the original picture, then copy the patches of each object from the original image back on top of that noisy image?</p> <p><strong>EDIT after you rephrased your question</strong></p> <p>Basically, you need to test whether <code>coords</co...
2
2016-08-16T13:24:50Z
[ "python", "opencv", "numpy", "image-processing" ]
python partial with keyword arguments
38,975,975
<p>I have a function that takes 3 keyword parameters. It has default values for x and y and I would like to call the function for different values of z using map. When I run the code below I get the following error:</p> <blockquote> <p>foo() got multiple values for keyword argument 'x'</p> </blockquote> <pre><code>...
0
2016-08-16T13:13:28Z
38,976,079
<p>When trying to call <code>res = map(f1, zz)</code> internally it actually looks like <code>[f1(i) for i in range(10)</code>. As you can see you call <code>f1</code> function with only one positional argument (in this case <code>f1(x=i)</code>). A possible solution would be to do something like this</p> <pre><code>r...
1
2016-08-16T13:18:49Z
[ "python", "partial" ]
python partial with keyword arguments
38,975,975
<p>I have a function that takes 3 keyword parameters. It has default values for x and y and I would like to call the function for different values of z using map. When I run the code below I get the following error:</p> <blockquote> <p>foo() got multiple values for keyword argument 'x'</p> </blockquote> <pre><code>...
0
2016-08-16T13:13:28Z
38,976,247
<p><code>map(f1, zz)</code> tries to call the function <code>f1</code> on every element in <code>zz</code>, but it doesn't know with which arguments to do it. <code>partial</code> redefined <code>foo</code> with <code>x=0</code> but <code>map</code> will try to reassign <code>x</code> because it uses positional argumen...
2
2016-08-16T13:27:23Z
[ "python", "partial" ]
Group by and filter max(date) between two dates in elastic search
38,976,025
<p>Currently we are able to group by customer_id in elastic search.</p> <p>Following is the document structure</p> <pre><code>{ "order_id":"6", "customer_id":"1", "customer_name":"shailendra", "mailing_addres":"shailendra@gmail.com", "actual_order_date":"2000-04-30", "is_veg":"0", "total_a...
1
2016-08-16T13:16:03Z
38,982,827
<p>You can try with the query below. Within each customer bucket, we further filter all document between two dates (here I've taken the month of August 2016) and then we run a <code>stats</code> aggregation on the date field. The <code>min</code> value will be the first order date and the <code>max</code> value will be...
0
2016-08-16T19:17:05Z
[ "python", "elasticsearch" ]
Receive non-standard UDP broadcast python
38,976,068
<p>I am having great difficulty receiving a UDP broadcast in Python. A device connected to PC via ethernet broadcasts messages on a specific address and port. I have tried numerous multicast python examples found online but I can never receive the data. Using wireshark I can see the UDP broadcasts are reaching the PC.<...
0
2016-08-16T13:18:20Z
38,977,311
<p>You are not receiving the broadcast because you are not using the broadcast address. </p> <p>Either use:</p> <pre><code>s.bind(('',4876)) </code></pre> <p>Or the correct broadcast address for your ip.</p>
0
2016-08-16T14:15:41Z
[ "python", "udp", "broadcast", "multicast" ]
Receive non-standard UDP broadcast python
38,976,068
<p>I am having great difficulty receiving a UDP broadcast in Python. A device connected to PC via ethernet broadcasts messages on a specific address and port. I have tried numerous multicast python examples found online but I can never receive the data. Using wireshark I can see the UDP broadcasts are reaching the PC.<...
0
2016-08-16T13:18:20Z
38,979,715
<p>Ok found the answer, rather isolated to this scenario and kicking myself for overlooking it.</p> <p>The device connected via ethernet was waiting to be assigned an IP address!! Wireshark must capture network traffic at a lower level than python.</p> <p>Anyway manually assigned the device an ip address and now it i...
0
2016-08-16T16:10:56Z
[ "python", "udp", "broadcast", "multicast" ]
How to check if website is listed in DMOZ from Python?
38,976,089
<p>I need to check if website is listed in DMOZ using Python script. How can I do it? I'm trying to do it like this:</p> <pre><code>import urllib2 search = "http://www.dmoz.org/search?q=" domain = "example.com" r = urllib2.urlopen(search+domain).read() </code></pre> <p>It returns html code. I don't understand what sh...
-1
2016-08-16T13:19:16Z
38,976,796
<p>If you look inside returned HTML you will see <code>&lt;!---------- SITES RESULTS ----------&gt;</code> comment with <code>&lt;section class="results sites"&gt;</code> section. Inside this section you will find <code>&lt;div class="site-item"&gt;</code>. Several <code>&lt;div&gt;</code> deeper you can see what you a...
1
2016-08-16T13:53:12Z
[ "python", "django" ]
Python - how to get value from a text field in another module
38,976,165
<p>I've written a simple program with a tkinter GUI. The entire code is in one big module and I'd like to split it into two or three modules to separate the logic from the GUI. This is the example code:</p> <h1>main.py:</h1> <pre><code>import gui inst1 = gui.guitest() </code></pre> <h1>gui.py:</h1> <pre><code>impor...
1
2016-08-16T13:23:10Z
38,976,828
<p>Alright, let's start from the beginning, here's a working example of your code:</p> <pre><code>import tkinter class guitest: def __init__(self): win1 = tkinter.Tk() self.field1 = tkinter.Text(win1) self.field1.grid(column=0, row=0) self.but1 = tkinter.Button(win1, text='click'...
1
2016-08-16T13:54:24Z
[ "python", "user-interface", "tkinter", "module" ]
How to retrieve text from a button type webelement
38,976,308
<p>I am trying to retrieve text from a button type webelement using Python scripting in Selenium The HTML code of the button looks like:</p> <pre><code>&lt;button class="list-item ng-binding" ng-click="selectLineFilter(line)" type="button"&gt; &lt;i class="mdi mdi-domain blue" aria-hidden="true"&gt;&lt;/i&gt; 12063497...
1
2016-08-16T13:30:10Z
38,976,887
<p>I think you are using <code>find_elements</code> which returns list of <code>WebElement</code> while <code>.text</code> works on single <code>WebElement</code>, So you should try using <code>find_element</code> as below :-</p> <pre><code>driver.find_element_by_css_selector("button.list-item.ng-binding[type='button'...
1
2016-08-16T13:56:34Z
[ "python", "selenium-webdriver" ]
How to retrieve text from a button type webelement
38,976,308
<p>I am trying to retrieve text from a button type webelement using Python scripting in Selenium The HTML code of the button looks like:</p> <pre><code>&lt;button class="list-item ng-binding" ng-click="selectLineFilter(line)" type="button"&gt; &lt;i class="mdi mdi-domain blue" aria-hidden="true"&gt;&lt;/i&gt; 12063497...
1
2016-08-16T13:30:10Z
38,977,928
<p>use .GetAttribute("innerHTML")</p>
0
2016-08-16T14:43:55Z
[ "python", "selenium-webdriver" ]
How to retrieve text from a button type webelement
38,976,308
<p>I am trying to retrieve text from a button type webelement using Python scripting in Selenium The HTML code of the button looks like:</p> <pre><code>&lt;button class="list-item ng-binding" ng-click="selectLineFilter(line)" type="button"&gt; &lt;i class="mdi mdi-domain blue" aria-hidden="true"&gt;&lt;/i&gt; 12063497...
1
2016-08-16T13:30:10Z
38,988,498
<p>you can use the concept of this Java code :</p> <p>WebDriver driver;</p> <p>String a = driver.findelement(by.xpath("")).getText(); //use css or id attribute </p> <p>System.out.println(a); //this will print the text present on the button.</p>
0
2016-08-17T05:07:48Z
[ "python", "selenium-webdriver" ]
Initializing a very large pandas dataframe
38,976,431
<p>Background: I have a sequence of images. In each image, I map a single pixel to a number. Then I want to create a pandas dataframe where each pixel is in its own column and images are rows. The reason I want to do that is so that I can use things like forward fill.</p> <p>Challenge: I have transformed each image in...
1
2016-08-16T13:35:32Z
38,976,616
<p>Out of curiosity, is there a reason you want to use Pandas for this? Image analysis is typically handled in matrices making NumPy a clear favorite. If I'm not mistaken, both sk-learn and PIL/IMAGE use NumPy arrays to do their analysis and operations.</p> <p>Another option: avoid the in-memory step! Do you need ...
0
2016-08-16T13:44:16Z
[ "python", "pandas", "numpy", "large-data" ]
Get N terms with top TFIDF scores for each documents in Lucene (PyLucene)
38,976,466
<p>I am currently using PyLucene but since there is no documentation for it, I guess a solution in Java for Lucene will also do (but if anyone has one in Python it would be even better).</p> <p>I am working with scientific publications and for now, I retrieve the keywords of those. However, for some documents there ar...
1
2016-08-16T13:37:25Z
38,986,733
<p>If a field is <a href="http://lucene.apache.org/core/4_10_1/core/org/apache/lucene/document/FieldType.html#indexed()" rel="nofollow">indexed</a>, document frequencies can be retrieved with <a href="http://lucene.apache.org/core/4_10_1/core/org/apache/lucene/index/MultiFields.html#getTerms(org.apache.lucene.index.Ind...
1
2016-08-17T01:16:03Z
[ "java", "python", "lucene", "tf-idf" ]
Get N terms with top TFIDF scores for each documents in Lucene (PyLucene)
38,976,466
<p>I am currently using PyLucene but since there is no documentation for it, I guess a solution in Java for Lucene will also do (but if anyone has one in Python it would be even better).</p> <p>I am working with scientific publications and for now, I retrieve the keywords of those. However, for some documents there ar...
1
2016-08-16T13:37:25Z
38,994,211
<p>After digging a bit in the mailing list, I ended up having what I was looking for.</p> <p>Here is the method I came up with :</p> <pre><code>def getTopTFIDFTerms(docID, reader): termVector = reader.getTermVector(docID, "contents"); termsEnumvar = termVector.iterator(None) termsref = BytesRefIterator.ca...
1
2016-08-17T10:34:18Z
[ "java", "python", "lucene", "tf-idf" ]
devpi upload error: no commands supplied to setup.py
38,976,483
<p>When trying to upload to <code>devpi-4.1.0</code>, the same error occurs no matter what options I choose. The workaround is to build package and upload it as a file, but I'm not able to upload any docs.</p> <pre><code>(tstenv) [root@master workspace]# devpi upload --formats sdist detected devpi:upload section in /v...
0
2016-08-16T13:38:02Z
38,977,714
<p><a href="http://doc.devpi.net/latest/quickstart-releaseprocess.html#devpi-upload-uploading-one-or-more-packages" rel="nofollow">According to documentation</a> it's just <code>devpi upload</code>.</p>
1
2016-08-16T14:34:23Z
[ "python", "devpi" ]
Python Error: "global name server_loop() is not defined"
38,976,497
<p>I have been following along the "black hat python" book and when I typed in this particular code I got the error "global name server_loop() is not defined". Here is the statement BEFORE the main() function having the error:</p> <pre><code>if listen: server_loop() </code></pre> <p>and here is the server_loop() ...
0
2016-08-16T13:38:47Z
38,976,707
<p>I hope I understand the question correctly.</p> <p>I can reproduce your case easily:</p> <pre><code>something() def something(): pass </code></pre> <p>I get</p> <pre><code>Traceback (most recent call last): File "&lt;string&gt;", line 420, in run_nodebug File "&lt;module1&gt;", line 1, in &lt;module&gt;...
0
2016-08-16T13:48:40Z
[ "python", "sockets", "hacking" ]
Python Flask Restful API
38,976,532
<p>Part of my Flask code:</p> <pre><code>@app.route('/api/post', methods=['POST']) def post(): body = request.get_json() json_body = json.loads(body) new_id = mongo.db.Projects.insert(json_body) return str(new_id) </code></pre> <p>Script to post a new database entry:</p> <pre><code>payload = { 'Pro...
1
2016-08-16T13:40:14Z
38,976,826
<p>You don't need to <code>loads</code> request message to get dict format. Information stored in <code>body</code> variable is already in dict form. Simply doing the following should remove the error:</p> <pre><code>@app.route('/api/post', methods=['POST']) def post(): body = request.get_json() # json_body =...
4
2016-08-16T13:54:20Z
[ "python", "json", "flask", "flask-restful" ]
Python Flask Restful API
38,976,532
<p>Part of my Flask code:</p> <pre><code>@app.route('/api/post', methods=['POST']) def post(): body = request.get_json() json_body = json.loads(body) new_id = mongo.db.Projects.insert(json_body) return str(new_id) </code></pre> <p>Script to post a new database entry:</p> <pre><code>payload = { 'Pro...
1
2016-08-16T13:40:14Z
38,976,837
<p><a href="http://flask.pocoo.org/docs/0.11/api/#flask.Request.get_json" rel="nofollow">http://flask.pocoo.org/docs/0.11/api/#flask.Request.get_json</a></p> <p><code>get_json</code> is probably returning a dict already, so you don't need to call <code>json.loads(body)</code> (this is what most likely causes the <code...
0
2016-08-16T13:54:48Z
[ "python", "json", "flask", "flask-restful" ]
Is there any way to get the AST (Abstract Syntax Tree) of a block of code in Java rather than of the entire class ?
38,976,558
<p>I tried using Javalang module available in python to get the AST of Java source code , but it requires an entire class to generate the AST . Passing a block of code like an 'if' statement throws an error . Is there any other way of doing it ? PS : I am preferably looking for a python module to do the task. Thanks <...
2
2016-08-16T13:41:08Z
38,991,801
<p>OP is interested in a non-Python answer.</p> <p>Our <a href="http://www.semanticdesigns.com/Products/DMS/DMSToolkit.html" rel="nofollow">DMS Software Reengineering Toolkit</a> with its <a href="http://www.semanticdesigns.com/Products/FrontEnds/JavaFrontEnd.html?" rel="nofollow">Java Front End</a> can accomplish thi...
0
2016-08-17T08:36:14Z
[ "java", "python", "abstract-syntax-tree" ]
Using for loops in sqlalchemy query
38,976,632
<p>So i wanna use a for loop in a query and pull results if a record's field is equal to an object's property (in a list of objects) how do i do that? This is my code:</p> <pre><code>you = session.query(Users).filter_by(id=login_session['userid']).first() friends = session.query(Friends).filter_by(user_id=login_sessi...
0
2016-08-16T13:45:18Z
38,976,702
<blockquote> <p>Why?</p> </blockquote> <p>Because you can't pass a generator object as an argument for <code>filter</code>:</p> <pre><code>session.query(Markers).filter(Markers.owner == f.friend_id for f in friends).all() </code></pre> <p>Use <code>in_</code> with a list instead:</p> <pre><code>session.query(Mark...
2
2016-08-16T13:48:30Z
[ "python", "postgresql", "sqlalchemy" ]
python quits unexpectedly running pyautogui
38,976,711
<p>I'm running Python 2.7.12 installed with homebrew on my Mac OS X 10.11 and trying to use pyautogui. However, it keeps crashing ("Python quit unexpectedly.") when I try to run it as an imported module in another .py file. Like this:</p> <pre><code> # gui.py import pyautogui def myfunction(): pya...
2
2016-08-16T13:48:44Z
39,023,362
<p>I got it! This is because I'm importing pyscreenshot, and there is a conflict between it and pyautogui. Both use pillow and probably have some different reference to it that I'm not knowledgeable enough to tell. But as soon as I removed the pyscreenshot, pyautogui is running normal.</p>
0
2016-08-18T16:35:21Z
[ "python", "osx", "compilation", "pyautogui" ]
how to get proxy ip and port from text file
38,976,741
<p>how to get proxy ip and port from text file </p> <p>Code :</p> <pre><code>import re , urllib , urllib2 , socks , socket proxys = open('IPs.txt', 'r') links = open('URs.txt', 'r') #---- P = proxys.readlines() E = links.readlines() #---- nm = 0 #---- PROXY = P[nm] #---- for links in E : Post = 'id='+ links cj = ...
2
2016-08-16T13:49:55Z
38,976,845
<p>You need to convert <code>PORT</code> to an <code>int</code>:</p> <pre><code>socks.setdefaultproxy(socks.PROXY_TYPE_SOCKS5, IP, int(PORT)) </code></pre> <p>Note that this will raise a <code>ValueError</code> if for some whatever reason <code>PORT</code> can't be converted, so you may want to catch it.</p> <p>Depe...
2
2016-08-16T13:55:09Z
[ "python", "python-2.7", "websocket", "socks" ]
Pandas apply function to groups of columns and indexing
38,976,800
<p>Given a dataframe <code>df</code> consisting of multiple columns:</p> <pre><code>Col1 Col2 Col3 Col4 Col5 Col6 4 2 5 3 4 1 8 3 9 7 4 5 1 3 6 7 4 7 </code></pre> <p>I want to apply a function <code>func</code> for a group ...
2
2016-08-16T13:53:21Z
38,976,883
<p>You need remove first <code>:</code> in <code>iloc</code>, because working with <code>Series</code> in <code>apply</code>, not with <code>DataFrame</code>:</p> <pre><code>print (df.apply(lambda x: func(x.iloc[0:3]), axis=1)) </code></pre> <p>Test:</p> <pre><code>def func(x): return x.sum() print (df.apply(la...
1
2016-08-16T13:56:23Z
[ "python", "pandas", "indexing", "dataframe", "multiple-columns" ]
python/sqlite3: multiple columns with the same name not correctly treated by sqlite3.Row
38,976,811
<p>I am accessing a sqlite database taken from my phone (specifically, from the gnucash app). I want to access the columns by name, so I set conn.row_factory = sqlite3.Row on my connection. Then I join two tables with the following query:</p> <pre><code>&gt;&gt;&gt; rows = curr.execute('select * from splits s left joi...
2
2016-08-16T13:53:55Z
38,980,316
<p>The <a href="http://www.sqlite.org/c3ref/column_name.html" rel="nofollow">documentation</a> says:</p> <blockquote> <p>The name of a result column is the value of the "AS" clause for that column, if there is an AS clause. If there is no AS clause then the name of the column is unspecified.</p> </blockquote> <p>So...
0
2016-08-16T16:44:41Z
[ "python", "sqlite3" ]
In Python, change the attributes of a class instance which is passed as input to __init__
38,977,005
<p>Consider the following code, which generates a (basic) GUI:</p> <pre><code>import Tkinter as tk class Game: def __init__(self, root): self.root = root button = tk.Button(root, text="I am a button") button.pack() root = tk.Tk() root.title("This is a game window") # I would like to m...
4
2016-08-16T14:01:43Z
38,977,181
<p>Sure. You need to call the <code>.title</code> method. Doing </p> <pre><code>root.title = "This is a game window" </code></pre> <p>doesn't set the title, it overwrites the method with the string.</p> <pre><code>import Tkinter as tk class Game: def __init__(self, root): self.root = root root....
6
2016-08-16T14:09:11Z
[ "python", "tkinter" ]
elif statement not running?
38,977,008
<p>The aim is to open the page get url nr 18, swap the url with url in position 18 and rerun 7 times but my code is stuck after getting position 18, why is the elif not running in line 24 ? (no traceback given, program just sitting there)</p> <pre><code>import urllib from BeautifulSoup import * #not the real url url=...
0
2016-08-16T14:01:46Z
38,977,059
<pre><code>if position &lt;= 18: ... elif position == 18: ... </code></pre> <p>Both the <code>if</code> and <code>elif</code> branches are catching <code>position</code> if <code>position == 18</code> (note the <code>&lt;=</code> in the <code>if</code> statement), so the <code>elif</code> branch will never be ...
2
2016-08-16T14:03:46Z
[ "python", "python-2.7" ]
elif statement not running?
38,977,008
<p>The aim is to open the page get url nr 18, swap the url with url in position 18 and rerun 7 times but my code is stuck after getting position 18, why is the elif not running in line 24 ? (no traceback given, program just sitting there)</p> <pre><code>import urllib from BeautifulSoup import * #not the real url url=...
0
2016-08-16T14:01:46Z
38,977,069
<p>Your <code>if</code> <em>excludes</em> the <code>elif</code> condition:</p> <pre><code>if position &lt;= 18: </code></pre> <p>This matches if <code>position == 18</code> <em>too</em>. Python ignores all following <code>elif</code> conditions when a <code>if</code> or <code>elif</code> branch has matched.</p> <p>I...
2
2016-08-16T14:04:02Z
[ "python", "python-2.7" ]
elif statement not running?
38,977,008
<p>The aim is to open the page get url nr 18, swap the url with url in position 18 and rerun 7 times but my code is stuck after getting position 18, why is the elif not running in line 24 ? (no traceback given, program just sitting there)</p> <pre><code>import urllib from BeautifulSoup import * #not the real url url=...
0
2016-08-16T14:01:46Z
38,977,079
<p>Change</p> <pre><code>if position &lt;= 8: </code></pre> <p>by </p> <pre><code>if position &lt; 8: </code></pre> <p>And leave your <code>elif</code> the same.</p> <p>By having the condition <code>&lt;=8</code> your code always enter the if (When <code>position</code> is <code>&lt;=8</code>), but when is 9 (<cod...
2
2016-08-16T14:04:24Z
[ "python", "python-2.7" ]
Split string by the first occurance from a set of delimiters with Python and regex
38,977,041
<p>First of all the question is tagged with <code>Python</code> and <code>regex</code> but it is not really tied to those - an answer can be high level.</p> <p>At the moment I'm splitting a string with multiple delimiters with the following pattern. There are actually more delimiting patterns and they are more complex...
5
2016-08-16T14:03:04Z
38,977,361
<blockquote> <p><em>it is required to split either by a delimiter that occurs first in the string or by a delimiter that is most frequent in the string.</em></p> </blockquote> <p>So you can first find all the delimiters and preserve them in a proper container with their frequency, then find the most common and first...
3
2016-08-16T14:17:50Z
[ "python", "regex", "split" ]
Split string by the first occurance from a set of delimiters with Python and regex
38,977,041
<p>First of all the question is tagged with <code>Python</code> and <code>regex</code> but it is not really tied to those - an answer can be high level.</p> <p>At the moment I'm splitting a string with multiple delimiters with the following pattern. There are actually more delimiting patterns and they are more complex...
5
2016-08-16T14:03:04Z
38,984,902
<p>I've found the string.count() method to be very fast since it's implemented in C. Anything that avoids for loops will generally be faster, even if you iterate the string multiple times. This is probably the fastest solution:</p> <pre><code>&gt;&gt;&gt; s = 'aaa*bbb#ccc*ddd' &gt;&gt;&gt; a, b = s.count('*'), s.count...
0
2016-08-16T21:39:38Z
[ "python", "regex", "split" ]
Find and clicking button with selenium without ID
38,977,169
<p>I'm trying to click on a particular button on a webpage with Selenium in Python. How do I select and click on the button "Replace", with the following HTML?</p> <pre><code>&lt;div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-dialog-buttons ui-draggable ui-resizable no-close" tabindex="-1" ...
2
2016-08-16T14:08:34Z
38,977,261
<p>You should try using <code>xpath</code> as below :-</p> <pre><code>driver.find_element_by_xpath(".//button[contains(.,'Replace')]").click() </code></pre> <p>Or if there is multiple button with same text <code>Replace</code> try as below :-</p> <pre><code>driver.find_element_by_xpath(".//button[child::span[text() ...
1
2016-08-16T14:13:04Z
[ "python", "python-3.x", "selenium" ]
Find and clicking button with selenium without ID
38,977,169
<p>I'm trying to click on a particular button on a webpage with Selenium in Python. How do I select and click on the button "Replace", with the following HTML?</p> <pre><code>&lt;div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-dialog-buttons ui-draggable ui-resizable no-close" tabindex="-1" ...
2
2016-08-16T14:08:34Z
38,977,366
<p>Try xpath:</p> <pre><code>//span[.='Replace'] </code></pre>
1
2016-08-16T14:17:56Z
[ "python", "python-3.x", "selenium" ]
Find and clicking button with selenium without ID
38,977,169
<p>I'm trying to click on a particular button on a webpage with Selenium in Python. How do I select and click on the button "Replace", with the following HTML?</p> <pre><code>&lt;div class="ui-dialog ui-widget ui-widget-content ui-corner-all ui-front ui-dialog-buttons ui-draggable ui-resizable no-close" tabindex="-1" ...
2
2016-08-16T14:08:34Z
38,977,374
<pre><code>def click_link(self, link_name: str): if link_name in self.driver.page_source: elem = self.driver.find_element_by_link_text(link_name) elem.click() </code></pre>
0
2016-08-16T14:18:14Z
[ "python", "python-3.x", "selenium" ]
Pandas - append strings in data frame: ValueError: cannot reindex from a duplicate axis
38,977,184
<p>I have a data.frame looking similar to this (except much longer and with way more colornames):</p> <pre><code>ff = pd.DataFrame({'OldCol':['darkbrown','lightbeige','lightbrown / beige','beige','brown','beige / cognac'], 'NewCol':['nan','nan','nan','nan','nan','nan']}) </code></pre> <p>I want the data.frame to look...
2
2016-08-16T14:09:20Z
38,977,377
<p>There is problem with duplicates in <code>index</code>. You can replace all values of index by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.reset_index.html" rel="nofollow"><code>reset_index</code></a> to <code>Regular Index</code> (<code>0,1,2..len(df)-1</code>). Old values are re...
1
2016-08-16T14:18:25Z
[ "python", "string", "pandas", "indexing", "dataframe" ]
Making python interpret spaces as newline characters
38,977,285
<p>I am not sure about input format that user will enter. There are two possibities:</p> <p>code:</p> <pre><code>n=int(input("enter the no of workers \n")) print("enter the names of workers") NameList=[] for i in range(n): NameList.append(input()) print(NameList) </code></pre> <p>possibility 1:</p> <p>enter the...
-3
2016-08-16T14:14:37Z
38,977,345
<p>If a worker name can't include a space, you can check that and change the behavior accordingly.</p> <p>This will even work if the user combine the 2 options (e.g. entering <code>'a'</code> and then <code>'b c'</code>), although it is not perfect (it is possible to get more than <code>n</code> names, for example if ...
1
2016-08-16T14:17:16Z
[ "python", "python-3.x" ]
Making python interpret spaces as newline characters
38,977,285
<p>I am not sure about input format that user will enter. There are two possibities:</p> <p>code:</p> <pre><code>n=int(input("enter the no of workers \n")) print("enter the names of workers") NameList=[] for i in range(n): NameList.append(input()) print(NameList) </code></pre> <p>possibility 1:</p> <p>enter the...
-3
2016-08-16T14:14:37Z
38,977,553
<p>Instead of the spaces, I would <em>highly</em> recommend the following:</p> <pre><code>for i in range(n): NameList.append(input("What is the name of worker " + i +"?")) </code></pre> <p>If you <em>absolutely</em> need to accept spaces, use DeepSpace's answer.</p>
0
2016-08-16T14:26:44Z
[ "python", "python-3.x" ]
Install numpy from a wheel package on Redhat 6.5
38,977,344
<p>I am trying to install numpy from a wheel package (that I have generated in my virtualenv) on a Redhat 6.5 with python version =2.6.6:</p> <pre><code>pip install numpy-1.11.1-cp26-cp26mu-linux_x86_64.whl </code></pre> <p>I am getting the following error: </p> <pre><code>numpy-1.11.1-cp26-cp26mu-linux_x86_64.whl i...
1
2016-08-16T14:17:14Z
39,014,240
<p>Based on the answer of Simon Visser on question : <a href="http://stackoverflow.com/questions/28107123/cannot-install-numpy-from-wheel-format?rq=1">Cannot install numpy from wheel format</a> the solution is to replace "cp26mu" in the name of the file by none. </p>
0
2016-08-18T09:13:21Z
[ "python", "numpy", "pip" ]
500 internal server Error running cgi python
38,977,390
<p>i run my python file on web browser but i have some error can u help me solve them</p> <pre><code>Internal Server Error </code></pre> <p>The server encountered an internal error or misconfiguration and was unable to complete your request.</p> <p>Please contact the server administrator at webmaster@localhost to in...
-1
2016-08-16T14:18:54Z
38,977,559
<p>you can find your apache logs in this directory <code>/var/log/apache/</code>. Error 500 usually means there is a server error. If you can't find the error in these logs, then try to use verbose logging.</p>
0
2016-08-16T14:27:06Z
[ "python", "apache", "cgi" ]
error in installing google api python client
38,977,457
<p>I'm installing google api python client on python 3 using pip from <a href="https://github.com/google/gdata-python-client" rel="nofollow">the GitHub repository</a>.</p> <p>But getting the following error:</p> <blockquote> <p>Microsoft Visual C++ 10.0 is required. Get it with "Microsoft Windows SDK 7.1": www.micr...
1
2016-08-16T14:22:04Z
38,977,627
<p>gdata is <a href="https://developers.google.com/gdata/docs/directory" rel="nofollow">deprecated</a> and does not have support for Python 3.x in the first place. Use any of <a href="https://developers.google.com/products" rel="nofollow">these</a> APIs.</p>
1
2016-08-16T14:30:20Z
[ "python", "python-3.x", "gdata", "google-api-python-client" ]
Non-blocking way to determine if thread is finished?
38,977,472
<p>I have the following code:</p> <pre><code>import threading import time class TestWorker (threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): print "Starting " + self.name tim...
2
2016-08-16T14:22:33Z
38,978,075
<pre><code>import threading dt = {} threading.Thread(target=dt.update, kwargs=dict(out=123)).start() while 'out' not in dt: print('out' in dt) print(dt) </code></pre>
0
2016-08-16T14:50:56Z
[ "python", "multithreading" ]
Non-blocking way to determine if thread is finished?
38,977,472
<p>I have the following code:</p> <pre><code>import threading import time class TestWorker (threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): print "Starting " + self.name tim...
2
2016-08-16T14:22:33Z
38,978,438
<p>You can give your thread instance an optional callback function to call when it's finished.<br> Note I added a <code>Lock</code> to prevent concurrent printing (which does block).</p> <pre><code>import threading import time print_lock = threading.Lock() # prevent threads from printing at same time class TestWork...
1
2016-08-16T15:07:22Z
[ "python", "multithreading" ]
Non-blocking way to determine if thread is finished?
38,977,472
<p>I have the following code:</p> <pre><code>import threading import time class TestWorker (threading.Thread): def __init__(self, threadID, name): threading.Thread.__init__(self) self.threadID = threadID self.name = name def run(self): print "Starting " + self.name tim...
2
2016-08-16T14:22:33Z
38,980,087
<pre><code>import queue import threading class SThread(threading.Thread, queue.Queue): def __init__(self, queue_out: object): threading.Thread.__init__(self) queue.Queue.__init__(self) self.queue_out = queue_out self.setDaemon(True) self.start() def run(self): p...
1
2016-08-16T16:32:32Z
[ "python", "multithreading" ]
How to use idlelib.PyShell to embed an interpreter in a tkinter program?
38,977,525
<p>I need to embed an interative python interpreter into my tkinter program. Could anyone help me out as to how to integrate it?</p> <p>I have already looked at the <code>main()</code> function, but it's way to complex for my needs, but I can't seem to reduce it without breaking it.</p>
2
2016-08-16T14:25:05Z
38,984,338
<p>Some details of what you must do may depend on what you want to do with IDLE's Shell once you have it running. I would like to know more about that. But let us start simple and make the minimum changes to pyshell.main needed to make it run with other code. </p> <p>Note that in 3.6, which I use below, <code>PyShe...
1
2016-08-16T20:56:12Z
[ "python", "shell", "python-3.x", "tkinter", "python-idle" ]
Replacing multiple words in a string from different data sets in Python
38,977,756
<p>Essentially I have a python script that loads in a number of files, each file contains a list and these are used to generate strings. For example: "Just been to see $film% in $location%, I'd highly recommend it!" I need to replace the $film% and $location% placeholders with a random element of the array of their res...
1
2016-08-16T14:36:03Z
38,978,076
<p>A few points about your code:</p> <ul> <li>You can replace the randrange with <a href="https://docs.python.org/2/library/random.html#random.choice" rel="nofollow">random.choice</a> as you just want to select an item from an array.</li> <li>You can iterate over your types and do the replacement without specifying a ...
0
2016-08-16T14:50:57Z
[ "python", "string", "random" ]
Replacing multiple words in a string from different data sets in Python
38,977,756
<p>Essentially I have a python script that loads in a number of files, each file contains a list and these are used to generate strings. For example: "Just been to see $film% in $location%, I'd highly recommend it!" I need to replace the $film% and $location% placeholders with a random element of the array of their res...
1
2016-08-16T14:36:03Z
38,978,454
<p>The <code>varType</code> you are assigning will be set in only one of your <code>if-elif-else</code> sequence and then the interpreter will go outside. You would have to run all over it and perform operations. One way would be to set flags which part of sentence you want to change. It would go that way:</p> <pre><c...
0
2016-08-16T15:08:04Z
[ "python", "string", "random" ]
Replacing multiple words in a string from different data sets in Python
38,977,756
<p>Essentially I have a python script that loads in a number of files, each file contains a list and these are used to generate strings. For example: "Just been to see $film% in $location%, I'd highly recommend it!" I need to replace the $film% and $location% placeholders with a random element of the array of their res...
1
2016-08-16T14:36:03Z
38,979,403
<p>The following program may be somewhat closer to what you are trying to accomplish. Please note that documentation has been included to help explain what is going on. The templates are a little different than yours but provide customization options.</p> <pre><code>#! /usr/bin/env python3 import random PATH_TEMPLAT...
0
2016-08-16T15:54:46Z
[ "python", "string", "random" ]
How to find all unused and first missing number in an array (in Python)?
38,977,776
<p>I'm new to python and I need help in trying to find all unused and the first unused/missing number in an array (in python 2.7.3)? </p> <p>The array is of length 20 and is used by an application. When the application is launched, the array is empty, but as users begin to populate it, I need to find all unused number...
1
2016-08-16T14:36:43Z
38,977,942
<p>I think this listcomprehension should do the trick for you</p> <pre><code>missingNumbers = [ i for i in range(20) if i not in myarray ] </code></pre> <p>to get the first number you only need to take the first element </p> <pre><code>firstMissingNoInMyArray = missingNumbers[0] </code></pre>
1
2016-08-16T14:44:30Z
[ "python", "arrays", "dynamic" ]
How to find all unused and first missing number in an array (in Python)?
38,977,776
<p>I'm new to python and I need help in trying to find all unused and the first unused/missing number in an array (in python 2.7.3)? </p> <p>The array is of length 20 and is used by an application. When the application is launched, the array is empty, but as users begin to populate it, I need to find all unused number...
1
2016-08-16T14:36:43Z
38,977,964
<p>You could use <a href="https://docs.python.org/2/library/sets.html" rel="nofollow"><code>set</code></a> operations.</p> <pre><code>limit = 20 myarray = [1, 5, 15] # Example missingNumbers = list(set(range(1, limit + 1)) - set(myarray)) print 'Missing numbers -&gt;', missingNumbers print 'First missing number -&gt...
2
2016-08-16T14:45:57Z
[ "python", "arrays", "dynamic" ]
How to find all unused and first missing number in an array (in Python)?
38,977,776
<p>I'm new to python and I need help in trying to find all unused and the first unused/missing number in an array (in python 2.7.3)? </p> <p>The array is of length 20 and is used by an application. When the application is launched, the array is empty, but as users begin to populate it, I need to find all unused number...
1
2016-08-16T14:36:43Z
38,977,967
<p>You can use <code>set</code>s then you can simply subtract the sets. In order to see the first missing number you can take the <code>min</code> in the resulting set:</p> <pre><code>all_nums = set(xrange(1, 21)) arr = set(xrange(5, 10)) print all_nums - arr print min(all_nums - arr) # note that sets are unordere...
1
2016-08-16T14:46:01Z
[ "python", "arrays", "dynamic" ]
How to find all unused and first missing number in an array (in Python)?
38,977,776
<p>I'm new to python and I need help in trying to find all unused and the first unused/missing number in an array (in python 2.7.3)? </p> <p>The array is of length 20 and is used by an application. When the application is launched, the array is empty, but as users begin to populate it, I need to find all unused number...
1
2016-08-16T14:36:43Z
38,978,260
<p>If you know the upper limit of the range, then remove element, that came from user, from pre-populated list and return the first element. Like below:</p> <pre><code>prepop_list = [ i for i in xrange( 1, 20+1 ) ] def new_user( item ): if item in prepop_list: prepop_list.remove( item ) else: ...
0
2016-08-16T14:58:49Z
[ "python", "arrays", "dynamic" ]
write a reverse proxy in node js to call the api in django
38,977,853
<p>My frontend code is running in angular at node httpserver port 127.0.0.1:8081 My backend services runnning in python django framework at port 127.0.0.1:9000 While calling my backend servies from angular http methods throws cors exception so i wrote a proxy controller in my node js</p> <pre><code>var http = require(...
1
2016-08-16T14:40:15Z
38,978,177
<p>Enable <code>CORS</code> in Django</p> <p>Uses this third-party lib <a href="https://github.com/ottoyiu/django-cors-headers/" rel="nofollow">django-cors</a> to do it.</p> <p>You are getting CORS because you are making the call from your AngularJS app and its host is <code>127.0.0.1:8081</code>, different from your...
0
2016-08-16T14:55:16Z
[ "python", "angularjs", "node.js", "django", "reverse-proxy" ]
write a reverse proxy in node js to call the api in django
38,977,853
<p>My frontend code is running in angular at node httpserver port 127.0.0.1:8081 My backend services runnning in python django framework at port 127.0.0.1:9000 While calling my backend servies from angular http methods throws cors exception so i wrote a proxy controller in my node js</p> <pre><code>var http = require(...
1
2016-08-16T14:40:15Z
38,991,895
<p>The error said CORS is supported only for specific protocals like http:// etc. So you have to add http to that url. When you say, 127.0.0.1, the browser is unable to understand which protocol to use to access that url, should it be using http:// or data:// or chrome:// etc. So you've to explicitly say http:// </p> ...
0
2016-08-17T08:41:58Z
[ "python", "angularjs", "node.js", "django", "reverse-proxy" ]
TTK, Buttons only have one number on them
38,977,891
<pre><code>import tkinter from tkinter import ttk def main(): root = tkinter.Tk() numpad = NumPad(root) root.mainloop() numbers = [ '7', '8', '9', '4', '5', '6', '1', '2', '3'] class NumPad(ttk.Frame): def __init__(self, root): ttk.Frame.__init__(self, root) self.grid() ...
2
2016-08-16T14:42:00Z
38,978,138
<p>For each spot on your grid, you are creating 9 buttons and putting one on top of the other. Only the last button (the one corresponding to 3) ends up showing up and it shows up every time. Instead, you need to figure out the index based on <code>c</code> and <code>r</code> and only create 1 button:</p> <pre><code...
3
2016-08-16T14:53:36Z
[ "python", "python-3.x", "tkinter", "ttk" ]
TTK, Buttons only have one number on them
38,977,891
<pre><code>import tkinter from tkinter import ttk def main(): root = tkinter.Tk() numpad = NumPad(root) root.mainloop() numbers = [ '7', '8', '9', '4', '5', '6', '1', '2', '3'] class NumPad(ttk.Frame): def __init__(self, root): ttk.Frame.__init__(self, root) self.grid() ...
2
2016-08-16T14:42:00Z
38,978,343
<p>You are overriding <code>self.b</code> in the last inner loop. Try this:</p> <pre><code>import tkinter from tkinter import ttk def main(): root = tkinter.Tk() numpad = NumPad(root) root.mainloop() numbers = [ '7', '8', '9', '4', '5', '6', '1', '2', '3'] class NumPad(ttk.Frame): def __init_...
1
2016-08-16T15:02:31Z
[ "python", "python-3.x", "tkinter", "ttk" ]
TTK, Buttons only have one number on them
38,977,891
<pre><code>import tkinter from tkinter import ttk def main(): root = tkinter.Tk() numpad = NumPad(root) root.mainloop() numbers = [ '7', '8', '9', '4', '5', '6', '1', '2', '3'] class NumPad(ttk.Frame): def __init__(self, root): ttk.Frame.__init__(self, root) self.grid() ...
2
2016-08-16T14:42:00Z
38,978,685
<p>Pair each row-column coordinate with one item from <code>numbers</code> using <code>zip</code>:</p> <pre><code>def num(self): rc_gen = ((r, c) for r in range(3) for c in range(3)) for (r, c), num in zip(rc_gen, numbers): cmd = lambda num=num: print(num) self.b = ttk.Button(self, text=num, co...
0
2016-08-16T15:20:49Z
[ "python", "python-3.x", "tkinter", "ttk" ]
pyinstaller creating EXE RuntimeError: maximum recursion depth exceeded while calling a Python object
38,977,929
<p>I am running WinPython 3.4.4.3 with pyinstaller 3.2 (obtained via pip install pyinstaller).</p> <p>Now I've got some really simple Qt4 code that I want to convert to EXE and I've run into problem that I cannot solve. </p> <p><strong>The Code:</strong></p> <pre><code>import sys import math from PyQt4 import QtGui,...
1
2016-08-16T14:44:00Z
38,977,984
<p>i'd try to increase recursion depth limit. Insert at the beginning of your file:</p> <pre><code>import sys sys.setrecursionlimit(5000) </code></pre>
0
2016-08-16T14:46:44Z
[ "python", "recursion", "scipy", "exe", "pyinstaller" ]
How to rerun a script?
38,977,994
<p>I have a function named plot(), which displays a graph with data in it. plot() takes it's data from a text file that is being updated every few seconds.</p> <p>I want plot() to close the matplotlib window, and then run it again every t seconds.</p> <p>What I have so far:</p> <pre><code>plot(t): draw plt p...
0
2016-08-16T14:47:09Z
38,978,335
<p>This should work for you. Just make a loop that waits and counts seconds:</p> <pre><code>import time def plot(t): draw plt plt.show() time.sleep(t) plt.close('all') def rinse_repeat(t, total_time): seconds = 0 while(seconds &lt; total_time): time.sleep(t) seconds += t ...
0
2016-08-16T15:02:09Z
[ "python", "matplotlib", "time", "sleep" ]
Python how to programmatically build function calls
38,978,084
<p>Ok I am not even sure the proper terminology to use to describe what I am trying to do. Anyway, I want to know if it is possible to programmatically or dynamically build a function call in python.</p> <p>Let me explain.</p> <p>I have a function inside a class that is defined with optional parameters like so:</p> ...
0
2016-08-16T14:51:21Z
38,978,161
<p>If I understand correctly, I think this is what you're looking for:</p> <pre><code>params = {} if x: params['full_name'] = 'something' if y: params['role'] = 'something else' an_agent.update(r_agent_id, **params) </code></pre> <p><strong>UPDATE</strong></p> <p>There are other options, assuming you contr...
1
2016-08-16T14:54:35Z
[ "python" ]
How to get GETted json data in Flask
38,978,160
<p>I am implementing a REST API in Python using Flask. I have to get parameters to perform a query and return resources. To be aligned with <code>REST</code> principles, I am going to use a <code>GET</code> request for this operation.</p> <p>Given that there can be a lot of parameters, I want to send them through a <c...
0
2016-08-16T14:54:25Z
38,978,254
<p><code>request.get_json()</code> looks for JSON data in the request <em>body</em> (e.g. what a POST request would include). You put the JSON data in the <em>URL query string</em> of a GET request instead.</p> <p>Your <code>curl</code> command sends your JSON un-escaped, and produces an invalid URL, so the server <em...
4
2016-08-16T14:58:16Z
[ "python", "json", "curl", "flask" ]
How to get GETted json data in Flask
38,978,160
<p>I am implementing a REST API in Python using Flask. I have to get parameters to perform a query and return resources. To be aligned with <code>REST</code> principles, I am going to use a <code>GET</code> request for this operation.</p> <p>Given that there can be a lot of parameters, I want to send them through a <c...
0
2016-08-16T14:54:25Z
38,989,657
<p>Martijn answer was right with this</p> <pre><code>$ curl --data-urlencode @conf.json -G http://localhost:8080/resources/ </code></pre> <p>But you do not need to use <code>urllib</code> to get the args with flask. I would instead on my endpoint just use the following.</p> <pre><code>@resources.route('/resources') ...
0
2016-08-17T06:37:22Z
[ "python", "json", "curl", "flask" ]
Does lock file when using flock need to be global
38,978,163
<p>I am setting up cron job for single instance. Does the lock below need to be global? I believe so, in order that it stays in scope until the program finishes. Or at least outside of try/except block. Also, return values should be positive from Python? Seems -2 returns 254 on echo $? in bash. </p> <pre><code>import ...
0
2016-08-16T14:54:36Z
38,984,401
<p><em>Seems -2 returns 254 on echo $? in bash.</em></p> <p>The Bash is interpreting the -2 as 254 probably due to how it handles negative numbers which <em>I believe</em> is by returning 8-bit unsigned integers. </p> <p><strong>Soln:</strong> Use a postive integer number > 0 but &lt; 256. Bash will see a return co...
0
2016-08-16T21:00:59Z
[ "python", "bash", "cron" ]
using bash commands in python on mac: error 127
38,978,174
<p>I am using am using Python 2.7 on MacOS and want to use a bash command within a python script.</p> <pre><code>command = "someProgram --option1 value 1 --option2 value 2" </code></pre> <p>I had to include the path of this program in my bash_profile in order to run it. I tested so far:</p> <pre><code>os.system(comm...
-1
2016-08-16T14:55:08Z
38,978,267
<p>With <code>shell=True</code> the cmd needs to be a string.</p> <p><code>subprocess.check_call(command, shell=True)</code></p> <p>where command is of type <code>str</code></p>
1
2016-08-16T14:59:07Z
[ "python", "bash", "osx" ]
using bash commands in python on mac: error 127
38,978,174
<p>I am using am using Python 2.7 on MacOS and want to use a bash command within a python script.</p> <pre><code>command = "someProgram --option1 value 1 --option2 value 2" </code></pre> <p>I had to include the path of this program in my bash_profile in order to run it. I tested so far:</p> <pre><code>os.system(comm...
-1
2016-08-16T14:55:08Z
38,998,694
<p>Thanks for your help. The final solution is kind of stupid. I started spyder via the anaconda GUI. If I do so the above code does not work.</p> <p>If I run this directly via the console or start spyder via the console everything is fine. It seems that the bash_profile is not loaded when spyder is loaded but require...
0
2016-08-17T13:53:52Z
[ "python", "bash", "osx" ]
Python 2.7 - How do I use an Observer in a Tkinter GUI, where you switch between frames?
38,978,182
<p>I'm currently working on a GUI which is based on the thread <a href="http://stackoverflow.com/questions/32212408/how-to-get-variable-data-from-a-class">How to get variable data from a class</a>. Since there will be a lot of data to handle, I would like to use a Model-Class, which get's its updates via Observer.</p> ...
1
2016-08-16T14:55:19Z
39,120,531
<p>Since I wasn't able to implement an Observer to watch widgets like the ttk.Combobox, I've decided to create a workaround. Here are the steps I took, in order to achieve a MVC architecture from Bryan Oakleys example (link is in the question), which refreshes its model class via the controller class, whenever a user t...
0
2016-08-24T10:18:04Z
[ "python", "model-view-controller", "tkinter", "event-handling", "observer-pattern" ]
Merge a list of dataframes to create one dataframe
38,978,214
<p>I have a list of 18 data frames:</p> <pre><code>dfList = [df1, df2, df3, df4, df5, df6.....df18] </code></pre> <p>All of the data frames have a common id column so it's easy to join them each together with pd.merge 2 at a time. Is there a way to join them all at once so that dfList comes back as a single dataframe...
0
2016-08-16T14:56:39Z
38,978,237
<p>I think you need <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html" rel="nofollow"><code>concat</code></a>, but first set index of each <code>DataFrame</code> by common column:</p> <pre><code>dfs = [df.set_index('id') for df in dfList] print pd.concat(dfs, axis=1) </code></pre> <p>I...
1
2016-08-16T14:57:34Z
[ "python", "python-3.x", "pandas" ]
Should I create a volume for project files when using Docker with git?
38,978,228
<p>I want to Dockerize a project. I have my project files in a git repo. The project is written in python, and requires a virtual environment to be activated and a pip installation of requirements after the git clone from the repo. The container is going to be a development container, so I would need a basic set of sof...
0
2016-08-16T14:57:11Z
38,978,850
<p>The best solution is B except you will not use a volume in production.</p> <p>Docker-compose will also allow you to easily mount your code as a volume but you only need this for dev. </p> <p>In production you will COPY your files into the container.</p>
0
2016-08-16T15:28:07Z
[ "python", "git", "docker", "docker-compose", "devops" ]
How to exec periodically a function in CherryPy
38,978,299
<p>This code generate 3 webpages using CheryPy. It's works but now i need to execute periodically the function "PageWeb" to have last informations from a query. How to use threading in CherryPy:</p> <pre><code>from Widget import showLine from Widget import SocketLivestatus import cherrypy import threading def PageWe...
1
2016-08-16T15:00:35Z
38,983,996
<p>A <a href="https://docs.python.org/2/library/threading.html#timer-objects" rel="nofollow"><code>threading.Timer</code></a> only runs once:</p> <blockquote> <p>This class represents an action that should be run only after a certain amount of time has passed</p> </blockquote> <p>After some experimentation, it appe...
0
2016-08-16T20:34:16Z
[ "python", "cherrypy" ]