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
pandas delete the 0 appears most times
38,095,139
<p>I have a DataFrame like this:</p> <pre><code>a b c d 1 0 0 0 0 1 0 7 5 2 0 4 6 3 0 0 0 0 8 8 0 7 7 7 0 0 0 1 </code></pre> <p>1: fow each row, if the counts of 0 is >90% of the column counts(in this case: mean: 0.9*4 ), then delete the row.</p> <p>2: fow each column...
-1
2016-06-29T09:12:01Z
38,095,381
<p>I guess you want something like:</p> <pre><code>mask_rows = pd.DataFrame.sum(df == 0, axis=1) &gt; 0.9*len(df.columns) mask_cols = pd.DataFrame.sum(df == 0, axis=0) &gt; 0.9*len(df.columns) </code></pre> <p>This creates mask following my interpretation of your question...</p>
1
2016-06-29T09:21:48Z
[ "python", "pandas" ]
pandas delete the 0 appears most times
38,095,139
<p>I have a DataFrame like this:</p> <pre><code>a b c d 1 0 0 0 0 1 0 7 5 2 0 4 6 3 0 0 0 0 8 8 0 7 7 7 0 0 0 1 </code></pre> <p>1: fow each row, if the counts of 0 is >90% of the column counts(in this case: mean: 0.9*4 ), then delete the row.</p> <p>2: fow each column...
-1
2016-06-29T09:12:01Z
38,095,402
<p>First create a mask that reveals the place zeros are:</p> <pre><code>df_temp = (df == 0) </code></pre> <p>Then drop the lines:</p> <pre><code>df.drop(df_temp.mean(axis = 1) &gt; 0.9,inplace = True) </code></pre> <p>And finally the columns:</p> <pre><code>df.drop(df_temp.mean() &gt; 0.9, 1, inplace = True) </cod...
0
2016-06-29T09:22:25Z
[ "python", "pandas" ]
what's the difference between webView.load(QUrl) and QNetworkAccessManager.get(Qurl) in QT?
38,095,150
<p>UPDATE:I use javaScriptConsoleMessage and got a message on there sites:</p> <pre><code>Can't find variable: jQuery </code></pre> <p>I use PyQt on my project。 Today I want to change the web access way from webView.load(QUrl) to QNetworkAccessManager.get(Qurl),because webView.load(QUrl) can't use async.</p> <p>...
3
2016-06-29T09:12:25Z
38,101,861
<p>I suspect the issue is with <code>setContent()</code> not being able to load external resources (like CSS) because you're not using the <code>baseUrl</code> parameter to tell <code>QWebView</code> where to make external requests from. You can also use <a href="http://doc.qt.io/qt-4.8/qwebview.html#setHtml" rel="nof...
1
2016-06-29T13:58:36Z
[ "python", "qt", "pyqt" ]
Finding elements by xpath pattern in Selenium python
38,095,177
<p>I am working with selenium python and lettuce to test django application.<br></p> <p>There are many elements having xpath in the following pattern and i don't know how many of these elements exists in the document.</p> <pre><code>.//*[@id='accordion-note-1'] .//*[@id='accordion-note-2'] .//*[@id='accordion-note-3'...
3
2016-06-29T09:14:03Z
38,095,739
<p>Not sure this will work, but you can try by using the below xpath:</p> <pre><code>.//*[starts-with(@id, 'accordion-note')] </code></pre> <p>here is the link <a href="http://www.zvon.org/xxl/XSLTreference/Output/function_starts-with.html" rel="nofollow">http://www.zvon.org/xxl/XSLTreference/Output/function_starts-w...
5
2016-06-29T09:36:19Z
[ "python", "xpath", "selenium-webdriver" ]
Saving an object with unsaved related objects
38,095,209
<p>Is there a reason why django doesn't provide an ability to automatically save unsaved related objects?</p> <p>From the <a href="https://docs.djangoproject.com/en/1.9/topics/db/examples/one_to_one/" rel="nofollow">docs</a>:</p> <blockquote> <p><strong>Changed in Django 1.8.4:</strong></p> <p>Previously, savi...
2
2016-06-29T09:14:59Z
38,095,403
<p>From a <a href="https://code.djangoproject.com/ticket/10811#comment:5" rel="nofollow">ticket that lead to the change</a></p> <blockquote> <p>I prefer failing early and loudly, by raising an exception when an unsaved object is assigned to a related field.</p> <p>I could listen to an argument for trying to re-...
4
2016-06-29T09:22:25Z
[ "python", "django" ]
Using variables as index on list
38,095,237
<p>I have two lists:</p> <pre><code>List1 = [1, 3, 6, 8, 1, 61, 89, ...] # This is how List1 is declared List2[1][3][6][8][1][61][89][...] # This is how I want to access data from List2 </code></pre> <p><code>List1</code> is a one one-dimensional list with undefined size (can have 1, 2 or infinite items)</p> <p><c...
0
2016-06-29T09:16:27Z
38,096,109
<p><code>len(List2[List1])</code> : You are trying to index a <code>List2</code> using <code>List1</code> while indexing in lists is done using integers.</p> <p>Try: <code>len(List2[List1[0]])</code></p>
0
2016-06-29T09:51:46Z
[ "python", "list", "python-2.7", "python-3.x", "nested-lists" ]
Sort a nested dictionary in Python
38,095,250
<p>I have the following dictionary.</p> <pre><code>var = a = { 'Black': { 'grams': 1906, 'price': 2.05}, 'Blue': { 'grams': 9526, 'price': 22.88}, 'Gold': { 'grams': 194, 'price': 8.24}, 'Magenta': { 'grams': 6035, 'price': 56.69}, 'Maroon': { 'grams': 922, 'price': 18.76}, 'Mint green': { 'grams': 9961, ...
-3
2016-06-29T09:16:52Z
38,095,429
<pre><code>for s in sorted(a.iteritems(), key=lambda (x, y): y['price']): print s </code></pre> <p>Or by OrderedDict</p> <pre><code>from collections import OrderedDict res = OrderedDict(sorted(a.items(), key=lambda x: x[1]['price'], reverse=False)) print res </code></pre> <p>Output:</p> <pre><code>[('Black',...
1
2016-06-29T09:23:10Z
[ "python", "sorting", "dictionary", "hashtable" ]
Sort a nested dictionary in Python
38,095,250
<p>I have the following dictionary.</p> <pre><code>var = a = { 'Black': { 'grams': 1906, 'price': 2.05}, 'Blue': { 'grams': 9526, 'price': 22.88}, 'Gold': { 'grams': 194, 'price': 8.24}, 'Magenta': { 'grams': 6035, 'price': 56.69}, 'Maroon': { 'grams': 922, 'price': 18.76}, 'Mint green': { 'grams': 9961, ...
-3
2016-06-29T09:16:52Z
38,095,566
<pre><code>import collections update=collections.OrderedDict() result = sorted(a, key=lambda x: (a[x]['price'])) for r in result: update[r]=a[r] print(update) </code></pre>
0
2016-06-29T09:28:35Z
[ "python", "sorting", "dictionary", "hashtable" ]
Sort a nested dictionary in Python
38,095,250
<p>I have the following dictionary.</p> <pre><code>var = a = { 'Black': { 'grams': 1906, 'price': 2.05}, 'Blue': { 'grams': 9526, 'price': 22.88}, 'Gold': { 'grams': 194, 'price': 8.24}, 'Magenta': { 'grams': 6035, 'price': 56.69}, 'Maroon': { 'grams': 922, 'price': 18.76}, 'Mint green': { 'grams': 9961, ...
-3
2016-06-29T09:16:52Z
38,096,032
<p>Construct an <code>OrderedDict</code> from a list of ordered item tuples:</p> <pre><code>from collections import OrderedDict ordered = OrderedDict(sorted(a.items(), key=lambda i: i[1]['price'])) </code></pre> <p>(<code>.items()</code> assumes Python 3, in Python 2 <code>iteritems</code> should do the same.)</p>
1
2016-06-29T09:49:02Z
[ "python", "sorting", "dictionary", "hashtable" ]
Sort a nested dictionary in Python
38,095,250
<p>I have the following dictionary.</p> <pre><code>var = a = { 'Black': { 'grams': 1906, 'price': 2.05}, 'Blue': { 'grams': 9526, 'price': 22.88}, 'Gold': { 'grams': 194, 'price': 8.24}, 'Magenta': { 'grams': 6035, 'price': 56.69}, 'Maroon': { 'grams': 922, 'price': 18.76}, 'Mint green': { 'grams': 9961, ...
-3
2016-06-29T09:16:52Z
38,096,487
<p>You can also use <a href="https://docs.python.org/2/library/operator.html?highlight=getitem#operator.getitem" rel="nofollow"><code>getitem</code></a> from the <a href="https://docs.python.org/2/library/operator.html" rel="nofollow"><code>operator</code></a> library:</p> <pre><code>from collections import OrderedDic...
0
2016-06-29T10:07:35Z
[ "python", "sorting", "dictionary", "hashtable" ]
How to predict float vector labels with caffe?
38,095,280
<p>I was wondering if it's possible to predict a 1-by-n feature associated to an input image using caffe. In <a href="http://stackoverflow.com/questions/33140000/how-to-feed-caffe-multi-label-data-in-hdf5-format">this post</a> there is a solution to make caffe predict a binary vector such as [1 0 1 0].</p> <p>Is this ...
0
2016-06-29T09:18:04Z
38,110,325
<p>Yes; I believe that if you simply follow the instructions in the post you referenced, but use float labels in place of the binary ones, that you'll get useful results. Caffe is happy to support you. :-)</p>
0
2016-06-29T21:27:09Z
[ "python", "neural-network", "regression", "deep-learning", "caffe" ]
How to predict float vector labels with caffe?
38,095,280
<p>I was wondering if it's possible to predict a 1-by-n feature associated to an input image using caffe. In <a href="http://stackoverflow.com/questions/33140000/how-to-feed-caffe-multi-label-data-in-hdf5-format">this post</a> there is a solution to make caffe predict a binary vector such as [1 0 1 0].</p> <p>Is this ...
0
2016-06-29T09:18:04Z
38,137,119
<p>You can also think about this <a href="http://stackoverflow.com/a/37291510/6281477">MultiTaskData Layer</a>. It can parse float typed label vector as you mentioned in your question.</p>
1
2016-07-01T04:33:18Z
[ "python", "neural-network", "regression", "deep-learning", "caffe" ]
Python how to show text in a tkinter application on a none-button
38,095,287
<p>I'm extremely new to python and has started a small project to learn stuff. anyways, as it says in the title, how do I show text in a tkinter application without creating buttons? here's the code if you need it</p> <pre><code>import tkinter as tk ulo = 1 hoho = 0 def lul(): global ulo #ulo = ulo + 1 glo...
-1
2016-06-29T09:18:14Z
38,095,444
<p>There are couple options but using <a href="http://effbot.org/tkinterbook/label.htm" rel="nofollow">Label</a>s are the most fitting one since Label's job is showing text/image.</p> <blockquote> <p>The Label widget is a standard Tkinter widget used to display a text or image on the screen. The label can only dis...
2
2016-06-29T09:23:37Z
[ "python", "text", "tkinter" ]
Python how to show text in a tkinter application on a none-button
38,095,287
<p>I'm extremely new to python and has started a small project to learn stuff. anyways, as it says in the title, how do I show text in a tkinter application without creating buttons? here's the code if you need it</p> <pre><code>import tkinter as tk ulo = 1 hoho = 0 def lul(): global ulo #ulo = ulo + 1 glo...
-1
2016-06-29T09:18:14Z
38,183,521
<p>You can use tkinter built-in <code>Label</code> widget to display text :</p> <p>Here's the code:</p> <pre><code>from tkinter import * root=Tk() def showLabel(): myLabel=Label(root,text="Hello World") myLabel.pack() myButton=Button(root,text="Click here",command=showLabel) myButton.pack() root.mainloop() ...
0
2016-07-04T11:22:37Z
[ "python", "text", "tkinter" ]
How to resolve the ValueError proj_w in Tensorflow?
38,095,288
<p>I have created a REST webservice to execute machine translation with some modifications in translate.py. If I run decode function in translate.py alone, on multiple runs I get the right output. But when I try to run the decode function through the webservice that I have created, the first time, I get the translation...
0
2016-06-29T09:18:14Z
38,114,625
<p>With the following modifications, I am able to run the webservice smoothly. I am creating the model and tf.session() only once. Earlier they were created for every hit on the webservice.</p> <pre><code>model = None en_vocab_path =None fr_vocab_path =None sess = None def decode(sentence) global sess if sess...
0
2016-06-30T05:29:24Z
[ "python", "web-services", "tensorflow", "tensorflow-serving" ]
Python - Kivy, Have I Structured this wrong?
38,095,308
<p>At the moment I have one Floatlayout in SHeditorMain, Inside the class SHeditormain i've declared a bunch of widgets (buttons, popups, labels, etc..) and used self.add_widget to add them. </p> <p>Now i want to create a new window that opens up inside/over the FloatLayout and i can't seem to get it to works. All the...
0
2016-06-29T09:18:55Z
38,111,029
<p>Please read <a href="http://stackoverflow.com/a/38057351/5994041">this answer</a> about multiple "windows" and why it may not be desired. I can recommend you to have kivy window maximized and using ModalView as a pseudo-form that can be dragged and has some button that would close it. More control over everything, c...
0
2016-06-29T22:23:13Z
[ "python", "kivy" ]
Python plot of a piecewise defined surface
38,095,362
<p>I am trying to make a 3d plot of a surface that is defined in different ways for different regions. As an example, take f(x,y) that is defined as 1 if x > y and as x^2 if x &lt;= y.</p> <p>I defined f with logical operators, and tried to plot it with the "plot_surface" function, evaluating it in a grid. Unfortunate...
0
2016-06-29T09:21:01Z
38,128,463
<p>Taking from the link posted by Serenity you need to define f using np.piecewise</p> <pre><code>import numpy as np import matplotlib.pyplot as plt from mpl_toolkits.mplot3d import axes3d, Axes3D num_steps = 500 x_arr = np.linspace(0,100, num_steps) y_arr = np.linspace(0,100, num_steps) def zfunc(x, y): return...
0
2016-06-30T16:14:04Z
[ "python", "matplotlib", "plot" ]
Legend with labels besides seafile heatmap
38,095,366
<p>I have the following code:</p> <pre><code>from string import letters import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt sns.set(style="white") # Compute the correlation matrix df = pd.DataFrame(np.random.randint(0,100,size=(100, 4)), columns=list('ABCD')) corr = df.corr()...
0
2016-06-29T09:21:10Z
38,132,535
<p>About your first question, here is what I managed to do:</p> <pre><code>import numpy as np import pandas as pd import seaborn as sns import matplotlib.pyplot as plt import matplotlib.lines as mlines sns.set(style="white") cols = list('ABCD') # Compute the correlation matrix df = pd.DataFrame(np.random.randint(0,1...
1
2016-06-30T20:20:00Z
[ "python", "plot", "legend", "heatmap", "seaborn" ]
Get all functions inside a Python Package for getattr
38,095,407
<p>I have two python files and both at same directory level like this</p> <pre><code>project |&gt; tasks.py |&gt; queue.py </code></pre> <p>I have a function like this in <code>tasks.py</code> file</p> <pre><code>def foo(message): # perform some functions on message data # blah blah </code></pre>...
0
2016-06-29T09:22:36Z
38,097,626
<p>Answer from @jonrsharpe comment. Put following in in the <code>__init__.py</code></p> <blockquote> <p>from .tasks import *</p> </blockquote> <p>to expose all names in <code>tasks.py</code> from the tasks module. Do it for all files you have in <code>tasks</code> package.</p>
0
2016-06-29T10:59:12Z
[ "python", "django", "getattr" ]
Save a pandas dataframe as table in Image or pdf document with nice multi index display
38,095,436
<p>I'm trying to include a data frame with multi-index in a report in pdf. I would like to have a nice table output.</p> <p>I have found these 2 solutions:</p> <p>pandas.df -> HTML -> pdf</p> <pre><code> import pandas as pd from IPython.display import HTML import pdfkit # df generation df = pd.re...
2
2016-06-29T09:23:26Z
38,097,283
<p>Well one way is to use markdown. You can use <code>df.to_html()</code>. This converts the dataframe into a html table. From there you can put the generated html into a markdown file (.md) and use a package to convert markdown to pdf. <a href="https://www.npmjs.com/package/markdown-pdf" rel="nofollow">https://www.npm...
0
2016-06-29T10:43:56Z
[ "python", "pdf", "pandas", "latex", "pdflatex" ]
Save a pandas dataframe as table in Image or pdf document with nice multi index display
38,095,436
<p>I'm trying to include a data frame with multi-index in a report in pdf. I would like to have a nice table output.</p> <p>I have found these 2 solutions:</p> <p>pandas.df -> HTML -> pdf</p> <pre><code> import pandas as pd from IPython.display import HTML import pdfkit # df generation df = pd.re...
2
2016-06-29T09:23:26Z
38,189,048
<p>The solution that work for me: With pandas >= 0.17 I installed pdflatex. I copied latex package such as booktabs.sty, geography.sty and pdflscape.sty</p> <pre><code>import pandas as pd import os import math def save_summary_table_as_pdf(path_to_csv, path_to_output_folder): pwd = os.getcwd() df = pd.read_cs...
0
2016-07-04T16:29:23Z
[ "python", "pdf", "pandas", "latex", "pdflatex" ]
ImportError: libcudart.so.7.5 when I debug TensorFlow programs using VScode with the python extension?
38,095,478
<p>I have installed VSCode with the Python extension on my Ubuntu system. I have also installed TensorFlow 0.9, CUDA 7.5 and cuDNN library correctly.</p> <p>However, when I debug the tensorflow program using VSCode, it will give an error importing tensorflow (import tensorflow) as below:</p> <pre><code>ImportError: l...
1
2016-06-29T09:25:20Z
38,099,143
<p>I have finally solved the problem after searching and reading many web pages. The method is as bellows:</p> <p>First, link the CUDA library using the following command:</p> <pre><code>sudo ldconfig /usr/local/cuda/lib64 </code></pre> <p>Then, I can import tensorflow in VSCode. However, there is still one error, w...
1
2016-06-29T12:11:04Z
[ "python", "tensorflow", "vscode" ]
Is this a bug in Pandas? FloatingPointError on ewm().std()
38,095,546
<p>When I execute the following, I get a FloatingPointError.</p> <pre><code>import traceback import warnings import sys import pandas as pd import numpy as np np.seterr(all='raise') def warn_with_traceback(message, category, filename, lineno, file=None, line=None): traceback.print_stack() log = file if hasattr...
0
2016-06-29T09:27:23Z
38,095,854
<p><code>np.seterr(all='raise')</code> is causing the issue. </p> <p>Check this out: <a href="http://stackoverflow.com/questions/35657516/pandas-floatingpointerror-with-np-seterrall-raise-and-missing-data">pandas: FloatingPointError with np.seterr(all=&#39;raise&#39;) and missing data</a></p> <p>The output of <code>p...
0
2016-06-29T09:41:51Z
[ "python", "numpy", "pandas" ]
Python pandas 'ffill' method not working
38,095,605
<p>In the book 'Python for Data Analysis' there is an example using pandas' Series data structure for reindexing. I copied this simple code into an iPython notebook and run it but it does not change <code>obj3</code>.</p> <pre><code>obj3 = Series(['blue', 'purple', 'yellow'], index=[0, 2, 4]) print(obj3) obj3.reindex(...
1
2016-06-29T09:30:03Z
38,095,642
<p>You need assign <code>obj3 =</code>:</p> <pre><code>obj3 = obj3.reindex(range(6), method='ffill') print(obj3) 0 blue 1 blue 2 purple 3 purple 4 yellow 5 yellow dtype: object </code></pre>
1
2016-06-29T09:31:25Z
[ "python", "pandas" ]
Table does not exist on testing a read-only table (Django)
38,095,656
<p>I have a <code>Django</code> project. There are 2 databases in this project and I've written a <code>Router</code> to make one of them <code>readonly</code>. I've written some unit tests that use this <code>readonly</code> database, but when I run <code>python manage.py test</code> it says</p> <blockquote> <p>Pro...
1
2016-06-29T09:32:13Z
38,097,180
<p>First of all it's inaccurate to say, </p> <blockquote> <p>I've written some unit tests that use this readonly database</p> </blockquote> <p>That is because</p> <blockquote> <p>Tests that require a database (namely, model tests) will not use your “real” (production) database. Separate, blank databases ar...
2
2016-06-29T10:39:39Z
[ "python", "mysql", "django", "django-migrations" ]
how to set default ip as 0.0.0.0 for a django project to debug in visual studio 2015?
38,095,689
<p>I am developing a <code>django rest framework</code> application using visual studio 2015, python 2.7, django 1.9. I have enabled CORS. I can access it from other origin when I run it through command prompt as <code>python manage.py runserver 0.0.0.0:8086</code>. But, in visual studio auto debug, it runs on 127.0.0....
1
2016-06-29T09:33:33Z
38,096,728
<p>First of all <code>0.0.0.0</code> is not an IP. It stands for "all IPv4 addresses on the local machine". When you start the development server as</p> <pre><code>./manage.py runserver 0.0.0.0:8086 </code></pre> <p>It will serve on <code>127.0.0.1</code> and whatever other IP address you have configured for your net...
1
2016-06-29T10:18:49Z
[ "python", "django", "visual-studio-2015", "django-rest-framework", "django-cors-headers" ]
how to set default ip as 0.0.0.0 for a django project to debug in visual studio 2015?
38,095,689
<p>I am developing a <code>django rest framework</code> application using visual studio 2015, python 2.7, django 1.9. I have enabled CORS. I can access it from other origin when I run it through command prompt as <code>python manage.py runserver 0.0.0.0:8086</code>. But, in visual studio auto debug, it runs on 127.0.0....
1
2016-06-29T09:33:33Z
38,126,584
<p>After so many struggle I found one solution, want to share it with you. Hope you will like it. open <code>&lt;your python location&gt;\Lib\site-packages\django\core\management\commands\runserver.py</code> and find one code where it deal with <code>self.addr</code>.<br> <code>if not self.addr: self.addr = '::1' i...
0
2016-06-30T14:47:49Z
[ "python", "django", "visual-studio-2015", "django-rest-framework", "django-cors-headers" ]
Fabric counter to display how many host are done
38,095,721
<p>I'm trying to create a counter to be able to display "host 5/100 done" at the end of my task. I have a counter classe :</p> <pre><code>class ThreadCounter(object): def __init__(self, initval=0): self.val =int(initval) self.lock = threading.Lock() def increment(self): with self.lock: ...
0
2016-06-29T09:35:22Z
38,096,785
<p>You can use a decorator to track the task completion like,</p> <pre><code>total = 100 count = 0 def counter(f): def wrapped(*args, **kwargs): globals()["count"] += 1 ret = f(*args, **kwargs) print "host %(count)s/%(total)s done" % globals() return ret return wrapped @counte...
0
2016-06-29T10:20:51Z
[ "python", "multithreading", "locking", "fabric" ]
Runnning an IDL code with text file output in Python
38,095,926
<p>I have a number of different codes which all take a text file with data as input and write to a different one as output. Three of these codes are written in Python 2.7, but one is written in IDL. My goal is to create one "master" python program which can run all of these codes, by typing "python master.py". However,...
0
2016-06-29T09:44:34Z
38,102,798
<p>So I have worked out a solution that seems to work well for this problem. The issue above was the use of the os.system function to do things it couldn't. My new codde is:</p> <pre><code>import os import subprocess os.system("python python_code1.py") p=subprocess.Popen("idl", stdin=subprocess.PIPE, stdout=subproce...
0
2016-06-29T14:36:58Z
[ "python", "python-2.7", "idl", "idl-programming-language" ]
Runnning an IDL code with text file output in Python
38,095,926
<p>I have a number of different codes which all take a text file with data as input and write to a different one as output. Three of these codes are written in Python 2.7, but one is written in IDL. My goal is to create one "master" python program which can run all of these codes, by typing "python master.py". However,...
0
2016-06-29T09:44:34Z
38,130,169
<p>If you have IDL 8.5 or later, it ships with the IDL-Python bridge built in. Then your code would look something like:</p> <pre><code>from idlpy import * IDL.idlcode() </code></pre> <p>Hope this helps.</p>
1
2016-06-30T17:54:30Z
[ "python", "python-2.7", "idl", "idl-programming-language" ]
How to add two solutions
38,095,971
<p>So this code works, but I want it to print two solutions off a text-file. The problem includes trying to print out two lines in a text file, when keywords are used with <code>if 'word' == something then print</code>, I want to print two lines. Any help would be appreciated. I have tried various different things.</p>...
-1
2016-06-29T09:46:26Z
38,097,020
<p>If the solutions are always fixed, you should move the file opening and reading outside the loop. The match between keywords and solution index can be done with a dictionary.</p> <pre><code>problem = False foo = open("solutions.txt","r") solutions = foo.readlines() Problemlistdict = {'wet':0, 'water':0, 'dropped'...
0
2016-06-29T10:32:16Z
[ "python" ]
How to add two solutions
38,095,971
<p>So this code works, but I want it to print two solutions off a text-file. The problem includes trying to print out two lines in a text file, when keywords are used with <code>if 'word' == something then print</code>, I want to print two lines. Any help would be appreciated. I have tried various different things.</p>...
-1
2016-06-29T09:46:26Z
38,097,327
<p>Add a stop-index to your line-selection:</p> <p><code>solutions[0:1]</code> will return the first two lines of the file, not only the first line.</p> <p>Or for two lines not following immediately each other, do:</p> <p><code>solutions[2] + solutions[7]</code></p> <p>See "<a href="http://effbot.org/zone/python-l...
0
2016-06-29T10:45:42Z
[ "python" ]
How to apply string method on regular expression in Python
38,096,048
<p>I'm having a markdown file wich is a little bit broken: the links and images which are too long have line-breaks in it. I would like to remove line-breaks from them.</p> <p>Example:</p> <p>from:</p> <pre><code>See for example the [installation process for Ubuntu Trusty](https://wiki.diasporafoundation.org/Install...
0
2016-06-29T09:49:44Z
38,096,091
<p>strip would work similar to functionality of trim. As you would need to trim the new lines, use strip('\n'),</p> <pre><code>fin.readline.strip('\n') </code></pre>
0
2016-06-29T09:51:10Z
[ "python", "regex", "markdown" ]
How to apply string method on regular expression in Python
38,096,048
<p>I'm having a markdown file wich is a little bit broken: the links and images which are too long have line-breaks in it. I would like to remove line-breaks from them.</p> <p>Example:</p> <p>from:</p> <pre><code>See for example the [installation process for Ubuntu Trusty](https://wiki.diasporafoundation.org/Install...
0
2016-06-29T09:49:44Z
38,096,898
<p>This will work also:</p> <pre><code>&gt;&gt;&gt; s = """ ... ![https://diasporafoundation.org/assets/pages/about/network- ... distributed-e941dd3e345d022ceae909beccccbacd.png](data/images/network- ... distributed-e941dd3e345d022ceae909beccccbacd.png) ... """ &gt;&gt;&gt; new_s = "".join(s.strip().split('\n')) &...
0
2016-06-29T10:26:26Z
[ "python", "regex", "markdown" ]
How to apply string method on regular expression in Python
38,096,048
<p>I'm having a markdown file wich is a little bit broken: the links and images which are too long have line-breaks in it. I would like to remove line-breaks from them.</p> <p>Example:</p> <p>from:</p> <pre><code>See for example the [installation process for Ubuntu Trusty](https://wiki.diasporafoundation.org/Install...
0
2016-06-29T09:49:44Z
38,103,231
<p>Alright, I finally found what I was searching. With the snippet below, I could capture a string with a regex and then apply the treatment on each of them.</p> <pre><code>def remove_newlines(match): return "".join(match.group().strip().split('\n')) links_pattern = re.compile(r'\[([\w\s*:/\-\.]*)\]\(([^()]+)\)')...
0
2016-06-29T14:55:58Z
[ "python", "regex", "markdown" ]
python - Sort & Unique vs Set
38,096,132
<p>In python 2.7, in order to retrieve the set of unique strings from a redundant list of strings, what is preferred (~10 million strings of length ~20):</p> <p>a) sort the list and delete repeating strings</p> <pre><code>sort(l) unique(l) #some linear time function </code></pre> <p>b) just put them all in a set</p>...
1
2016-06-29T09:52:57Z
38,098,086
<p>I made a simple test to check the running time of both solutions. The first test creates a <code>set</code> and the second test sorts the list (it doesn't remove duplicates for the sake of simplicity).</p> <p>As expected creating a set is much faster than sorting, since its complexity is <code>O(n)</code> while sor...
2
2016-06-29T11:20:37Z
[ "python", "python-2.7", "sorting", "set", "unique" ]
Create a column based on condition pertaining to 2 other columns
38,096,144
<p>I have two columns in a pandas DataFrame (let's call the 'col1' and col2'). Both contain True/False values. </p> <p>I need to create a third column from these two ('col3'), that will have a True value for a record if one or the other of the two columns has a True value in that record.</p> <p>Currently, I'm doing t...
2
2016-06-29T09:53:29Z
38,096,204
<p>You can use <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.logical_or.html" rel="nofollow"><code>np.logical_or</code></a> to do this:</p> <pre><code>In [236]: df = pd.DataFrame({'col1':[True,False,False], 'col2':[False,True,False]}) df Out[236]: col1 col2 0 True False 1 False True 2...
2
2016-06-29T09:55:57Z
[ "python", "pandas", "vector", "dataframe" ]
Decreasing value in dictionary
38,096,190
<p>I am learning python and I have a simple problem with my program. I have two dictionaries with a keys as a string and values connected to them. Lets say that it's a shop with fruits and prices. </p> <pre><code>shopping_list = ["banana", "orange", "apple"] stock = { "banana": 6, "apple": 0, "orange": 32...
0
2016-06-29T09:55:20Z
38,096,268
<p>The problem is that your functions terminates prematurely because of the <code>return</code> call in your <code>if</code> statement. </p> <p>They way your code is, the function will check a single item out of the basket and then exit. What you have and want to do is check <strong>all</strong> items, add their price...
1
2016-06-29T09:58:18Z
[ "python", "dictionary" ]
Decreasing value in dictionary
38,096,190
<p>I am learning python and I have a simple problem with my program. I have two dictionaries with a keys as a string and values connected to them. Lets say that it's a shop with fruits and prices. </p> <pre><code>shopping_list = ["banana", "orange", "apple"] stock = { "banana": 6, "apple": 0, "orange": 32...
0
2016-06-29T09:55:20Z
38,096,272
<p><code>returns</code> ends the function and returns the value back to out of the function. If you return inside of a loop the rest of the loop will not run anymore and you will only take the first item into account.</p>
0
2016-06-29T09:58:31Z
[ "python", "dictionary" ]
Decreasing value in dictionary
38,096,190
<p>I am learning python and I have a simple problem with my program. I have two dictionaries with a keys as a string and values connected to them. Lets say that it's a shop with fruits and prices. </p> <pre><code>shopping_list = ["banana", "orange", "apple"] stock = { "banana": 6, "apple": 0, "orange": 32...
0
2016-06-29T09:55:20Z
38,096,281
<p>There are two things wrong here:</p> <ul> <li>You return <strong>immediately</strong> after testing the first item, ignoring the rest of your items. <code>return</code> exits a function, the moment Python executes it.</li> <li>You decrement your stock in the wrong place, outside of the loop.</li> </ul> <p>Both wil...
1
2016-06-29T09:59:01Z
[ "python", "dictionary" ]
Django Login Require Issues
38,096,251
<p>I am sorry if the question is very obvious but I am still new to Django.</p> <p>I have View:</p> <pre><code>import logging @login_required(login_url='/accounts/login/') def index(request): return render(request, 'post.html', {}) def new(request): return render(request, 'post-add.html',) </code></pre...
-1
2016-06-29T09:57:38Z
38,096,301
<p>You must apply the <code>@login_required</code> decorator to every view you want to require login for:</p> <pre><code>@login_required(login_url='/accounts/login/') def index(request): return render(request, 'post.html', {}) @login_required(login_url='/accounts/login/') def new(request): return render(...
0
2016-06-29T10:00:14Z
[ "python", "django", "django-views", "django-login" ]
Django Login Require Issues
38,096,251
<p>I am sorry if the question is very obvious but I am still new to Django.</p> <p>I have View:</p> <pre><code>import logging @login_required(login_url='/accounts/login/') def index(request): return render(request, 'post.html', {}) def new(request): return render(request, 'post-add.html',) </code></pre...
-1
2016-06-29T09:57:38Z
38,096,336
<p>If you want to redirect when you try to open "post-add" without login, you need another decorator(@login_required(login_url='/accounts/login/') ).</p>
1
2016-06-29T10:01:22Z
[ "python", "django", "django-views", "django-login" ]
Django Login Require Issues
38,096,251
<p>I am sorry if the question is very obvious but I am still new to Django.</p> <p>I have View:</p> <pre><code>import logging @login_required(login_url='/accounts/login/') def index(request): return render(request, 'post.html', {}) def new(request): return render(request, 'post-add.html',) </code></pre...
-1
2016-06-29T09:57:38Z
38,096,626
<p>As others have pointed out you must use the login decorator on every view requiring authentication.</p> <p>You can re-use it by simply wrapping it like this:</p> <pre><code>auth = login_required(login_url='/accounts/login/') @auth def index(request): return render(request, 'post.html', {}) @auth def new(requ...
0
2016-06-29T10:13:34Z
[ "python", "django", "django-views", "django-login" ]
Updating entry widget using text from onscreen keyboard in tkinter
38,096,376
<p>I want to run my code on raspberry pi which has a touchscreen attached to it. The GUI is made using Tkinter and I want to pop up the system onscreen keyboard when the entry is focused. Here is my current code:</p> <p>For binding the entry widget with FocusIn event:</p> <pre><code>self.usernameEntry.bind('&lt;Focus...
2
2016-06-29T10:02:47Z
38,126,364
<p>For someone looking for the answer, I found 2 ways of solving this:</p> <p>First, use subprocess.popen to create seperate threads of UI and the Keyboard. This works fine on onboard keyboard but florence lags</p> <p>Second method is to run florence in background before opening the app. Then use </p> <pre><code>flo...
0
2016-06-30T14:38:13Z
[ "python", "tkinter", "keyboard", "entry" ]
Odoo8-Call a python function from menuitem and rereturn a URL?
38,096,480
<p>I tried to call python function from menuitem and return a URL? It successfully get into function but didn't return anything, No error. My code :</p> <p>In py:</p> <pre><code> def browse_ftp(self, cr, uid, ids, context=None): fi_url='http://www.google.com' print'Final Url',fi_url // It print url retur...
0
2016-06-29T10:07:22Z
38,196,824
<p>I have modified ir.action.server view like below:</p> <pre><code> &lt;record id="action_make_testing" model="ir.actions.server"&gt; &lt;field name="name"&gt;Test Browsse File&lt;/field&gt; &lt;field name="condition"&gt;True&lt;/field&gt; &lt;field name="type"&gt;ir.actions.server&lt;/field&gt; &...
0
2016-07-05T06:44:20Z
[ "python", "function", "url", "menuitem", "odoo-8" ]
Django - permission denied for text file created on the fly
38,096,520
<p>I am trying to make a downloadable text file on the fly, i think i have achieved this but when i run the code i get a permission denied error.</p> <p>also when i open this text file, does it get created anywhere in the file system? as i dont want to store these files, just create them and have them downloaded to us...
1
2016-06-29T10:09:04Z
38,097,462
<p>If the goal is to provide a link where the user can download a file which is automatically generated, there's no need to write anything to disk.</p> <p>You can just build the desired content in a Python string, and use the <a href="https://tools.ietf.org/html/rfc6266" rel="nofollow"><code>Content-Disposition</code>...
0
2016-06-29T10:51:39Z
[ "python", "django" ]
Error while installing pam-python-1.0.5
38,096,665
<p>When i run <code>make</code> command i receive following error</p> <pre><code>rm -f html/index.html &amp;&amp; ln -s pam_python.html html/index.html make[1]: Leaving directory `/home/vagrant/pam-python-1.0.5/doc' make --directory src make[1]: Entering directory `/home/vagrant/pam-python-1.0.5/src' gcc -O0 -Wall -We...
0
2016-06-29T10:15:23Z
38,098,018
<p>Suggest : Use the stable version = python-pam-1.8.2 .</p> <p>The EL6 package : python-pam-1.8.2-2.el6.noarch.rpm ( 9.7kB ) <a href="https://drive.google.com/file/d/0B7S255p3kFXNQ1FrM1poTXR5Nmc/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0B7S255p3kFXNQ1FrM1poTXR5Nmc/view?usp=sharing</a></p> <p...
1
2016-06-29T11:17:14Z
[ "python", "authentication", "pam" ]
Edit tensorflow inceptionV3 retraining-example.py for multiple classificiations
38,096,689
<p>TLDR: Cannot figure out how to use retrained inceptionV3 for multiple image predictions. </p> <p>Hello kind people :) I've spent a few days searching many stackoverflow posts and the documentation, but I could not find an answer to this question. Would greatly appreciate any help on this!</p> <p>I have retrained a...
9
2016-06-29T10:16:50Z
38,228,509
<p>So looking at your linked script:</p> <pre><code>with tf.Session() as sess: softmax_tensor = sess.graph.get_tensor_by_name('final_result:0') predictions = sess.run(softmax_tensor, {'DecodeJpeg/contents:0': image_data}) predictions = np.squeeze(predictions) top_k = predic...
2
2016-07-06T16:00:51Z
[ "python", "python-3.x", "machine-learning", "tensorflow" ]
Edit tensorflow inceptionV3 retraining-example.py for multiple classificiations
38,096,689
<p>TLDR: Cannot figure out how to use retrained inceptionV3 for multiple image predictions. </p> <p>Hello kind people :) I've spent a few days searching many stackoverflow posts and the documentation, but I could not find an answer to this question. Would greatly appreciate any help on this!</p> <p>I have retrained a...
9
2016-06-29T10:16:50Z
38,233,104
<p>The raw jpeg data seems to be fed directly to a <a href="https://www.tensorflow.org/versions/master/api_docs/python/image.html#decode_jpeg" rel="nofollow"><code>decode_jpeg</code></a> operation, which only takes a single image as input at a time. In order to process more than one image at a time you would probably n...
3
2016-07-06T20:23:11Z
[ "python", "python-3.x", "machine-learning", "tensorflow" ]
Edit tensorflow inceptionV3 retraining-example.py for multiple classificiations
38,096,689
<p>TLDR: Cannot figure out how to use retrained inceptionV3 for multiple image predictions. </p> <p>Hello kind people :) I've spent a few days searching many stackoverflow posts and the documentation, but I could not find an answer to this question. Would greatly appreciate any help on this!</p> <p>I have retrained a...
9
2016-06-29T10:16:50Z
39,972,418
<p>I had the same issues. I followed all the possible solutions and finally found one that worked for me. This error occurs when the version of Tensorflow used to re-train the model is different from the one where it is being used. </p> <p>The solution is to update Tensorflow to the latest version. Since I had used ...
0
2016-10-11T07:36:25Z
[ "python", "python-3.x", "machine-learning", "tensorflow" ]
Python - Class methods with input
38,096,757
<p>How can I create a method in a class with a user input?</p> <p>What argument should I pass when I am calling the method ?</p> <pre><code>class Student: def __init__(self): self._name = '' def getName(self): return self._name def setName(self, newName): newName = input ('...
0
2016-06-29T10:19:43Z
38,096,987
<p>This should work: </p> <pre><code>class Student: def __init__(self): self._name = '' def getName(self): return self._name def setName(self, newName): self._name = newName studente = Student() newName = input('Inserire nome:') studente.setName(newName) </code></pre> <p>You wer...
1
2016-06-29T10:30:25Z
[ "python", "python-3.x", "oop" ]
Python - Class methods with input
38,096,757
<p>How can I create a method in a class with a user input?</p> <p>What argument should I pass when I am calling the method ?</p> <pre><code>class Student: def __init__(self): self._name = '' def getName(self): return self._name def setName(self, newName): newName = input ('...
0
2016-06-29T10:19:43Z
38,097,044
<p>If I understood what you want correctly, why dont you try to ask for an input when initialsing class instance?</p> <pre><code>class MyClass(object): def __init__(self): self.name = input('Enter name&gt; ') X = MyClass() # when executing that line, you'll be asked for a name to input </code></pre> <p...
0
2016-06-29T10:33:17Z
[ "python", "python-3.x", "oop" ]
Python - Class methods with input
38,096,757
<p>How can I create a method in a class with a user input?</p> <p>What argument should I pass when I am calling the method ?</p> <pre><code>class Student: def __init__(self): self._name = '' def getName(self): return self._name def setName(self, newName): newName = input ('...
0
2016-06-29T10:19:43Z
38,100,022
<p>You could also play with the builtin <code>setattr</code> and dismiss the explicit setters/getters:</p> <pre><code>class Student: pass student = Student() newName = input('Inserire nome:') setattr(student, 'name', newName) </code></pre>
-1
2016-06-29T12:47:35Z
[ "python", "python-3.x", "oop" ]
How to access the dict value?
38,096,826
<p>I have a response syntax of type <code>dict</code>:</p> <pre><code>{ 'StoppingInstances': [ { 'InstanceId': 'string', 'CurrentState': { 'Code': 123, 'Name': 'pending'|'running'|'shutting-down'|'terminated'|'stopping'|'stopped' }, ...
-2
2016-06-29T10:22:49Z
38,096,845
<p>Your <code>response['StoppingInstances']</code> object is a <em>list</em> of dictionaries. You'd have to either loop over those or index an individual item:</p> <pre><code>response['StoppingInstances'][0]['CurrentState']['Name'] == "stopping" </code></pre> <p>If you need to test if <em>any</em> of those objects is...
0
2016-06-29T10:24:06Z
[ "python" ]
How to access the dict value?
38,096,826
<p>I have a response syntax of type <code>dict</code>:</p> <pre><code>{ 'StoppingInstances': [ { 'InstanceId': 'string', 'CurrentState': { 'Code': 123, 'Name': 'pending'|'running'|'shutting-down'|'terminated'|'stopping'|'stopped' }, ...
-2
2016-06-29T10:22:49Z
38,096,852
<p>Your data contains a list enclosing the outer dict values, and not simple nested dictionaries as you suppose. You need to index the list, then access the nested dict values via the keys:</p> <pre><code>response['StoppingInstances'][0]['CurrentState']['Name'] # ^ </code></pre> <p>And in ...
0
2016-06-29T10:24:25Z
[ "python" ]
Blender, convert .stl to .obj with prompt commande
38,096,913
<p>I want to convert an .stl file to .obj, without using blender interface.</p> <p>To do that, i want to do it in two step :</p> <p>1 STL to BLEND</p> <p>2 BLEND to OBJ</p> <p>Actually BLEND to OBJ work ok with this python code :</p> <pre><code>import bpy import sys argv = sys.argv argv = argv[argv.index("--") +...
2
2016-06-29T10:27:04Z
38,098,605
<blockquote> <p>i got as an error : File format is not supported in file C:..\turbine.stl Blender quit</p> </blockquote> <p>The error you are getting means that Blender is trying to read first command argument as a .blend file. Just put your script's arguments after "--" (as it says in the script's comment), and it ...
1
2016-06-29T11:46:05Z
[ "python", "stl", "blender", "catia" ]
Blender, convert .stl to .obj with prompt commande
38,096,913
<p>I want to convert an .stl file to .obj, without using blender interface.</p> <p>To do that, i want to do it in two step :</p> <p>1 STL to BLEND</p> <p>2 BLEND to OBJ</p> <p>Actually BLEND to OBJ work ok with this python code :</p> <pre><code>import bpy import sys argv = sys.argv argv = argv[argv.index("--") +...
2
2016-06-29T10:27:04Z
39,133,878
<p>I ran this code with the following input on OSX</p> <pre><code>/Applications/blender-2.77a-OSX_10.6-x86_64/blender.app/Contents/MacOS/blender --background --python convert_stl_to_blend.py -- fileIN.stl FileOut.obj </code></pre> <p>This code was very helpful, thanks guys!</p> <p>BTW, I needed this code to do all f...
0
2016-08-24T22:20:32Z
[ "python", "stl", "blender", "catia" ]
Find model object that encompasses another in Django
38,096,940
<p>Given an unsaved/local model object, how can I find the list of objects that already have the information of the unsaved object without having to keep a list of fields in sync?</p> <p>For example, say I have this model:</p> <pre><code>class Person(models.Model): name = models.CharField(max_length=100) job ...
-1
2016-06-29T10:28:38Z
38,097,056
<p>change:</p> <pre><code>luke = find_my_object(Person(name='Luke')) </code></pre> <p>to</p> <pre><code>luke = find_my_object('Person', name, 'Luke') </code></pre> <p>and</p> <pre><code>def find_my_object(modelname, fieldname, value=None): return eval(modelname).objects.filter(fieldname='{}'.format(value)).fir...
0
2016-06-29T10:33:46Z
[ "python", "django", "django-models" ]
Find model object that encompasses another in Django
38,096,940
<p>Given an unsaved/local model object, how can I find the list of objects that already have the information of the unsaved object without having to keep a list of fields in sync?</p> <p>For example, say I have this model:</p> <pre><code>class Person(models.Model): name = models.CharField(max_length=100) job ...
-1
2016-06-29T10:28:38Z
38,097,163
<blockquote> <p>Is this a pointless exercise</p> </blockquote> <p>Yes, but not for the reasons you've stated about a dictionary</p> <p>It would appear to me that its just obfuscating code for the sake of it when the same can be easily achieved by just inserting a queryset where you expect to introduce this new meth...
0
2016-06-29T10:38:20Z
[ "python", "django", "django-models" ]
Selecting children from TreeView using pywinauto
38,096,962
<p>The issue that I have is related to <code>the GetItem()</code> method from <code>pywinauto</code>. I was able to run the <code>window.TreeView.GetItem('\\Desktop').Click()</code> command on Windows 7 and 10 both 32 bit but it throws an exeption and does not run when calling it from the python command line of Windows...
1
2016-06-29T10:29:26Z
38,107,221
<p>It happens because Win32 API structure sizes for Windows messages are different for 32-bit and 64-bit apps. It's fixed in UIA branch (you can wait for 0.6.0 planned this summer).</p> <p>Another way is just to set up 32-bit Python (and pywinauto) in addition to your 64-bit Python (you just need to care about full pa...
1
2016-06-29T18:14:55Z
[ "python", "python-2.7", "pywinauto" ]
Referencing columns in Pyspark DataFrame
38,097,011
<p>Suppose I have a word list that I converted to Data Frame</p> <pre><code> ----- | word | ----- | cat | | bird | | dog | | ... | ----- </code></pre> <p>And I tried to do a letter count:</p> <pre><code>from pyspark.sql.functions import length letter_count_df = words_df.select(length(words_df.word)) </code>...
1
2016-06-29T10:31:52Z
38,100,395
<p>With name:</p> <pre><code>&gt;&gt;&gt; letter_count_df.select(c) DataFrame[length(word): int] </code></pre> <p>or col and name:</p> <pre><code>&gt;&gt;&gt; from pyspark.sql.functions import * &gt;&gt;&gt; letter_count_df.select(c)) </code></pre> <p>with <code>c</code> being a constant:</p> <pre><code>&gt;&gt;&g...
1
2016-06-29T13:02:19Z
[ "python", "apache-spark", "pyspark", "spark-dataframe" ]
TwitterAPI for Python: using result from request in a new request
38,097,090
<p>I want to collect all user data from the followers from a specific twitter user. First, I collect the user_id's of the followers from the user using followers/id. Thereafter I want to use users/lookup in order to collect the user data from the collected user_id's all at once (with a maximum of 100). This is where I ...
0
2016-06-29T10:35:17Z
38,117,585
<p>I managed to fix it myself. The first request yielded too many results, which the second request couldn't process. I changed the first request to this:</p> <pre><code>r = api.request('followers/ids', {'screen_name':'elonmusk', 'count':'100'}) </code></pre>
0
2016-06-30T08:18:54Z
[ "python", "twitter" ]
Pytesseract No such file or directory error
38,097,148
<p>First of all I did everything mentioned here <a href="http://stackoverflow.com/questions/28741563/pytesseract-no-such-file-or-directory-error">pytesseract-no such file or directory error</a> </p> <p>Still doesn't work. Now I'm using Pycharm IDE with following code:</p> <pre><code>from PIL import Image import pytes...
0
2016-06-29T10:37:43Z
38,098,089
<p>I solved my own question.</p> <pre><code>im = Image.open('test.png') print pytesseract.image_to_string(im) </code></pre> <p>It's still unclear why it works when a reference is passed but not directly when I try to open image inside the parameter.</p>
-1
2016-06-29T11:20:49Z
[ "python", "image", "text", "pycharm", "tesseract" ]
Pytesseract No such file or directory error
38,097,148
<p>First of all I did everything mentioned here <a href="http://stackoverflow.com/questions/28741563/pytesseract-no-such-file-or-directory-error">pytesseract-no such file or directory error</a> </p> <p>Still doesn't work. Now I'm using Pycharm IDE with following code:</p> <pre><code>from PIL import Image import pytes...
0
2016-06-29T10:37:43Z
38,098,286
<p>I tested the code you mentioned in your question. It works fine. I was facing the same error </p> <blockquote> <p><em>No such file or directory found</em></p> </blockquote> <p>The problem was the directory containing 'tesseract.exe' was not added to the environment Variable. You should be able to run command 'te...
0
2016-06-29T11:30:30Z
[ "python", "image", "text", "pycharm", "tesseract" ]
Difference between Sqlalchemy execution time and execution time from EXPLAIN query?
38,097,347
<p>I am using postgresql with Flask and sqlalchemy. I found that if I do something like in python,</p> <pre><code>t1 = datetime.datetime.now() session.query(Table_Class).all() t2 = datetime.datetime.now() print (t2 - t1) </code></pre> <p>I am getting execution time of sqlalchemy query. But if I go to postgresql and w...
0
2016-06-29T10:46:35Z
38,097,454
<p>The difference is probably cause by communication overhead. When you run explain analyse you are measuring the exact time of the query in your postgres database. When you measure the time in the python code you are measuring the time of the query execution plus: the time of connecting to the database, sending the da...
0
2016-06-29T10:51:11Z
[ "python", "postgresql", "flask", "sqlalchemy", "explain" ]
How do I open up a download dialog box using Flask?
38,097,453
<p>I'm trying to let the user download an mp3 file after a text-to-speech convert using gTTS. The flash message appears but the download dialog does not open.</p> <p>Here is the Python code:</p> <pre><code>def mytts(): if request.method == 'POST': if not request.form['text']: flash('Text neede...
0
2016-06-29T10:51:09Z
38,102,224
<p>You need to return the result of <code>send_file</code>. It just generates a response object, Flask won't do anything with that on it's own.</p> <pre><code>return send_file(...) </code></pre>
1
2016-06-29T14:11:34Z
[ "javascript", "python", "html", "flask", "text-to-speech" ]
How to right click on a folder and select from context menu using pywinauto?
38,097,476
<p>I'm writing automation tests for a cloud syncing desktop application. The problem I'm facing is that I cannot select a sub-folder from a window and I cannot select an option from context menu when right-click on a folder.</p> <p>Example:</p> <pre><code>import pywinauto pywinauto.Application().Start(r'explorer.exe...
1
2016-06-29T10:52:19Z
38,104,573
<p>(WARNING: for early testing of UIA branch of pywinauto; will replace the answer after pywinauto 0.6.0 is out)</p> <p>If you're familiar with Git, just clone the main repo, switch to UIA branch, install comtypes with <code>pip install comtypes</code> and then install pywinauto (UIA branch) by <code>python setup.py i...
0
2016-06-29T15:53:47Z
[ "python", "automation", "pywinauto" ]
How to right click on a folder and select from context menu using pywinauto?
38,097,476
<p>I'm writing automation tests for a cloud syncing desktop application. The problem I'm facing is that I cannot select a sub-folder from a window and I cannot select an option from context menu when right-click on a folder.</p> <p>Example:</p> <pre><code>import pywinauto pywinauto.Application().Start(r'explorer.exe...
1
2016-06-29T10:52:19Z
38,416,206
<p>To continue vasiliy ryabov's answer. It can be accomplished with the latest UIA branch of pywinauto. Let's say you have a <code>Video</code> folder opened and you try to right click on a sub-folder called <code>My Home Videos</code>. When a context menu is popped up we just click on <code>Open</code> menu item:</p> ...
1
2016-07-16T22:25:13Z
[ "python", "automation", "pywinauto" ]
I am having trouble with Tkinter GUI control
38,097,491
<p>I have a programme with various controls, a live webcam feed and a matplotlib figure based on the webcam data. I would like all the controls to be located in a left column, and the webcam and matplotlib figure to be located in a right column.</p> <p>Attempts to use .grid() methods, canvases and frames etc don't wor...
1
2016-06-29T10:53:03Z
38,098,753
<p>The line</p> <pre><code>labelframe = tk.LabelFrame(parent, text="This is a LabelFrame") </code></pre> <p>probably should have <code>self</code> instead of <code>parent</code>. After this</p> <pre><code>labelframe.pack(fill="both", expand="yes", tk.LEFT) </code></pre> <p>should work. Since the Controller and the ...
1
2016-06-29T11:53:18Z
[ "python", "tkinter" ]
Issue's saving multiple records with ajax in django
38,097,523
<p>I am having issue's saving my form multiple times. I want the user to fill out my form with as many dimensions as possible(this is the form) so, If they did it once only insert one record into my db if they do two dimensions save each one to my db totaling two new records. Any help figuring this out will be greatly ...
0
2016-06-29T10:54:17Z
38,098,611
<p>change the change <code>dim.save()</code> to <code>Dimension.objects.create()</code></p> <p><a href="http://stackoverflow.com/a/23926742/475565">http://stackoverflow.com/a/23926742/475565</a></p> <p>you also should change id's to classes</p> <pre><code>$('.dim_form').on('submit', function(){ var data = $(this)....
1
2016-06-29T11:46:21Z
[ "javascript", "python", "ajax", "django" ]
Scipy.misc import not working
38,097,565
<p>I'm having problems with importing scipy.misc in my python script. Now I know other people also posted questions concerning this, but their solutions are not working for me.</p> <p>The program I am writing begins like this:</p> <pre><code>import matplotlib as plt from matplotlib.pyplot import imshow from PIL impor...
1
2016-06-29T10:56:05Z
38,097,676
<p>Since you aren't an expert on programming or computers I would recommend that you switch to a Python distribution that brings an up-to-date SciPy and many other libraries with it. Continuum's <a href="https://www.continuum.io/downloads" rel="nofollow">open source Anaconda package</a> will remove all the maintenance ...
1
2016-06-29T11:01:18Z
[ "python", "numpy", "scipy" ]
dill: TypeError: 'module' object is not callable when dill.load() is run from different files
38,097,583
<p>I use <code>dill</code> to store python objects to a file like:</p> <pre><code>with open(filename, 'wb') as output_: dill.dump(obj, output_) </code></pre> <p>and than I load stored objects from <code>test.dprj</code> file <strong>C:...\DyS_project\testsread_write.py</strong></p> <pre><code>import pprint from ...
0
2016-06-29T10:57:03Z
38,527,224
<p>I have solved the problem that was actually a bad hidden type. I have changed the code:</p> <pre><code>import pprint </code></pre> <p>to:</p> <pre><code>from pprint import pprint </code></pre>
0
2016-07-22T13:05:30Z
[ "python", "pickle", "dill" ]
how to invisible field based on the dropdown selection field in ODOO
38,097,608
<p><a href="http://i.stack.imgur.com/BkHBv.png" rel="nofollow">error msg after added invisible attr</a><a href="http://i.stack.imgur.com/gyNy3.png" rel="nofollow">Added image here depending upon group bellow notepad tree view fields can be change</a> Hi friends I am beginner to ODOO or OpenERP, I have scenario in that ...
0
2016-06-29T10:58:22Z
38,105,188
<p>Create an related field for it and add that related field in attrs.</p> <pre><code> _name = 'feeder.data' _columns= {'group_name_related' :fields.related('group_name','field_name', type = 'char', relation='target_table_name', string='Name')} &lt;tree&gt; &lt;field name='name' attrs="{'invisible' : [('group...
0
2016-06-29T16:21:36Z
[ "python", "openerp", "odoo-8", "openerp-8" ]
Assign external function to class variable in Python
38,097,638
<p>I am trying to assign a function defined elsewhere to a class variable so I can later call it in one of the methods of the instance, like this:</p> <pre><code>from module import my_func class Bar(object): func = my_func def run(self): self.func() # Runs my function </code></pre> <p>The problem is...
5
2016-06-29T10:59:43Z
38,097,916
<p>Python functions are <a href="https://docs.python.org/2/howto/descriptor.html" rel="nofollow"><em>descriptor</em> objects</a>, and when attributes on a class accessing them an instance causes them to be bound as methods.</p> <p>If you want to prevent this, use the <a href="https://docs.python.org/2/library/function...
8
2016-06-29T11:12:23Z
[ "python", "oop", "python-2.x" ]
How to load static files in python django
38,097,719
<p>I have tried to modify in the settings.py file to allow loading css files but some of html code still doesn't appear with its style, the run in the terminal the command "python manage.py collectstatic" and it says that files are copied but still doesn't appear its effect.</p> <p>HERE IS THE MODIFIED LINES IN settin...
1
2016-06-29T11:03:00Z
38,097,921
<p>In your settings.py provide:</p> <pre><code>STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static...
0
2016-06-29T11:12:54Z
[ "python", "html", "css", "django" ]
python - history file
38,097,755
<p>I have a project </p> <p>I'm making a text browser and I need help</p> <p>I have a history file that every url and time, put in the history file like:</p> <blockquote> <p>www.youtube.com 2016-06-29 13:47:15.986000</p> <p>www.youtube.com 2016-06-29 13:47:22.416000</p> <p>www.youtube.com 2016-06-29 13:4...
-6
2016-06-29T11:04:35Z
38,098,094
<p>If you are trying to delete this lines from the file, try this:</p> <pre><code>import os def removeUrl(url): url_file = "url.txt" fileIn = open(url_file, 'r') fileOut = open("temp.txt", 'w') for line in fileIn: if url not in line: fileOut.write(line) fileIn.close() fileO...
-1
2016-06-29T11:21:05Z
[ "python", "python-2.7", "file" ]
Different in List size
38,097,829
<p>could someone explain me the difference in the List <strong>size</strong>? Once it is (x,1) and the other (x,). I think I get an idexError due to that.</p> <p>Thanks <a href="http://i.stack.imgur.com/SD2g1.png" rel="nofollow"><img src="http://i.stack.imgur.com/SD2g1.png" alt="enter image description here"></a></p> ...
1
2016-06-29T11:08:31Z
38,098,758
<p>An array A of size (x,1) is a matrix of x rows and 1 columns (2 dimensions), which differs from A.T of size (1,x). They have the same elements but in different 'orientation'. An array B of size (x,) is a vector of x coordinates (1 dimension), without any orientation (it's not a row nor a column). It's just a list of...
1
2016-06-29T11:53:27Z
[ "python", "list", "size" ]
Save all class methods with decorator
38,097,896
<p>i have a class and i want to all its methods in a list inside the class, i want it to work even if i have two methods with the same name, my problem is i can't access the class to put the methods there. lets say i have the decorator</p> <pre><code>def dec(func): class = ???? class.methods.append(func) r...
0
2016-06-29T11:11:58Z
38,098,116
<p>The class object itself is only constructed <em>after</em> the body statements (all the statements inside the <code>class &lt;classname&gt;(&lt;bases,&gt;):</code> block have been executed. Decorators on the other hand are executed together with the function they are decorating.</p> <p>You could just in the list yo...
1
2016-06-29T11:22:12Z
[ "python" ]
Is brute force the best option for multiple regression using Python?
38,097,941
<p>In the linear model 𝑦 = 𝑎0 + 𝑎1 × 𝑥i + 𝑎2 × 𝑥j + 𝑎3 × 𝑥k + 𝜖 , what values for 𝑖,j,k ∈ [1,100] results in the model with the highest R-Squared?</p> <p>The data set consists of 100 independent variables and one dependent variable. Each variable has 50 observatio...
1
2016-06-29T11:14:02Z
38,477,815
<p>Exhaustive search is going to be the slowest way of doing this</p> <p>The fastest way to do this is mentioned in one of the comments. You should pre-specify your model based on theory/intuition/logic and come up with a set of variables that you hypothesize will be good predictors of your outcome.</p> <p>The differ...
0
2016-07-20T09:47:26Z
[ "python", "statistics", "scikit-learn", "regression", "multiple-regression" ]
Inherit from matplotlib
38,098,026
<p>I´d like to create my own plotting class as follows but I can not find a way to inherit from <code>Figure</code> while using the <code>plt</code> module (see below). Either it inherits from <code>Figure</code> or it changes the <code>tick_params</code>. <code>Figure</code> is a class so I can inherit but <code>plt<...
1
2016-06-29T11:17:36Z
38,099,949
<p>Ok, meanwhile I found one solution myself. First I created an inherited class <code>custom_plot</code> from <code>Figure</code> which I use in conjuncion with <code>plt.figure(FigureClass=custom_plot, figtitle='my title')</code>. I collect the <code>plt</code>related modification with <code>cplot</code> and and get ...
1
2016-06-29T12:44:18Z
[ "python", "inheritance", "matplotlib" ]
Jinja2 dump into an object?
38,098,087
<p>I want to be able to dump into an object. </p> <p>According to the documentation, I can dump into a file or a file like object. </p> <p>What can I use as a file like object?</p> <p><em>Obs.: I don't want to save it nor display it. Its a downloadable config template for a router thats created on the fly from data ...
1
2016-06-29T11:20:44Z
38,098,324
<p>In general, file-like objects are just things that act like files in some way (typically by implementing <code>read</code> and/or <code>write</code>). I like the answer given to <a href="http://stackoverflow.com/a/1661354/1062499">Check if object is file-like in Python</a>.</p> <p>So, in your case, it seems it's e...
1
2016-06-29T11:32:16Z
[ "python", "django", "jinja2" ]
Jinja2 dump into an object?
38,098,087
<p>I want to be able to dump into an object. </p> <p>According to the documentation, I can dump into a file or a file like object. </p> <p>What can I use as a file like object?</p> <p><em>Obs.: I don't want to save it nor display it. Its a downloadable config template for a router thats created on the fly from data ...
1
2016-06-29T11:20:44Z
38,098,563
<p>I've never used jinja2, but I suspect you can use a <code>StringIO</code> to get the desired content as a string.</p> <p>The following ought to work, but I can't (easily) test it...</p> <pre><code>from StringIO import StringIO env = Environment(autoescape=False, optimized=False) sio = StringIO() device_config =...
1
2016-06-29T11:43:32Z
[ "python", "django", "jinja2" ]
how do i overwrite to a specific part of a text file in python
38,098,101
<p>For example if in my text file i have,</p> <p>Explosion,Bomb,Duck Jim,Sam,Daniel</p> <p>and i wanted to change the Daniel in that file, so that nothing else would be affected. How would I achieve this without overwriting the whole file.</p>
-1
2016-06-29T11:21:27Z
38,098,164
<p>if you want get the last element first you need the read() method which simply read from files then split it (comma is the seperator ) and using slice [:-1]</p>
-1
2016-06-29T11:24:50Z
[ "python", "file" ]
how do i overwrite to a specific part of a text file in python
38,098,101
<p>For example if in my text file i have,</p> <p>Explosion,Bomb,Duck Jim,Sam,Daniel</p> <p>and i wanted to change the Daniel in that file, so that nothing else would be affected. How would I achieve this without overwriting the whole file.</p>
-1
2016-06-29T11:21:27Z
38,098,173
<p>You can use <code>fileinput</code></p> <pre><code>import fileinput with fileinput.FileInput(fileToSearch, inplace=True, backup='.bak') as file: for line in file: print(line.replace(textToSearch, textToReplace), end='') #testToSearch:- Daniel #textToReplace:- newName </code></pre> <p>O...
1
2016-06-29T11:25:21Z
[ "python", "file" ]
how do i overwrite to a specific part of a text file in python
38,098,101
<p>For example if in my text file i have,</p> <p>Explosion,Bomb,Duck Jim,Sam,Daniel</p> <p>and i wanted to change the Daniel in that file, so that nothing else would be affected. How would I achieve this without overwriting the whole file.</p>
-1
2016-06-29T11:21:27Z
38,098,556
<pre><code>f = open('name.txt','rb+') for line in f: line.replace('change','Daniel') f.write(line) f.close() </code></pre>
-1
2016-06-29T11:43:03Z
[ "python", "file" ]
Supress output of subprocess
38,098,203
<p>I want to use the subprocess module to control some processes spawned via ssh.</p> <p>By searching and testing I found that this works:</p> <pre><code>import subprocess import os import time node = 'guest@localhost' my_cmd = ['sleep','1000'] devnull = open(os.devnull, 'wb') cmd = ['ssh', '-t', '-t', node] + my_cm...
1
2016-06-29T11:26:42Z
38,103,276
<p>Ok, the output is now clear. I do not exactly know why, but the command <code>ssh -t -t</code> puts the local terminal in raw mode. It makes sense anyway, because it is intended to allow you to directly use curses programs (such as vi) on the remote, and in that case, no conversion should be done, not even the simpl...
2
2016-06-29T14:58:02Z
[ "python", "python-2.7", "ssh", "subprocess" ]
connecting strings in pandas
38,098,290
<p>I try to sum up columns with string data. The Problem is that I want to ignore the NaN, but I didn't find a solution.</p> <p>The Dataframe look like this:</p> <pre><code>s=pd.DataFrame({'A':['(Text,','(Text1,'],'B':['(Text2,','(Text3,'],'C':['(Text4,','(Text5,']}) A B C 0 (Text, (Text2, ...
1
2016-06-29T11:30:44Z
38,098,364
<p>You can fill the null values of your dataframe with empty strings before computing the new column. Use <code>fillna</code> like this:</p> <pre><code>s.fillna('',inplace = True) </code></pre>
0
2016-06-29T11:33:45Z
[ "python", "string", "pandas", "sum" ]
connecting strings in pandas
38,098,290
<p>I try to sum up columns with string data. The Problem is that I want to ignore the NaN, but I didn't find a solution.</p> <p>The Dataframe look like this:</p> <pre><code>s=pd.DataFrame({'A':['(Text,','(Text1,'],'B':['(Text2,','(Text3,'],'C':['(Text4,','(Text5,']}) A B C 0 (Text, (Text2, ...
1
2016-06-29T11:30:44Z
38,098,870
<p>I think you can use <a href="http://stackoverflow.com/a/23445503/2901002"><code>Kiwi</code></a> solution, where is added removing <code>(,</code> by <code>.strip('(,')</code>:</p> <pre><code>import pandas as pd import numpy as np s=pd.DataFrame({'A':['(Text,','(Text1,'], 'B':[np.nan,'(Text3,'], ...
0
2016-06-29T11:58:16Z
[ "python", "string", "pandas", "sum" ]
connecting strings in pandas
38,098,290
<p>I try to sum up columns with string data. The Problem is that I want to ignore the NaN, but I didn't find a solution.</p> <p>The Dataframe look like this:</p> <pre><code>s=pd.DataFrame({'A':['(Text,','(Text1,'],'B':['(Text2,','(Text3,'],'C':['(Text4,','(Text5,']}) A B C 0 (Text, (Text2, ...
1
2016-06-29T11:30:44Z
38,099,658
<p>I feel what you really need to use should be <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.applymap.html" rel="nofollow"><code>applymap</code></a> after filling all <code>NaN</code> values with an empty string as you are trying to manipulate all the columns in the dataframe. </p> <...
0
2016-06-29T12:32:39Z
[ "python", "string", "pandas", "sum" ]
Using python multiprocessing for sklearn NN
38,098,316
<p>I am using dev version of Python sklearn package with NN implementation. My task is to train 4 NN with different input data and the average the predictions </p> <pre><code>X_median = preprocessing.scale(data_median) X_min = preprocessing.scale(data_min) X_max = preprocessing.scale(data_max) X_mean = preprocessing....
1
2016-06-29T11:32:01Z
38,123,869
<p>Finally I made it work)</p> <p>I based my solution on this <a href="http://stackoverflow.com/questions/5442910/python-multiprocessing-pool-map-for-multiple-arguments">answer</a>. So, firstly create two help functions:</p> <p>1)</p> <pre><code>def Myfunc(MyNN,X,train_y): MyBrain.fit(X,train_y) return MyNN </code><...
0
2016-06-30T12:59:20Z
[ "python", "machine-learning", "scikit-learn", "multiprocessing", "pool" ]
forecast results for a specific vector x using statsmodels linear regressions
38,098,472
<p>I've successfully built a model using OLS for a large number of data.</p> <pre><code>results = smf.ols(formula='ind ~ Age + C(County) + C(Class)', data=df).fit() </code></pre> <p>I'd like to implement a method that allows the user to input a vector <code>X</code> and have it return a <code>y</code> based on the r...
0
2016-06-29T11:39:15Z
38,102,490
<p>If I'm getting that right, you don't want the in-sample prediction of <code>y</code>, which is why you don't want to use the <code>predict</code> method; instead you just want to be able to plug in arbitrary <code>x</code> values and get a value for <code>y</code> based on the predicted coefficients ?</p> <p>If tha...
1
2016-06-29T14:23:42Z
[ "python", "pandas", "scikit-learn", "statsmodels" ]
python multiline comment indent
38,098,522
<p>I have a Django project, and in some places we have multiline comments indented as follows: </p> <pre><code>field = models.IntegerField(default=0, null=True) # 0-initial_email_sent # 1-second_email_sent # 2-third_...
2
2016-06-29T11:41:27Z
38,098,587
<p>This question is duplicate of <a href="http://stackoverflow.com/questions/7696924/multiline-comments-in-python">this question</a><br> You could also use multi-line comments like this.</p> <pre><code>""" This is how yo can use Python Multi-line Comments Line two is here. Line three is here. """ </code></pre>
2
2016-06-29T11:44:47Z
[ "python", "pep" ]
python multiline comment indent
38,098,522
<p>I have a Django project, and in some places we have multiline comments indented as follows: </p> <pre><code>field = models.IntegerField(default=0, null=True) # 0-initial_email_sent # 1-second_email_sent # 2-third_...
2
2016-06-29T11:41:27Z
38,098,962
<p>Magic numbers are evil, so the best documentation here is to use named (pseudo) constants:</p> <pre><code>INITIAL_EMAIL_SENT = 0 SECOND_EMAIL_SENT = 1 THIRD_EMAIL_SENT = 2 field = models.IntegerField(default=INITIAL_EMAIL_SENT, null=True) </code></pre> <p>As a general rule, the less you have to comment the better...
3
2016-06-29T12:02:37Z
[ "python", "pep" ]
pyspark: Passing RDD as parameter to a Class
38,098,552
<p>Could you help to retrieve value from a row that is passed as a parameter to a class constructor (or) please suggest a better approach. My aim is to validate the value of all fields. Each field has a different validation criteria.</p> <p>This is what I am doing:</p> <p>I have read the hive table using HiveContext ...
0
2016-06-29T11:42:56Z
38,100,607
<ul> <li><p>It looks like your row is inside a list :</p> <pre><code> val[0].id </code></pre></li> <li><p>Why not use a function here ? You can insert a boolean and filter out the wrong rows</p> <pre><code>def normalize(row): .... validate row.id ... return Row(validated = is_validated, id=row.id) myrdd.map(...
1
2016-06-29T13:10:16Z
[ "python", "apache-spark", "pyspark" ]
regex replace repeated (emoticon) characters python
38,098,747
<p>I want to replace <code>:)</code> / <code>:))))</code>... with <code>+</code> for as many occurrences as seen. e.g.:</p> <pre><code>:) -&gt; + :))) -&gt; +++ </code></pre> <p>And same for negative :</p> <pre><code>:( -&gt; - :((( -&gt; --- </code></pre> <p>It should also match for left-handed emotico...
-1
2016-06-29T11:52:52Z
38,099,032
<p>Why not?</p> <pre><code>&gt;&gt;&gt; def get_emoticon(txt): return re.sub(r':(([\(\)])+)', lambda m: '-'*len(m.group(1)) if m.group(2) == '(' else '+' * len(m.group(1)), txt) &gt;&gt;&gt; get_emoticon(':) hi :))) how r you? :((( :(') '+ hi +++ how r you? --- -' &gt;&gt;&gt; </code></pre> <p>Update:</p> <p...
1
2016-06-29T12:06:15Z
[ "python", "regex" ]
PySide - PyQt : How to make set QTableWidget column width as proportion of the available space?
38,098,763
<p>I'm developing a computer application with <em>PySide</em> and I'm using the QTableWidget. Let's say my table has 3 columns, but the data they contain is very different, like (for each row) a long sentence in the first column, then 3-digit numbers in the two last columns. I'd like <strong>to have my table resize in ...
1
2016-06-29T11:53:39Z
38,107,422
<p>You can do this with <code>QItemDelegates</code> or <code>QStyledItemDelegates</code>. If you want to resize to contents <strong>and</strong> have automatic stretch, you'll need to choose which column is the "stretch" column.</p> <pre><code>class ResizeDelegate(QStyledItemDelegate): def __init__(self, table, ...
1
2016-06-29T18:25:59Z
[ "python", "qt", "user-interface", "pyqt", "pyside" ]
PySide - PyQt : How to make set QTableWidget column width as proportion of the available space?
38,098,763
<p>I'm developing a computer application with <em>PySide</em> and I'm using the QTableWidget. Let's say my table has 3 columns, but the data they contain is very different, like (for each row) a long sentence in the first column, then 3-digit numbers in the two last columns. I'd like <strong>to have my table resize in ...
1
2016-06-29T11:53:39Z
38,129,829
<p>This can be solved by setting the resize-mode for each column. The first section must stretch to take up the available space, whilst the last two sections just resize to their contents:</p> <pre><code> header = self.table.horizontalHeader() header.setResizeMode(0, QtGui.QHeaderView.Stretch) header.setRes...
1
2016-06-30T17:33:39Z
[ "python", "qt", "user-interface", "pyqt", "pyside" ]
How to remove children of QTreeWidgetItem
38,098,811
<p>How to remove children of QTreeWidgetItem. Sometimes it removes all the items and sometimes it doesn't. </p> <p>How to properly delete child items.</p> <p>Here is my function performing removal of child items and adding new child items</p> <pre><code>def update_children_cont(self,subDirs,parent): new_dir = su...
1
2016-06-29T11:55:39Z
38,108,801
<p>Your example doesn't work because you are trying to remove items while iterating over them. After each item is removed, the others will move down. So once the half-way point is passed, the loop will start giving invalid indexes.</p> <p>You can easily fix this by removing the items in <em>reverse order</em>. That wa...
1
2016-06-29T19:46:14Z
[ "python", "pyqt4" ]
LDA gensim. How to update a Postgres database with the correct topic number for every document?
38,098,824
<p>I am taking different documents from a database and I check with LDA (gensim), what kind of latent topics are there in these documents. This works pretty well. What I would like to do is to save in the database for every document what is its most probable topic. And I am not sure what is the best solution for it. I ...
0
2016-06-29T11:56:19Z
38,181,530
<p>As wildplasser has commented, I just had to select the id together with the text_column. I was trying it before, but with the way I was appending the data to the list, it was not suitable for the further processing. The code below works and as a result creates a table with the id and a number of the most probable to...
0
2016-07-04T09:43:16Z
[ "python", "postgresql", "lda", "gensim" ]
Compiling Python 3.4/5 fails with segmentation fault on RedHat 6.4
38,098,874
<p>I try to compile a new Python 3.x version on a Redhat 6.4 machine. In this example i use 3.5.1. </p> <p>GCC is gcc version 4.4.7 20120313 (Red Hat 4.4.7-3) (GCC). </p> <pre><code>./configure --prefix=/data/tools/python3 </code></pre> <p>works fine, but make fails:</p> <pre><code>make gcc -pthread -fPIC -Wsign-co...
0
2016-06-29T11:58:21Z
38,384,409
<p>I suggest using the RH Software Collection version: <a href="http://developers.redhat.com/products/softwarecollections/get-started-rhel6-python/" rel="nofollow">http://developers.redhat.com/products/softwarecollections/get-started-rhel6-python/</a></p> <p>This doc is for 3.4, but there's a 3.5 version too.</p>
0
2016-07-14T21:16:07Z
[ "python", "redhat" ]