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
Can I do real time adb logcat keyword look up using python?
38,904,426
<p>I am trying to run a test on android device and collect the logs using python and ADB. I want my python script to collect the ADB logcat logs and keep monitoring the logs, if any crash keywords(or any required keywords) are found during the run, take adb main radio bug-report and adb dump and save them in to particu...
-1
2016-08-11T19:14:45Z
38,904,485
<p>Yes, you can do this. Take a look at <em>subprocess</em> - <a href="http://docs.python.org/library/subprocess.html" rel="nofollow">http://docs.python.org/library/subprocess.html</a>. </p> <p>Once you have the <em>adb</em> output going into your Python script, you can do whatever you want to it - search live logs fo...
1
2016-08-11T19:18:49Z
[ "python", "adb", "jython" ]
How do I save a new graph as png with every iteration of a loop
38,904,461
<p>I don't know how to save a new graph png for each iteration of a loop using NetworkX. I've borrowed the code from this question: <a href="http://stackoverflow.com/questions/22635538/in-networkx-cannot-save-a-graph-as-jpg-or-png-file">in NetworkX cannot save a graph as jpg or png file</a> and manipulated it a bit. ...
0
2016-08-11T19:17:09Z
38,904,708
<p>First suggestion, accessing the colors by their index values is not "Pythonic". Instead, use a <code>for</code> loop:</p> <pre><code>for color in colors: print(color) </code></pre> <p>Your code is overwriting <code>Graph.png</code> on each iteration of the loop. To save a new file for each iteration, simply re...
0
2016-08-11T19:33:14Z
[ "python", "matplotlib", "networkx" ]
How do I save a new graph as png with every iteration of a loop
38,904,461
<p>I don't know how to save a new graph png for each iteration of a loop using NetworkX. I've borrowed the code from this question: <a href="http://stackoverflow.com/questions/22635538/in-networkx-cannot-save-a-graph-as-jpg-or-png-file">in NetworkX cannot save a graph as jpg or png file</a> and manipulated it a bit. ...
0
2016-08-11T19:17:09Z
38,904,716
<p>Just change the name of the output file</p> <pre><code>while n &lt; len(colorses): nx.draw(G, pos, node_size=1500, node_color=colorses[n], font_size=8, font_weight='bold') plt.tight_layout() # plt.show() plt.savefig("Graph" + str(n) +".png", format="PNG") n += 1 </code></pre> <p>You should use ...
2
2016-08-11T19:33:32Z
[ "python", "matplotlib", "networkx" ]
How to insert a list of values into a column in sqlite3 with python?
38,904,525
<p>I can't seem to get <code>executemany</code> to work. I didn't get any errors. But no values got inserted either. The following is a small example: the table prices already has some columns and 3 rows. I added a new column <code>t</code> and inserted the values in <code>vals</code> into <code>t</code>.</p> <pre><co...
-1
2016-08-11T19:21:27Z
38,904,567
<p>it does't look like you're inserting values into the column 't'.i'm assuming your table has 2 columns (id,t) Check your list on top which has </p> <pre><code>vals = [(1,), (2,), (3,)] </code></pre> <p>perhaps that's the problem. Could you elaborate a little more?</p>
0
2016-08-11T19:24:34Z
[ "python", "sqlite3" ]
Python, reading ID3 tags from m4a files
38,904,591
<p>I have a large collection of m4a files, all with ID3 tags for genre, artist, and titles. What I would like is to be able to read these tags and store them as strings. </p>
0
2016-08-11T19:26:11Z
38,904,773
<p>For such common tasks, ready-made libraries almost always exist. A quick Google search for <code>python m4a</code> yields:</p> <ul> <li><a href="http://mutagen.readthedocs.io/en/latest/" rel="nofollow">Mutagen</a></li> <li><a href="https://github.com/devsnd/tinytag" rel="nofollow">tinytag</a></li> </ul>
0
2016-08-11T19:36:53Z
[ "python", "id3", "m4a" ]
Multi-processing... Running 2 scripts on 2 terminals
38,904,646
<p>I have 2 scripts that start multiple processes. Right now I'm opening up two different terminals and running python start.py to start both the scripts. How can I achieve this with one command, or one running one script.</p> <p>Start.py 1</p> <pre><code># globals my_queue = multiprocessing.Manager().Queue() # queue...
0
2016-08-11T19:28:49Z
38,905,089
<p>You can run the first script in the background on the same terminal, using the <code>&amp;</code> shell modifier.</p> <pre><code>python start.py &amp; python start1.py </code></pre>
1
2016-08-11T19:58:33Z
[ "python", "multiprocessing" ]
Why not run uwsgi instances as root
38,904,656
<p>I am reading through the uWSGI documentation and it warns to <em><a href="https://uwsgi-docs.readthedocs.io/en/latest/WSGIquickstart.html#security-and-availability" rel="nofollow">always avoid running your uWSGI instances as root</a></em>. What is the reason behind this?</p> <p>Does it matter if it is the only proc...
0
2016-08-11T19:29:09Z
38,904,680
<p>In general, security reasoning says that running as root as bad. If there were any kind of bug, for example a code execution bug that can allow anybody to execute arbitrary code they would be able to destroy your entire system. </p> <p>If you don't run the process as root, any code execution vulnerabilities would n...
1
2016-08-11T19:31:06Z
[ "python", "nginx", "docker", "uwsgi" ]
Error reformatting string conditionally
38,904,775
<p>I had this subsection of my application working yesterday, and I can't seem to find out why it's not working now.</p> <p>Here's what it should do:</p> <p>Input: <code>10th ave 501</code></p> <p>Output: <code>501 10th ave</code></p> <p>This block of code is supposed to search for one of the target words in a list...
-1
2016-08-11T19:37:10Z
38,904,930
<p><code>'10th'.isdigit()</code> is <code>False</code> since:</p> <blockquote> <p>Return true if <strong>all</strong> characters in the string are digits (<a href="https://docs.python.org/3/library/stdtypes.html#str.isdigit" rel="nofollow">source</a>)</p> </blockquote> <p>If you wish, you can check only the first c...
0
2016-08-11T19:47:30Z
[ "python" ]
What does Python's io.open() use as the default separator?
38,904,799
<p>So I have a code that's trying to get all lines of a text file inside <code>message</code>, by doing this:</p> <pre><code>inbody = False lines = [] f = io.open(path, 'r', encoding='latin1') for line in f: if inbody: lines.appned(line) elif line == '\n': inbody = True f.close() message = '\n'...
-1
2016-08-11T19:38:27Z
38,904,824
<p>From <a href="https://docs.python.org/2/library/io.html#io.IOBase.readline" rel="nofollow">https://docs.python.org/2/library/io.html#io.IOBase.readline</a>:</p> <blockquote> <p>The line terminator is always b'\n' for binary files; for text files, the newline argument to open() can be used to select the line t...
1
2016-08-11T19:40:15Z
[ "python", "io" ]
What does Python's io.open() use as the default separator?
38,904,799
<p>So I have a code that's trying to get all lines of a text file inside <code>message</code>, by doing this:</p> <pre><code>inbody = False lines = [] f = io.open(path, 'r', encoding='latin1') for line in f: if inbody: lines.appned(line) elif line == '\n': inbody = True f.close() message = '\n'...
-1
2016-08-11T19:38:27Z
38,904,994
<p>From <a href="https://docs.python.org/2/library/io.html#io.open" rel="nofollow">https://docs.python.org/2/library/io.html#io.open</a>:</p> <blockquote> <p>On input, if newline is None, universal newlines mode is enabled. Lines in the input can end in '\n', '\r', or '\r\n', and these are translated into '\n' befor...
0
2016-08-11T19:51:36Z
[ "python", "io" ]
Python flask Auto Redirect message
38,904,957
<p>I have defined multplie service urls , all of which will execute same code.</p> <pre><code>@service.route('/get_info/env=&lt;path:env&gt;/starttime=&lt;int:starttime&gt;/endtime=&lt;int:endtime&gt;/entire=&lt;entire&gt;/over=&lt;over&gt;/stage=&lt;stage&gt;', defaults={'name': None}, strict_slashes=False) @service....
0
2016-08-11T19:49:31Z
38,905,469
<p>The way you construct the route is not really clean. GET request with arguments should take the format of <a href="http://server/route?arg1=val1&amp;arg2=val2&amp;" rel="nofollow">http://server/route?arg1=val1&amp;arg2=val2&amp;</a>.. etc. I'm pretty sure some special character or some parsing issue is responsible o...
0
2016-08-11T20:22:58Z
[ "python", "redirect", "flask", "flask-restful" ]
How to display the decimal points in python
38,904,963
<p>I am trying to write a python script that divides two numbers and then stores the value of the first digit after the decimal point but first I want to print the answer of the division. example: 31/7 should be 4,428 but when I use </p> <pre><code>def spiel(): anzahl=int(raw_input("Anzahl der Spieler")) spiel...
0
2016-08-11T19:49:53Z
38,905,007
<p>You're dividing an int by an int. You should use floats</p> <pre><code>def spiel(): anzahl=float(raw_input("Anzahl der Spieler")) spieler=float(raw_input("Jeder wievielte spielt")) if anzahl&gt;0 and spieler&gt;0: #Quotient berechnen q=anzahl/spieler print '%.2f'%q </code></pre> <p>In r...
0
2016-08-11T19:52:34Z
[ "python", "python-2.7", "floating-point" ]
How to display the decimal points in python
38,904,963
<p>I am trying to write a python script that divides two numbers and then stores the value of the first digit after the decimal point but first I want to print the answer of the division. example: 31/7 should be 4,428 but when I use </p> <pre><code>def spiel(): anzahl=int(raw_input("Anzahl der Spieler")) spiel...
0
2016-08-11T19:49:53Z
38,905,052
<p>In python2.7: If you divide two integer, answer will be integer always as it will skip the decimal value.</p> <p>If you want precise float output, try this:</p> <pre><code>&gt;&gt;&gt;float(10)/3 &gt;&gt;&gt;3.3333333333333335 </code></pre> <p>Any of the value should be float.</p>
0
2016-08-11T19:56:00Z
[ "python", "python-2.7", "floating-point" ]
How to display the decimal points in python
38,904,963
<p>I am trying to write a python script that divides two numbers and then stores the value of the first digit after the decimal point but first I want to print the answer of the division. example: 31/7 should be 4,428 but when I use </p> <pre><code>def spiel(): anzahl=int(raw_input("Anzahl der Spieler")) spiel...
0
2016-08-11T19:49:53Z
38,905,282
<p>The thing that you are doing wrong here is, you are making it believe that operands of division are integers( during division) .</p> <p>I am sure you want to take two integers. You can do following things:</p> <ol> <li><p>use float() during division. In here you do not need to convert both Anzahl and spieler to fl...
0
2016-08-11T20:11:24Z
[ "python", "python-2.7", "floating-point" ]
How to display the decimal points in python
38,904,963
<p>I am trying to write a python script that divides two numbers and then stores the value of the first digit after the decimal point but first I want to print the answer of the division. example: 31/7 should be 4,428 but when I use </p> <pre><code>def spiel(): anzahl=int(raw_input("Anzahl der Spieler")) spiel...
0
2016-08-11T19:49:53Z
38,906,078
<p>If you divide an integer by an integer you will receive an integer. An integer is a whole number, no decimal points.</p> <p>If you divide a float/integer by a float you will receive a float. A float is a whole number, including decimal points.</p> <p>When you are doing your operations, change <code>spieler</code> ...
0
2016-08-11T21:01:17Z
[ "python", "python-2.7", "floating-point" ]
pygame-How to replace an image with an other one
38,904,986
<p>I have this sort of code:</p> <pre><code>width = 100 height = 50 gameDisplay.blit(button, (width, height)) pygame.display.update() while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONUP and event.button == 1: # replace the button's image with another </code></pre>...
0
2016-08-11T19:51:23Z
38,905,297
<p>To show changes on screen use <code>pygame.display.update()</code>.</p> <p>Your code should look like this</p> <pre><code>width = 100 height = 50 gameDisplay.blit(button, (width, height)) while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONUP and event.button == 1: ...
0
2016-08-11T20:12:54Z
[ "python", "python-3.x", "pygame" ]
pygame-How to replace an image with an other one
38,904,986
<p>I have this sort of code:</p> <pre><code>width = 100 height = 50 gameDisplay.blit(button, (width, height)) pygame.display.update() while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONUP and event.button == 1: # replace the button's image with another </code></pre>...
0
2016-08-11T19:51:23Z
38,907,531
<p>You cannot 'replace' anything you've drawn. What you do is that you draw new images over the existing ones. Usually, you clear the screen and redraw your images every loop. Here's pseudo-code illustrating what a typical game loop looks like. I'll use <em>screen</em> as variable name instead of <em>gameDisplay</em>, ...
1
2016-08-11T23:17:58Z
[ "python", "python-3.x", "pygame" ]
Python error with lambda and alphanumeric words
38,905,074
<p>I am really new to python and now I am having an error and do not know why I get this error.</p> <p>I have 3 lists with words. The lists contains words numeric, literal words and alphanumeric words. These lists are saved in an txt file. Each file can contain words from other lists or new words.</p> <p>Now I like ...
0
2016-08-11T19:57:34Z
38,906,299
<p><code>partition</code> on <code>' '</code> or any other string for that matter will not extract the numeral part of the string except you know the character immediately following the numeral; very unlikely. </p> <p>You can instead use a regular expression to extract the leading numeral part of the string:</p> <pre...
0
2016-08-11T21:17:41Z
[ "python", "python-3.x", "lambda" ]
Xpath combine two treepaths
38,905,108
<p>I have two calls:</p> <pre><code>teamName = tree.xpath('//span[@class="name matchwinner"]/text()') teamMatch = tree.xpath('//a[@class="match"]/@href') </code></pre> <p>At the moment i get two arrays, one with team names and one with hrefs. Is there a way to get something like [team1, href1, team2, href2]? </p>
1
2016-08-11T20:00:32Z
38,905,173
<p>I suspect each team names and team matches share the same parent. If this is the case, you can do something like:</p> <pre><code>for team in tree.xpath("//div[@class='game']"): teamName = team.xpath('.//span[@class="name matchwinner"]/text()')[0] teamMatch = team.xpath('.//a[@class="match"]/@href')[0] ...
0
2016-08-11T20:04:36Z
[ "python", "xpath" ]
Nothing happens at a part of my script where there should be calculations
38,905,118
<p>I just started programming with python 3.5 and in this first program that I am making nothing happens at this part of the program:</p> <pre><code> def gender(): var2 = input ("What is your gender? ") v1 = int (var4) v2 = int (var5) guyheight = v1+v2+13 girlhiehgt = v1+v2-13 v4 = guyhei...
-1
2016-08-11T20:01:02Z
38,905,982
<p>This answer is based on my guess that <code>gender()</code> is this entire function and you want it to repeat at the end if a valid answer is not given. Try the formatting below.</p> <pre><code>def gender(): # There's obviously some code up here that eventually gives us var1 - var5 # I'll assume var2 is an ...
-1
2016-08-11T20:55:10Z
[ "python", "python-3.x" ]
Retrieving RDS tags using boto3 gives an index error.
38,905,131
<p>I am trying to retrieve a tags using boto3 but I constantly run into the ListIndex out of range error.</p> <p>My Code: </p> <pre><code>rds = boto3.client('rds',region_name='us-east-1') rdsinstances = rds.describe_db_instances() for rdsins in rdsinstances['DBInstances']: rdsname = rdsins['DBInstanceIdentifi...
0
2016-08-11T20:01:48Z
38,906,281
<p>You should iterate over list of tags first and compare <code>MyTag</code> with each item independently: something like that:</p> <pre><code> if 'MyTag' in [tag['Key'] for tag in rdstags['TagList']]: print "Tags exist and.........." </code></pre> <p>or better:</p> <pre><code>for tag in rdstags['TagList']: ...
0
2016-08-11T21:16:11Z
[ "python", "amazon-web-services", "boto3", "aws-rds" ]
How to remove first occurrence in string repeatedly python?
38,905,216
<p>I am not sure how to continously change the first occurance in a list. For instance, I will have a list of numbers </p> <pre><code>import numpy as np test=np.array([np.nan,np.nan,1,1,1,np.nan,1,1]) </code></pre> <p>Which gives me an output of </p> <pre><code>array([ nan, nan, 1., 1., 1., nan, 1., 1.])...
0
2016-08-11T20:06:56Z
38,905,248
<p>You could do something like this -</p> <pre><code>idx = np.diff(np.append(False,(test==1)).astype(int))==1 test[idx] = np.nan </code></pre> <p><strong>Sample runs</strong></p> <p>1) Sample case from posted question -</p> <pre><code>In [80]: test Out[80]: array([ nan, nan, 1., 1., 1., nan, 1., 1.]) I...
1
2016-08-11T20:09:16Z
[ "python", "list", "numpy" ]
How to remove first occurrence in string repeatedly python?
38,905,216
<p>I am not sure how to continously change the first occurance in a list. For instance, I will have a list of numbers </p> <pre><code>import numpy as np test=np.array([np.nan,np.nan,1,1,1,np.nan,1,1]) </code></pre> <p>Which gives me an output of </p> <pre><code>array([ nan, nan, 1., 1., 1., nan, 1., 1.])...
0
2016-08-11T20:06:56Z
38,905,573
<p>You can take advantage of the fact that <code>nan</code> times anything is <code>nan</code>.</p> <pre><code>import numpy as np test=np.array([np.nan,np.nan,1,1,1,np.nan,1,1]) test[1:] *= test[:-1] test[0] = np.nan print test # [ nan nan nan 1. 1. nan nan 1.] </code></pre>
1
2016-08-11T20:29:07Z
[ "python", "list", "numpy" ]
parameterizing a query in Postgres using Python
38,905,241
<p>I am having a bit of trouble parameterizing a sql query with python. Don't exactly know why this error is happening... if the tuple has two members and i am using two parameters in the sql, how am i getting an off by one error?</p> <p>error message:</p> <pre><code>File "...\app.py", line 27, in main rows = User.da...
1
2016-08-11T20:08:45Z
38,905,667
<p>Escape the <code>%</code> characters with one more <code>%</code></p> <pre><code>and c.cust_name ilike '%%_bar' and c.baz not ilike 'test%%' """ </code></pre>
1
2016-08-11T20:35:36Z
[ "python", "postgresql", "psycopg2" ]
Is it possible to get the contents of an S3 file without downloading it using boto3?
38,905,291
<p>I am working on a process to dump files from a <code>Redshift</code> database, and would prefer not to have to locally download the files to process the data. I saw that <code>Java</code> has a <code>StreamingObject</code> class that does what I want, but I haven't seen anything similar in <code>boto3</code>.</p>
0
2016-08-11T20:12:15Z
38,910,315
<p>If you have a <code>mybucket</code> S3 bucket, which contains a <code>beer</code> key, here is how to download and fetch the value without storing it in a local file:</p> <pre><code>import boto3 s3 = boto3.resource('s3') print s3.Object('mybucket', 'beer').get()['Body'].read() </code></pre>
1
2016-08-12T05:06:09Z
[ "python", "amazon-s3", "boto3" ]
Find 1D array from 2D NumPy arrays?
38,905,322
<p>Suppose I have </p> <pre><code>[[array([x1, y1]), z1] [array([x2, y1]), z2] ...... [array([xn, yn]), zn] ] </code></pre> <p>And I want to find the index of <code>array([x5, y5])</code>. How can find effieciently using NumPy?</p>
0
2016-08-11T20:14:34Z
38,905,692
<p>To start off, owing to the mixed data format, I don't think you can extract the arrays in a vectorized manner. Thus, you can use <code>loop comprehension</code> to extract the first element corresponding to the arrays from each list element as a <code>2D</code> array. So, let's say <code>A</code> is the input list, ...
0
2016-08-11T20:37:54Z
[ "python", "python-2.7", "numpy" ]
How to verify that the repeated output has same sets of lines and no extra line present in it
38,905,370
<p>I have number of repeated lines in output (which is pre-defined), from which I need to verify that the output has fixed set of lines repeated and no extra lines are present in it.</p> <pre><code>&gt; ********************************** &gt; timestamp expected &gt; ********************************** &gt; &gt; *****...
-3
2016-08-11T20:17:11Z
38,905,455
<p>Build a simple class with a print method that formats your output, verifies its content (and throws and exception if not OK) and counts the two cases. To be honest from your question it is not clear what you already have at hand (do the lines come from anywhere else?, etc.)</p>
0
2016-08-11T20:22:00Z
[ "python", "regex", "python-2.7", "python-3.x" ]
How to verify that the repeated output has same sets of lines and no extra line present in it
38,905,370
<p>I have number of repeated lines in output (which is pre-defined), from which I need to verify that the output has fixed set of lines repeated and no extra lines are present in it.</p> <pre><code>&gt; ********************************** &gt; timestamp expected &gt; ********************************** &gt; &gt; *****...
-3
2016-08-11T20:17:11Z
38,905,481
<p>This is a <code>pseudo code</code>. I suggest to take an <code>empty dict</code>. then use a <code>counter</code>.</p> <pre><code>mystr = '''********************************** timestamp expected ********************************** ********************************** Error expected ********************************** ...
0
2016-08-11T20:23:26Z
[ "python", "regex", "python-2.7", "python-3.x" ]
Can I change the number of hidden nodes in my Deep Learning model instead of remaking the entire model?
38,905,396
<p>I'm trying a brute force grid search to find the optimal number of hidden nodes to have in my TensorFlow DeepLearning model. I'm not too concerned about how long the program will take but I've found that my program runs out of memory because of all the tf.variables it has to make. The code to build my model is as fo...
0
2016-08-11T20:18:19Z
38,964,221
<p>Even though this isn't a perfect answer, I managed to find a workaround. I wrote a shell script that gets a range of numbers based on my interval using the <em>seq starting_number increment ending_number</em> and fed each value into my python code as a command line parameter. This avoids the memory problem since eac...
0
2016-08-15T22:56:01Z
[ "python", "machine-learning", "out-of-memory", "tensorflow", "deep-learning" ]
Mac OS X linking .so file to dynamic library
38,905,527
<p>I'm trying to build a python package that is dependent on several libraries including boost, boost-python, and fftw. I am able to compile the package without any errors, but when I try to run the program with the <code>steme --help</code> command, I get an error:</p> <pre><code>2016-08-11 15:07:55,571:ERROR: Import...
0
2016-08-11T20:26:07Z
38,906,047
<p>Try to include <code>/usr/local/Cellar/boost-python/1.61.0/lib</code> in your path when you launch the binary. Something like</p> <pre><code>$ export PATH=$PATH:/usr/local/Cellar/boost-python/1.61.0/lib $ ./your-binary </code></pre> <p>The link to the library is there otherwise you could not have found it via <cod...
0
2016-08-11T20:58:56Z
[ "python", "c++", "osx", "boost" ]
How to use the POST method in web.py to update a table in a postgreSQL database?
38,905,537
<p>Here's my web.py code so far. I want to use my web server to update a table.</p> <pre><code>import web urls = ('/', 'Index') render = web.template.render('templates/') app = web.application(urls, globals()) web.config.debug = True db = web.database(dbn='postgres', db='my_db', user='postgres', pw='******', hos...
0
2016-08-11T20:26:26Z
38,930,985
<p>You can do the Postgres insertion as follows,</p> <pre><code>def POST(self): sequence_id = db.insert('test1', col1=5, col2=3) # insert(tablename, seqname=None, _test=False, **values) </code></pre> <p>Refer <a href="http://lost-theory.org/webpydocs/module-web.db.html" rel="nofollow">this</a> for more details.<...
0
2016-08-13T08:51:35Z
[ "python", "postgresql", "rest", "web.py" ]
Unit test C-generating python code
38,905,560
<p>I have a project which involves some (fairly simple) C-code generation as part of a build system. In essence, I have some version information associated with a project (embedded C) which I want to expose in my binary, so that I can easily determine what firmware version was programmed to a particular device for debu...
2
2016-08-11T20:27:53Z
38,919,890
<p>Thanks for the diagram! Since you are not testing for coverage, if it were me, I would just compile the generated C code and see if it worked :) . You didn't mention your toolchain, but in a Unix-like environment, <code>gcc &lt;whatever build flags&gt; -c generated-file.c || echo 'Oops!'</code> should be sufficien...
1
2016-08-12T14:00:11Z
[ "python", "c", "unit-testing", "auto-generate" ]
CSV.writer | Ensure first row in CSV is also last row
38,905,578
<p>This code is going through .KAP files on a shared drive and creating CSV's on my local drive consisting of only the coordinate pairs of lat/lon extisting within the .KAP files. </p> <p>Example of coordinate lines within a .KAP file </p> <pre><code>PLY/1,48.107478621032,-69.733975000000 PLY/2,48.163516399836,-70.03...
0
2016-08-11T20:29:28Z
38,905,945
<p>Just do some kind of check on the last row to see if it is the same as the first, and if not, add a copy of the first row to the end. Maybe something like</p> <pre><code>for i in range(len(currentFile)): row = currentfile[i] if(row.startswith('PLY')): col1, col2 = row.split(",")[1:] rows =...
0
2016-08-11T20:52:42Z
[ "python", "csv", "writer" ]
CSV.writer | Ensure first row in CSV is also last row
38,905,578
<p>This code is going through .KAP files on a shared drive and creating CSV's on my local drive consisting of only the coordinate pairs of lat/lon extisting within the .KAP files. </p> <p>Example of coordinate lines within a .KAP file </p> <pre><code>PLY/1,48.107478621032,-69.733975000000 PLY/2,48.163516399836,-70.03...
0
2016-08-11T20:29:28Z
38,956,644
<p>When I had time to do it I came up with this solution to my own question:</p> <pre><code>import os import zipfile import csv import glob currentPath = r"K:\BsbProd\BSBCHS\BSB_4_Release" for zip in glob.glob('{}/*.zip'.format(currentPath)): zf = zipfile.ZipFile(os.path.join(currentPath, zip), 'r') for each...
0
2016-08-15T14:06:03Z
[ "python", "csv", "writer" ]
Attribute Error in querying with Flask SQL Alchemy
38,905,712
<pre><code>from flask import Flask import requests from flask_sqlalchemy import SQLAlchemy from flask_migrate import Migrate app = Flask(__name__) db = SQLAlchemy(app) migrate = Migrate(app, db) app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql://root:@localhost/localDB' class MainResult(db.Model): __tablename__ = ...
0
2016-08-11T20:39:03Z
38,906,392
<p>When you use <code>get</code> you need to give it the primary key, in the case of your <code>IndividualResult</code> you've defined a composite primary key (a primary key made of multiple columns) so to query that you would need to specify those two columns:</p> <pre><code>print(IndividualResult.query.get(("03d4962...
0
2016-08-11T21:25:11Z
[ "python", "flask", "sqlalchemy" ]
python asyncio invalid syntax ubuntu
38,905,747
<p>On OS X, my code works fine. Trying the exact code out on ubuntu, I get a syntax error:</p> <pre><code>ubuntu@home:server$ python3 server.py File "server.py", line 39 async def hello(websocket, path): ^ SyntaxError: invalid syntax </code></pre> <p>I used <code>pip3 install asyncio</code> to insta...
1
2016-08-11T20:41:15Z
38,905,831
<p>You have different versions of python on your OS X machine and your ubuntu machine. </p> <p><a href="https://www.python.org/dev/peps/pep-0492/" rel="nofollow"><code>async def</code> syntax was added in python 3.5</a>. </p> <p>There's no hope of getting that syntax working on python 3.4. </p>
4
2016-08-11T20:46:01Z
[ "python", "python-3.x", "python-asyncio" ]
Unable to write multiple simultaneous filesinks from appsrc
38,905,859
<p>I'm having trouble saving from appsrc to filesink when I have multiple gstreamer processes running simultaneously. Only one of the gstreamer processes will write correctly while the others will all write nearly empty files. There appears to be write contention during the filesink operation.</p> <p>Note: I am using...
0
2016-08-11T20:47:51Z
38,911,821
<p>Too long for comment, and this can solve your problem if I am correct..</p> <p>Add queue before filesink:</p> <pre><code>appsrc format=3 name=app emit-signals=true do-timestamp=true is-live=true blocksize=4608000 max-bytes=0 caps=video/x-raw,format=BGR,width=1920,height=800 ! videoconvert ! video/x-raw,format=I420...
0
2016-08-12T07:01:40Z
[ "python", "multiprocessing", "gstreamer", "python-gstreamer" ]
How to make a Histogram from a sqldf in python
38,905,956
<p>I wrote the following SQL query in iPython notebook</p> <pre><code>q = """SELECT * FROM Northeast ORDER BY counted desc LIMIT 10""" display(sqldf(q)) df = pysqldf(q) plt.bar(df) plt.show() </code></pre> <p>I was trying to make a histogram of it but I keep getting errors about it need a high etc. I try it in dif...
0
2016-08-11T20:53:27Z
38,978,224
<p>The following script should help with what you are trying to do:</p> <pre><code>import pandas as pd from pysqldf import SQLDF import matplotlib.pyplot as plt ##Set up the sqldf function to query from the globals() variables sqldf = SQLDF(globals()) ##Since you're using ipython notebooks, put plots in line with th...
1
2016-08-16T14:56:59Z
[ "python", "plot", "histogram", "sqldf" ]
how do i install pip on python 3.5.2?
38,905,980
<p>i downloaded python 3.5.2, i am planning on making a keylogger i need to install pyhook and pywin but i dont know how. every body recommends me to install it by pip but i dont seem to have that module. i open up the idle and import pip, but it gives me the error message saying i dont have that module installed even ...
0
2016-08-11T20:55:03Z
38,906,073
<p>You need to make sure the <code>pip</code> executable is in your <code>%PATH%</code> variable. For me, the <code>pip</code> executable is located in the <code>Scripts</code> directory of my Python installation. That turned out to be <code>C:\Python34\Scripts</code>. So you should find out where this location is for ...
1
2016-08-11T21:00:32Z
[ "python" ]
how do i install pip on python 3.5.2?
38,905,980
<p>i downloaded python 3.5.2, i am planning on making a keylogger i need to install pyhook and pywin but i dont know how. every body recommends me to install it by pip but i dont seem to have that module. i open up the idle and import pip, but it gives me the error message saying i dont have that module installed even ...
0
2016-08-11T20:55:03Z
40,051,061
<p>I am using Python 3.4 and was getting the error that it didn't exist. I ran this upgrade and I can now import pyperclip which was one of the packages in that module.</p> <pre><code>C:\Python35-32\Scripts&gt;python -m pip install --upgrade pip </code></pre> <p>Output:</p> <pre><code>Collecting pip Downloading pi...
-1
2016-10-14T19:56:55Z
[ "python" ]
Trouble serving MEDIA and STATIC files of Django in Apache
38,905,997
<p>I am using Django 1.8, python 3.4.3 and Apache 2.4.7, I have tried a lot of configurations and I can't see what I'm doing wrong. When I was using debug mode everything but the images was running perfect, and I solved the images issue by using this on urls.py:</p> <pre><code>url(r'^media/(?P&lt;path&gt;.*)$', 'djang...
0
2016-08-11T20:55:57Z
38,910,630
<p>Thanks to the help of user @Nostalg.io (find him on the comments of the question) I have found a solution (well, he found it), there was a lot of bad configurations and permission errors.</p> <p>First of all, I was using 127.0.0.1:8000 to access to my application, and that was a DJango URL, that's why files weren't...
0
2016-08-12T05:33:55Z
[ "python", "django", "apache" ]
Tensorflow: How can I restore model for training? (Python)
38,906,100
<p>I want to train a cnn for 20000 steps. In the 100th step I want to save all variables and after that I want to re-run my code restoring model and starting from the 100th step. I am trying to make it work with tensorflow documentation: <a href="https://www.tensorflow.org/versions/r0.10/how_tos/variables/index.html" r...
0
2016-08-11T21:02:30Z
38,906,748
<p>Im stuck in something similar but maybe this <a href="https://github.com/tensorflow/tensorflow/issues/3340" rel="nofollow">link</a> can help you. Im new in tensorflow but i think you cant restore and fit without need to training again you model.</p>
0
2016-08-11T21:57:54Z
[ "python", "python-2.7", "machine-learning", "tensorflow" ]
Tensorflow: How can I restore model for training? (Python)
38,906,100
<p>I want to train a cnn for 20000 steps. In the 100th step I want to save all variables and after that I want to re-run my code restoring model and starting from the 100th step. I am trying to make it work with tensorflow documentation: <a href="https://www.tensorflow.org/versions/r0.10/how_tos/variables/index.html" r...
0
2016-08-11T21:02:30Z
38,907,570
<p>This functionality is still unstable , and the documentation is outdated so is confusing, what worked for me(this was a suggestion of people from google that works directly on tensorflow) was to use the model_dir parameter on the constructor of my models before training, in this you will tell where to store your mo...
0
2016-08-11T23:23:36Z
[ "python", "python-2.7", "machine-learning", "tensorflow" ]
How to make a copy of xml tree in python using ElementTree?
38,906,104
<p>I'm using xml.etree.ElementTree to parse xml file. I'm parsing xml file in the following way:</p> <pre><code>import xml.etree.ElementTree as ET tree = ET.parse(options.xmlfile) root = tree.getroot() </code></pre> <p>This is my xml file:</p> <pre><code>&lt;rootElement&gt; &lt;member&gt; &lt;member_id&...
0
2016-08-11T21:03:05Z
38,913,589
<p>You can create a copy of the <code>member</code> element and append it. Example:</p> <pre><code>import xml.etree.ElementTree as ET import copy tree = ET.parse("test.xml") root = tree.getroot() # Find element to copy member1 = tree.find("member") # Create a copy member2 = copy.deepcopy(member1) # Append the co...
1
2016-08-12T08:40:36Z
[ "python", "xml", "elementtree" ]
Bad input shape with sklearn make_scorer needs_proba=True
38,906,145
<p>The code below works fine with:<br> <code>scorer = make_scorer(roc_auc_score)</code></p> <p>but gives "ValueError: bad input shape" with:<br> <code>scorer = make_scorer(roc_auc_score, needs_proba = True)</code></p> <p>The code is:<br> <code>clf = GaussianNB() cv = ShuffleSplit(features.shape[0], n_iter = 10, test_...
0
2016-08-11T21:05:52Z
38,907,322
<p>If you're using one of the default scoring metrics you don't need to pass a callable to <code>cross_val_score</code>, you can just, you can just call it with the name of the metric you're using:</p> <pre><code>score = cross_val_score(clf, features, labels, cv=cv, scoring='roc_auc_score') </code></pre>
0
2016-08-11T22:56:59Z
[ "python", "machine-learning", "scikit-learn" ]
ValueError when using scipy least_squares
38,906,193
<p>I am trying to fit my data to a function. I've been using this sample code as a guide <a href="http://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html#example-of-solving-a-fitting-problem" rel="nofollow">http://docs.scipy.org/doc/scipy/reference/tutorial/optimize.html#example-of-solving-a-fitting-problem</...
0
2016-08-11T21:08:35Z
38,926,045
<p>The problem is:</p> <ul> <li>case A: your initial-point</li> <li>case B: your function <code>model</code></li> </ul> <p>Giving the start-point <code>x0 = np.array([0.1,0.2])</code> (and also <code>u,y</code>), calling <code>fun(x0, u, y)</code>, the following happens:</p> <pre><code>np.sqrt((x[1]/u) - 1) # part ...
2
2016-08-12T20:31:55Z
[ "python", "numpy", "scipy", "least-squares" ]
Create bigrams using NLTK from a corpus with multiple lines
38,906,263
<p>I am trying to generate bigrams from a corpus with multiple lines. Bigrams are created across line breaks which is a problem because each line represents it's own context and is not related to the subsequent line. That results in semantically incorrect bigrams.</p> <p><strong>The corpus</strong></p> <pre><code>Ree...
0
2016-08-11T21:14:25Z
38,906,307
<p>I would use <code>split</code> on '\n' to get a list of lines and process then every line separately and combine the list of bigrams</p>
0
2016-08-11T21:18:22Z
[ "python", "nltk" ]
Create bigrams using NLTK from a corpus with multiple lines
38,906,263
<p>I am trying to generate bigrams from a corpus with multiple lines. Bigrams are created across line breaks which is a problem because each line represents it's own context and is not related to the subsequent line. That results in semantically incorrect bigrams.</p> <p><strong>The corpus</strong></p> <pre><code>Ree...
0
2016-08-11T21:14:25Z
38,906,598
<p>I believe something like this should work:</p> <pre><code>finder = nltk.BigramCollocationFinder.from_documents([ nltk.word_tokenize(x) for x in corpus.split('\n')]) bigrams = finder.nbest(bigram_measures.likelihood_ratio, 100) </code></pre>
0
2016-08-11T21:44:27Z
[ "python", "nltk" ]
+= operation with non existing dataframes
38,906,297
<p><strong>df_pairs:</strong></p> <pre><code>city1 city2 0 sfo yyz 1 sfo yvr 2 sfo dfw 3 sfo ewr </code></pre> <p><strong>output of df_pairs.to_dict('records'):</strong></p> <pre><code>[{'city1': 'sfo', 'city2': 'yyz'}, {'city1': 'sfo', 'city2': 'yvr'}, {'city1': 'sfo', 'city2': 'dfw'}, {'city1': 'sfo',...
0
2016-08-11T21:17:27Z
38,907,008
<p>Why don't you simply do this:</p> <pre><code>df_city1 = pd.merge(df_pairs['city1'], data_df, left_on='city1', right_on='city', how='left') df_city2 = pd.merge(df_pairs['city2'], data_df, left_on='city2', right_on='city', how='left') diff = df_city2.subtract(df_city1, fill_value=0) pos_sum = diff[diff &gt;= 0].sum(a...
1
2016-08-11T22:22:04Z
[ "python", "pandas" ]
+= operation with non existing dataframes
38,906,297
<p><strong>df_pairs:</strong></p> <pre><code>city1 city2 0 sfo yyz 1 sfo yvr 2 sfo dfw 3 sfo ewr </code></pre> <p><strong>output of df_pairs.to_dict('records'):</strong></p> <pre><code>[{'city1': 'sfo', 'city2': 'yyz'}, {'city1': 'sfo', 'city2': 'yvr'}, {'city1': 'sfo', 'city2': 'dfw'}, {'city1': 'sfo',...
0
2016-08-11T21:17:27Z
38,907,402
<p>Give this a run:</p> <p>Take out the initial variables, and get rid of the for loop.</p> <pre><code>a = pd.merge(df_pairs, data_df, left_on='city1', right_on='city', how='left').set_index(['city1', 'city2']) b = pd.merge(df_pairs, data_df, left_on='city2', right_on='city', how='left').set_index(['city1', 'city2'])...
0
2016-08-11T23:04:42Z
[ "python", "pandas" ]
Download and save the file in python
38,906,310
<p>I'm downloading the file from my server using <code>urllib2.urlopen</code> method. I want to know how do you open the file and save it to a hard disk location in '/userdata/addon_data/script.tvguide'?</p> <p>Here is the code:</p> <pre><code>def All_Channels(self): global __killthread__ self.getControl(34...
0
2016-08-11T21:18:29Z
38,906,362
<p>For python 2.7 it is <code>urllib.urlretrieve(url,filename)</code> where <code>filename</code> is the place you want to store it.</p>
0
2016-08-11T21:22:54Z
[ "python", "python-2.7" ]
converting/analyzing .csv to xlsx file
38,906,323
<p>I am currently attempting to write a script that converts a .csv file to a .xlsx file, then do some data analysis on the new file. I am currently running into an error when trying to copy the new file i make.</p> <p>here is the error:</p> <pre><code> File "C:/Users/mmunoz/Desktop/Excel Analysis/danielaScript1.0.p...
0
2016-08-11T21:19:32Z
38,906,379
<p>xlutils.copy is a module.</p> <p>Try this:</p> <pre><code>from xlutils.copy import copy </code></pre> <p>then</p> <pre><code>workbookCopy = copy(workbook) </code></pre> <p>More info: <a href="http://xlutils.readthedocs.io/en/latest/copy.html" rel="nofollow">http://xlutils.readthedocs.io/en/latest/copy.html</a>...
0
2016-08-11T21:24:13Z
[ "python", "excel", "xlrd" ]
Jupyter Notebook: How to change spacing between Text objects inside HBox?
38,906,333
<p>Say I have the following code in a cell in the Jupyter Notebook:</p> <pre><code>from ipywidgets.widgets import HBox, Text from IPython.display import display text1 = Text(description = "text1", width = 100) text2 = Text(description = "text2", width = 100) text3 = Text(description = "text3", width = 100) text4 = Te...
2
2016-08-11T21:20:24Z
38,908,772
<p>It seems that the spacing is due to the width of the <code>widget-text</code> class being specified with a width of 350 pixels. Try importing the <code>HTML</code> module (i.e. <code>from IPython.display import display, HTML</code>) and insert <code>HTML('&lt;style&gt; .widget-text { width: auto; } &lt;/style&gt;')<...
1
2016-08-12T02:08:07Z
[ "python", "jupyter", "ipywidgets" ]
Jupyter Notebook: How to change spacing between Text objects inside HBox?
38,906,333
<p>Say I have the following code in a cell in the Jupyter Notebook:</p> <pre><code>from ipywidgets.widgets import HBox, Text from IPython.display import display text1 = Text(description = "text1", width = 100) text2 = Text(description = "text2", width = 100) text3 = Text(description = "text3", width = 100) text4 = Te...
2
2016-08-11T21:20:24Z
38,912,027
<p>Building on Zarak's answer, you can do something like this</p> <pre><code>from ipywidgets.widgets import HBox, Text from IPython.display import display, HTML text1 = Text(description = "text1", width = 100) text2 = Text(description = "text2", width = 100) text3 = Text(description = "text3", width = 100) text4 = Te...
2
2016-08-12T07:14:44Z
[ "python", "jupyter", "ipywidgets" ]
newline feature of print command in Python
38,906,355
<p>I am teaching myself how to program in Python, and I have a question about "print".</p> <p>I know that print statement has a newline "\n" feature embedded into it, but I noticed that whenever my code ends with a print statement, for example, print("This is the end"), it does not create a newline.</p> <p>Is it a f...
0
2016-08-11T21:22:02Z
38,906,461
<p>No, Python has no such feature. You might be confusing "not printing a newline" with "not ending with a blank space".</p> <p>For example, in bash, it might look like this:</p> <pre><code>$ cat endline.py print('line 1') print('line 2') $ cat noendline.py print('line 1') print('line 2', end='') $ python3 endline.py...
4
2016-08-11T21:30:29Z
[ "python" ]
newline feature of print command in Python
38,906,355
<p>I am teaching myself how to program in Python, and I have a question about "print".</p> <p>I know that print statement has a newline "\n" feature embedded into it, but I noticed that whenever my code ends with a print statement, for example, print("This is the end"), it does not create a newline.</p> <p>Is it a f...
0
2016-08-11T21:22:02Z
38,906,469
<p>In python, a <code>\n</code> is added by <a href="https://www.python.org/dev/peps/pep-0278/" rel="nofollow">default</a>. You can specify what end argument you want concatenated to the end of your print statement in <strong><a href="https://docs.python.org/3/whatsnew/3.0.html#print-is-a-function" rel="nofollow">Pytho...
1
2016-08-11T21:31:21Z
[ "python" ]
How to clear form fields in class-based views after a submit in Django
38,906,421
<p>I use <strong>class-based views for password reset</strong> in my Django project. My form has only one field where users can write there email adress or username. After successfull submit users can see success message in the same page. My problem is that after the submit I see empty field but in the same time I can ...
0
2016-08-11T21:27:22Z
38,912,189
<p>First, never ever use global variables. </p> <p>Second, you can put your post logic into a <code>form.save()</code> method. IMO its is much more appropriate there and its close to what <code>Django</code> is doing inside its <a href="https://github.com/django/django/blob/master/django/contrib/auth/forms.py#L228" re...
1
2016-08-12T07:23:06Z
[ "python", "django", "python-3.x", "django-views", "reset-password" ]
Numerous XML documents: how can I capture occurrence and max length of text
38,906,437
<p>I have a large number of XML documents I need to loop over and capture how many times the a child node occurs and the max length of the field. I am able to properly parse the XML, and can capture the count and the length of the field. What I am unsure of is what datatype and method would be most effective to captu...
0
2016-08-11T21:28:53Z
38,906,779
<p>You should use a defaultdict that if the element does not exist resolves to the default value you specify (see the example below). On each iteration then all you'll have to do is:</p> <pre><code>max_length[child.tag] = max(max_length[child.tag], len(child.text)) </code></pre> <p>Full example:</p> <pre><code># Ne...
1
2016-08-11T22:00:19Z
[ "python", "xml", "python-3.x" ]
Returning multiple values in a FLASK response
38,906,448
<p>I have a FLASK response object that I am preparing with two string values as follows: </p> <pre><code>vioAllScript = encode_utf8(vioAllScript) vioAllDiv = encode_utf8(vioAllDiv) vioTup = (vioAllDiv, vioAllScript,) resp = make_response(vioTup) return resp </code></pre> <p>However, whenever I retrieve this response...
0
2016-08-11T21:29:32Z
38,906,553
<p>Unfortunately those flask interfaces are a bit too overloaded, which can be confusing, but if you dig in the relevant <a href="http://flask.pocoo.org/docs/0.11/api/#flask.Flask.make_response" rel="nofollow">docs</a> you will find this part:</p> <blockquote> <p>A tuple in the form (response, status, headers) or (r...
0
2016-08-11T21:39:42Z
[ "python", "flask", "response" ]
Bundle Cython module with a Python package
38,906,482
<p>I'm wrapping a C++ library in Cython, and I would like to distribute this as a Python package. I've been using <a href="http://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html" rel="nofollow">this tutorial</a> as a guide.</p> <p>Here is how things are organized.</p> <pre><code>. ├── inc ...
0
2016-08-11T21:32:20Z
38,906,589
<p>Your import statement acts on <code>__init__.py</code> which is probably empty But what your setup script should create is an <code>.so</code> file. Thus you have to run it not with <code>install</code> but with <code>build_ext</code> (and <code>--inplace</code>) which gives you the <code>.so</code> file that can be...
0
2016-08-11T21:43:26Z
[ "python", "cython", "packaging" ]
Bundle Cython module with a Python package
38,906,482
<p>I'm wrapping a C++ library in Cython, and I would like to distribute this as a Python package. I've been using <a href="http://cython.readthedocs.io/en/latest/src/userguide/wrapping_CPlusPlus.html" rel="nofollow">this tutorial</a> as a guide.</p> <p>Here is how things are organized.</p> <pre><code>. ├── inc ...
0
2016-08-11T21:32:20Z
38,907,323
<p>In this case, the problem turned out to be that the <code>.pyx</code> file and the extension did not have the same basename. When I renamed <code>wrapper.pyx</code> to <code>Rectangle</code> and re-installed I was able to run the following in the Python interpreter.</p> <pre><code>&gt;&gt;&gt; import Rectangle &gt;...
0
2016-08-11T22:57:01Z
[ "python", "cython", "packaging" ]
how to find the complement of two dataframes
38,906,513
<p>given two large dataframes, is there any concise and efficient code (avoid using any <code>for loop</code> directly) that allow me to obtain the complement of these two dataframes? </p> <p>the most straight forward way to me is to compute <code>union-intersection</code> as shown in the naive example below, but I do...
2
2016-08-11T21:35:36Z
38,906,805
<p>Starting with this:</p> <pre><code>df1= pd.DataFrame({'key1': ['K0', 'K0', 'K1', 'K2'], 'key2': ['K0', 'K1', 'K0', 'K1'], 'A': ['A0', 'A1', 'A2', 'A3'], 'B': ['B0', 'B1', 'B2', 'B3']}) df2= pd.DataFrame({'key1': ['K0', 'K1', 'K1', 'K2'], ...
2
2016-08-11T22:02:53Z
[ "python", "pandas", "join", "merge" ]
django tutorial: where does question_id come from?
38,906,576
<p>So I am trying to learn django and following this tutorial: <a href="https://docs.djangoproject.com/en/1.10/intro/tutorial01/" rel="nofollow">https://docs.djangoproject.com/en/1.10/intro/tutorial01/</a></p> <p>After following the tutorial and made the poll app, when I look back and look into the code, I just don't ...
0
2016-08-11T21:41:31Z
38,906,662
<p>In your <code>urlpatterns</code> list in <code>urls.py</code> you have this route:</p> <pre><code>url(r'^(?P&lt;question_id&gt;[0-9]+)/vote/$', views.vote, name='vote') </code></pre> <p>The url is actually a regex, so one string to specify a whole family of urls.<br> The <code>question_id</code> is a named part of...
0
2016-08-11T21:49:46Z
[ "python", "django" ]
django tutorial: where does question_id come from?
38,906,576
<p>So I am trying to learn django and following this tutorial: <a href="https://docs.djangoproject.com/en/1.10/intro/tutorial01/" rel="nofollow">https://docs.djangoproject.com/en/1.10/intro/tutorial01/</a></p> <p>After following the tutorial and made the poll app, when I look back and look into the code, I just don't ...
0
2016-08-11T21:41:31Z
38,906,667
<ol> <li>Your statement is true you might want to take a look at the relevant Documentation for Django Models here: <a href="https://docs.djangoproject.com/en/1.10/topics/db/models/#automatic-primary-key-fields" rel="nofollow">https://docs.djangoproject.com/en/1.10/topics/db/models/#automatic-primary-key-fields</a></li...
0
2016-08-11T21:49:58Z
[ "python", "django" ]
Unable to run scrypt with Python 3.5
38,906,610
<p>After applying the recommended changes to the setup files (listed <a href="https://bitbucket.org/mhallin/py-scrypt/issues/23/scrypt-for-python-35" rel="nofollow">here</a>), I successfully installed Scrypt on Python 3.5. But I can't figure out how to actually get it to run or to pass its own tests. It complains that ...
0
2016-08-11T21:45:33Z
38,928,070
<p>After using Process Monitor to track the activity of Scrypt on my working desktop and my non-working laptop, I discovered that it wanted OpenSSL's libeay32.dll. In the beginning, I had chosen to install its DLLs in the /bin directory but, unfortunately, Scrypt doesn't check there. After reinstalling OpenSSL and choo...
0
2016-08-13T00:31:12Z
[ "python", "python-3.x", "python-3.5", "scrypt" ]
How do I have Splinter to iterate clicks on dropdown menu with python?
38,906,620
<p>I am trying to gather some yearly stats from <a href="http://www.atpworldtour.com/en/stats" rel="nofollow">http://www.atpworldtour.com/en/stats</a></p> <p>The years are on dropdown menu (default selection is 52-weeks). I succeeded at opening the drop down menu, but my code does not select any year.</p> <pre><code>...
0
2016-08-11T21:46:18Z
38,952,680
<p>This should work</p> <pre><code>browser.find_by_id("52weeks").first.click() browser.find_by_id("2010").first.click() </code></pre>
0
2016-08-15T09:38:09Z
[ "python", "web-scraping" ]
pd.DataFrame() fails when combining 2 lists
38,906,645
<p>I have 2 lists like below while my lists actually have 3000 elements:</p> <pre><code>a=[numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800')] b=[1,2,3] </code></pre> <p>When I tried to combine them to fo...
2
2016-08-11T21:48:08Z
38,906,724
<p>Try:</p> <pre><code>c = pd.DataFrame(data={'a':a,'b':b}) </code></pre> <p>You're getting the error because you are trying to create a pandas dataframe by putting two lists together into one column, while the data types of the elements in those lists don't match. Basically, you're trying to put dates and integers i...
3
2016-08-11T21:55:29Z
[ "python", "pandas", "dataframe" ]
pd.DataFrame() fails when combining 2 lists
38,906,645
<p>I have 2 lists like below while my lists actually have 3000 elements:</p> <pre><code>a=[numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800')] b=[1,2,3] </code></pre> <p>When I tried to combine them to fo...
2
2016-08-11T21:48:08Z
38,906,787
<p>This should work without using a dictionary: </p> <pre><code>c = pd.DataFrame([a, b]).T print c </code></pre>
1
2016-08-11T22:01:13Z
[ "python", "pandas", "dataframe" ]
pd.DataFrame() fails when combining 2 lists
38,906,645
<p>I have 2 lists like below while my lists actually have 3000 elements:</p> <pre><code>a=[numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800')] b=[1,2,3] </code></pre> <p>When I tried to combine them to fo...
2
2016-08-11T21:48:08Z
38,906,794
<pre><code>import pandas as pd import numpy as np data = { 'a': [ np.datetime64('2004-04-12T08:00:00.000000000+0800'), np.datetime64('2004-04-12T08:00:00.000000000+0800'), np.datetime64('2004-04-12T08:00:00.000000000+0800') ], 'b': [1, 2, 3] } df = pd.DataFrame(data) print df </cod...
2
2016-08-11T22:01:40Z
[ "python", "pandas", "dataframe" ]
pd.DataFrame() fails when combining 2 lists
38,906,645
<p>I have 2 lists like below while my lists actually have 3000 elements:</p> <pre><code>a=[numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800'),numpy.datetime64('2004-04-12T08:00:00.000000000+0800')] b=[1,2,3] </code></pre> <p>When I tried to combine them to fo...
2
2016-08-11T21:48:08Z
38,906,902
<p>try this: </p> <pre><code>import pandas as pd pd.DataFrame(zip(a,b)) 0 1 0 2004-04-12 1 1 2004-04-12 2 2 2004-04-12 3 </code></pre>
1
2016-08-11T22:12:06Z
[ "python", "pandas", "dataframe" ]
Office 365 API - Create Event With Attachment
38,906,663
<p>I am using the Python script below to create event for Office 365 and it works. However, I have a tough time (googling all day) to find out how can I also include the attachment with the event that is being generated from this script below. </p> <p>This below code works for creating the event.</p> <pre><code># Set...
0
2016-08-11T21:49:47Z
38,908,584
<p>To create attachment for the event, we need send another request. Here is the description for <a href="https://msdn.microsoft.com/en-us/office/office365/api/calendar-rest-operations#create-attachments" rel="nofollow">creating the attachment</a> for the exist event.</p> <p><a href="http://i.stack.imgur.com/kTe6H.png...
1
2016-08-12T01:44:07Z
[ "python", "office365" ]
MaxPlus Python - 3Ds Max - Add Worldspace Modifier
38,906,782
<p>I'm trying to learn MaxPlus/Python in 3Ds Max, and I am stuck with creating a worldspace modifier. (Path Deform Binding WSM modifier)</p> <pre><code>mod = MaxPlus.Factory.CreateWorldSpaceModifier(MaxPlus.ClassIds.PathDeformSpaceWarp) MaxPlus.ModifierPanel.AddToSelection(mod) </code></pre> <p>Above code gives the f...
1
2016-08-11T22:00:42Z
38,911,802
<p>Close enough, here you go:</p> <pre><code>mod = MaxPlus.Factory.CreateWorldSpaceModifier(MaxPlus.Class_ID(0x000110b4, 0x00007f9e)) MaxPlus.ModifierPanel.AddToSelection(mod) </code></pre> <p>Apart from looking for #define in the SDK, you can get the classIDs by getting the classID property of existing object, for e...
0
2016-08-12T07:00:20Z
[ "python", "3dsmax" ]
How to retrieve data within an a href tag
38,906,797
<p>Hey all i've stumbled across some difficulties whilst web crawling. I am trying to obtain the 70 in this chunk of code embedded in the middle of some html, my question is how would i go about doing so.I've tried various methods but none seem to work. I'm using the BeautifulSoup module and writing in Python 3.The lin...
1
2016-08-11T22:01:46Z
38,906,891
<pre><code>from bs4 import BeautifulSoup import re import requests soup = BeautifulSoup(text,"html.parser") for link in soup.find("a") temp = link.find("span",{"class" : "temp"}) print(re.findall(r"[0-9]{1,2}",temp.text)) </code></pre> <p>I hope this helps you</p>
-1
2016-08-11T22:11:06Z
[ "python", "beautifulsoup", "web-crawler", "href" ]
How to retrieve data within an a href tag
38,906,797
<p>Hey all i've stumbled across some difficulties whilst web crawling. I am trying to obtain the 70 in this chunk of code embedded in the middle of some html, my question is how would i go about doing so.I've tried various methods but none seem to work. I'm using the BeautifulSoup module and writing in Python 3.The lin...
1
2016-08-11T22:01:46Z
38,907,043
<p>Assuming using <code>BeautifulSoup</code> is not a strict requirement, you could do this with the <code>html.parser</code> module. The below is custom designed for the use-case you have mentioned. It fetches both the data fields and then filters out the number.</p> <pre><code>from html.parser import HTMLParser cl...
0
2016-08-11T22:26:25Z
[ "python", "beautifulsoup", "web-crawler", "href" ]
How to retrieve data within an a href tag
38,906,797
<p>Hey all i've stumbled across some difficulties whilst web crawling. I am trying to obtain the 70 in this chunk of code embedded in the middle of some html, my question is how would i go about doing so.I've tried various methods but none seem to work. I'm using the BeautifulSoup module and writing in Python 3.The lin...
1
2016-08-11T22:01:46Z
38,907,108
<p>This will get you any spans containing a temperature</p> <pre><code>temps = soup.find_all('span',{'class':'temp'}) </code></pre> <p>Then loop over it</p> <pre><code>for span in temps: temp = span.decode_contents() # temp looks like "70&amp;deg" or "70\xb0" so parse it print int(temp[:-1]) </code></pr...
0
2016-08-11T22:31:58Z
[ "python", "beautifulsoup", "web-crawler", "href" ]
How to retrieve data within an a href tag
38,906,797
<p>Hey all i've stumbled across some difficulties whilst web crawling. I am trying to obtain the 70 in this chunk of code embedded in the middle of some html, my question is how would i go about doing so.I've tried various methods but none seem to work. I'm using the BeautifulSoup module and writing in Python 3.The lin...
1
2016-08-11T22:01:46Z
38,907,252
<p>You need to add a user-agent to get the correct source, then select using the tag/class names you want:</p> <pre><code>from bs4 import * import requests headers = {"user-agent":"Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.82 Safari/537.36"} data = requests.get("http://www...
0
2016-08-11T22:49:06Z
[ "python", "beautifulsoup", "web-crawler", "href" ]
converting pyspark dataframe to labelled point object
38,906,803
<pre><code>df: [Row(split(value,,)=[u'21.0', u'1',u'2']),Row(split(value,,)=[u'22.0', u'3',u'4'])] </code></pre> <p>how to convert each row in df into a <code>LabeledPoint</code> object, which consists of a label and features, where the first value is the label and the rest 2 are features in each row.</p> <pre><code>...
1
2016-08-11T22:02:40Z
38,916,771
<p>If you want to obtain an <code>RDD</code> you need to create a function to parse your <code>Array</code> of <code>String</code>.</p> <pre class="lang-py prettyprint-override"><code>a = sc.parallelize([([u'21.0', u'1',u'2'],),([u'22.0', u'3',u'4'],)]).toDF(["value"]) a.printSchema() #root #|-- value: array (nulla...
3
2016-08-12T11:21:50Z
[ "python", "apache-spark", "pyspark", "apache-spark-mllib", "pyspark-sql" ]
pyqtgraph facilities to pcolor plot llike matplotlib
38,906,862
<p>Is there any possibility to plot pcolor in pyqtplot, like the ones matplotlib can ? and Is there any good example ?<br> How we can add axis to pyqtgraph plot? </p>
0
2016-08-11T22:08:10Z
38,908,121
<p>Try this to get started:</p> <pre><code>import pyqtgraph as pg x = [1, 2, 3, 4, 5] y = [1, 4, 9, 16, 25] pg.plot(x, y, title="Simple Example", labels={'left': 'Here is the y-axis', 'bottom': 'Here is the x-axis'}) </code></pre> <p>I looked at the documentation <a href="http://www.pyqtgraph.org/documentation/graph...
0
2016-08-12T00:35:35Z
[ "python", "matplotlib", "pyqtgraph" ]
Configuring Pycharm to use Python 1.5.2+
38,906,879
<p>I have to write an application for a GSM Modem from Telit that uses Python 1.5.2+</p> <p>I have been using PyCharm CE only as an editor for my code but debugging and testing my code directly on modem hardware.</p> <p>I've tried to configure my project to use Python 1.5.2+ and PyCharm calls it as "Unknown" as seen ...
1
2016-08-11T22:09:32Z
39,332,974
<p>The eldest Python, which PyCharm <a href="https://www.jetbrains.com/help/pycharm/2016.1/supported-languages.html" rel="nofollow">supports</a>, is 2.4.</p>
1
2016-09-05T14:40:29Z
[ "python", "pycharm", "gsm", "modem", "gprs" ]
Python subprocess stdout.readlines() getting stuck
38,906,906
<p>I am trying to use to python subprocess module in order to ssh to a server and then switch to a super user and then ls and print the folders in the terminal.</p> <p>My Code:</p> <pre><code>def sudo_Test(): HOST = 'Host' PORT = '227' USER = 'user' cmd='sudo su - ec2-user;ls' process = subproces...
0
2016-08-11T22:12:36Z
38,907,042
<p>The problem is here:</p> <pre><code>sudo su - ec2-user;ls </code></pre> <p><code>sudo su - ec2-user</code> opens a shell and <em>waits</em> for input. You need to send the shell an exit command (or close its stdin) before the shell exits and the <code>ls</code> command is run.</p> <p><strong>If your goal was to ...
1
2016-08-11T22:26:20Z
[ "python", "linux", "bash", "subprocess", "sudo" ]
Represent 5 dim data with seaborn/matplotlib in scatter like plots
38,906,922
<p>Using seaborn lmplot with the hue option we can represent 3 dimensional data e.g. 3 variables: total_bill, tip and smoker:</p> <pre><code>&gt;&gt;&gt; import seaborn as sns; sns.set(color_codes=True) &gt;&gt;&gt; tips = sns.load_dataset("tips") &gt;&gt;&gt; g = sns.lmplot(x="total_bill", y="tip", hue='smoker', data...
0
2016-08-11T22:13:52Z
38,908,499
<p>You can represent up to five dimensions with faceting:</p> <pre><code>import seaborn as sns tips = sns.load_dataset("tips") sns.lmplot(x="total_bill", y="tip", hue="time", col="sex", row="smoker", size=3, data=tips) </code></pre> <p><a href="http://i.stack.imgur.com/9YGFp.png" rel="nofollow">...
1
2016-08-12T01:32:09Z
[ "python", "matplotlib", "seaborn" ]
File Server Upload Python
38,906,945
<p><strong>File Server Download Problem Python 2.5.1</strong></p> <p>So i am working on a File Server as a hobby project. I am having some problems though. I can use the client to successfully upload the file to the server but say the file to upload is 50,000 bytes (50 mbs) it will only upload like 49,945 bytes then i...
-2
2016-08-11T22:15:29Z
38,907,247
<p>You close the client connection on the server side, but never close it on the client side as <a href="http://stackoverflow.com/users/6061947/cory-shay">Cory Shay</a> said.<br> Instead of closing it though, you need to <code>shutdown</code> the socket and signal it is done writing with <a href="https://docs.python.or...
0
2016-08-11T22:48:36Z
[ "python", "file", "upload", "server", "client" ]
Generating new list of grouped items within a set
38,907,013
<p>I'm trying to figure out how to convert the following:</p> <pre><code>results = [(516L, u'dupe', u'dupe', 106L), (517L, u'dupe', u'dupe', 106L), (518L, u'testing', u'testing', 106L), (519L, u'testing', u'testing', 106L), (523L, u'duplicate', u'duplicate', 88L), (524L, u'duplicate', u'duplicate', 88L)] </code></pre>...
0
2016-08-11T22:22:33Z
38,907,052
<p>Almost there!</p> <pre><code>[list(v) for k,v in groupby(results, key=lambda x: x[2])] # ^ grouping key ^ 0-based index </code></pre> <p><strong>Output</strong>:</p> <pre><code>[(516L, u'dupe', u'dupe', 106L), (517L, u'dupe', u'dupe', 106L)], [(518L, u'testing', u'testing', 106...
2
2016-08-11T22:27:00Z
[ "python", "list-comprehension" ]
Read txt files sequentially using Python
38,907,054
<p>I have a problem reading txt files in order. I would like to read the files in the following order:</p> <pre><code>0.txt 1.txt 2.txt ... 10.txt 11.txt ... 19.txt 20.txt 21.txt ... </code></pre> <p>However, the following codes</p> <pre><code>import os path = "temp/" dirs = os.listdir(path) for filename in sort...
1
2016-08-11T22:27:21Z
38,907,085
<p>You are sorting the names literally, instead you can use a key function in order to sort the names based on the integer value of the names:</p> <pre><code>for filename in sorted(dirs, key=lambda x: int(x.split('.')[0])): print filename </code></pre> <p>Note that if one of your file names doesn't follow the pro...
3
2016-08-11T22:30:00Z
[ "python" ]
How to convert a very large image(tif) file into an array using Python
38,907,079
<p>I have a <strong>tif</strong> file of size ~2GB. I want to convert it into a numpy array for further processing. I tried to open the image using PIL.Image.open("FileName") and then add it to numpy array. But I am getting the error:</p> <p><strong>IOError: cannot identify image file</strong> </p> <p>The file forma...
0
2016-08-11T22:29:16Z
38,907,204
<p>You can try Scipy:</p> <pre><code>from scipy import misc f = misc.face() misc.imsave('face.png', f) # uses the Image module (PIL) import matplotlib.pyplot as plt plt.imshow(f) plt.show() </code></pre> <p>--Source: <a href="http://www.scipy-lectures.org/advanced/image_processing/" rel="nofollow">http://www.scipy-l...
0
2016-08-11T22:43:24Z
[ "python", "numpy", "image-processing" ]
How to convert a very large image(tif) file into an array using Python
38,907,079
<p>I have a <strong>tif</strong> file of size ~2GB. I want to convert it into a numpy array for further processing. I tried to open the image using PIL.Image.open("FileName") and then add it to numpy array. But I am getting the error:</p> <p><strong>IOError: cannot identify image file</strong> </p> <p>The file forma...
0
2016-08-11T22:29:16Z
38,941,411
<p><a href="http://www.vips.ecs.soton.ac.uk/index.php?title=VIPS" rel="nofollow">vips</a> has good support for large files, and a <a href="http://www.vips.ecs.soton.ac.uk/supported/current/doc/html/libvips/using-from-python.html" rel="nofollow">convenient high-level Python binding</a>, you could try that. </p> <p>You ...
1
2016-08-14T10:41:08Z
[ "python", "numpy", "image-processing" ]
Find IP from CIDR
38,907,080
<p>I am searching for IPs listed in <code>s1</code> in CIDR listed in <code>s2</code>. So basically, I want to expand all elements of <code>s2</code> and search for IPs. Not sure how to get IPs from <code>s1</code>, if use <code>re.compile</code>. I am not getting ip4:, how do I remove the ip4: part</p> <pre><code>imp...
0
2016-08-11T22:29:25Z
38,907,845
<p>Finally I wrote this:</p> <pre><code>#/usr/bin/python import os import re from netaddr import IPNetwork import subprocess import shlex cmd = '/usr/bin/dig +short -t TXT _netblocks.google.com' proc=subprocess.Popen(shlex.split(cmd),stdout=subprocess.PIPE) s1,err=proc.communicate() cmd3 = '/usr/bin/dig +short -t TX...
0
2016-08-11T23:56:03Z
[ "python" ]
Trying to extract meta data from news article
38,907,114
<p>I am trying to extract the meta tags from a cnn article </p> <pre><code>import httplib2 from bs4 import BeautifulSoup http = httplib2.Http() status, response = http.request(http://www.cnn.com/2016/08/09/health/chagas-sleeping-sickness-leishmaniasis-drug/index.html) soup = BeautifulSoup(response) print(soup.selec...
1
2016-08-11T22:32:29Z
38,907,170
<p>It is the parser/html that is the issue, <em>lxml</em> and <em>html5lib</em> gives you what you want.</p> <pre><code>soup = BeautifulSoup(response,"lxml") </code></pre> <p>Or:</p> <pre><code> soup = BeautifulSoup(response,"html5lib") </code></pre> <p>If you don't have with <em>lxml</em> or <em>html5lib</em> inst...
1
2016-08-11T22:39:57Z
[ "python", "beautifulsoup" ]
What do I need to place in my `__init__.py` files to simplify this package's interface?
38,907,151
<p>I have a package that works with the following files:</p> <pre><code># package/sub1/obj1.py class Obj1: pass # package/sub2/obj2.py from ..sub1.obj1 import Obj1 class Obj2(Obj1): pass </code></pre> <p>Currently, with a file at the same level as the <code>package</code> folder, I need to do this:</p> <pre...
2
2016-08-11T22:37:30Z
38,907,399
<p>Assuming you don't have anything else in the <code>__init__.py</code> files except for the following, this should work:</p> <pre><code># package/sub1/__init__.py from package.sub1.obj1 import Obj1 # package/sub2/__init__.py from package.sub2.obj2 import Obj2 # package/__init__.py from package.sub1 import Obj1 fro...
3
2016-08-11T23:04:13Z
[ "python" ]
What do I need to place in my `__init__.py` files to simplify this package's interface?
38,907,151
<p>I have a package that works with the following files:</p> <pre><code># package/sub1/obj1.py class Obj1: pass # package/sub2/obj2.py from ..sub1.obj1 import Obj1 class Obj2(Obj1): pass </code></pre> <p>Currently, with a file at the same level as the <code>package</code> folder, I need to do this:</p> <pre...
2
2016-08-11T22:37:30Z
38,907,428
<p>You could make it work by adding the following to your <code>__init__.py</code> files:</p> <p>In <code>package/sub1/__init__.py</code>:</p> <pre><code>from .ob1 import Obj1 </code></pre> <p>In <code>package/sub2/__init__.py</code>:</p> <pre><code>from .ob2 import Obj2 </code></pre> <p>In <code>package/__init__....
3
2016-08-11T23:06:55Z
[ "python" ]
KeyProperty or IntegerID Look-up to Model One-to-Many Relationship Google App Engine
38,907,174
<p>this may be a super dumb question but here goes:</p> <p>On App Engine, if I want to model a one-to-many relationship, should I store the referenced entity as a KeyProperty, or should I simply store the numericID of the entity (auto-generated by App Engine) as an Integery Property?</p> <p>For example:</p> <pre><co...
1
2016-08-11T22:40:17Z
38,908,326
<p>There is a method to produce Web-safe strings from keys, but keys do take much more space than IDs. There is no reason to use Keys for references with an exception of some rare use cases when you need to know the parent entity and decide that it's easier to store a full key than pass ID of an entity and ID of a pare...
0
2016-08-12T01:04:35Z
[ "python", "google-app-engine", "one-to-many" ]
Regex - Non grouping and conditional block does not match
38,907,215
<p>I have this pattern:</p> <pre><code>&gt;&gt;&gt; pat = r'(?:.*)?(name)|nombres?' </code></pre> <p>When I test:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; re.search('nombre', pat).group() &gt;&gt;&gt; 'nombre' &gt;&gt;&gt; re.search('name', pat).group() &gt;&gt;&gt; 'name' </code></pre> <p>But</p> <pre><...
0
2016-08-11T22:44:54Z
38,907,259
<p>You have the arguments in the wrong order. The pattern goes first.</p>
2
2016-08-11T22:49:54Z
[ "python", "regex" ]
Regex - Non grouping and conditional block does not match
38,907,215
<p>I have this pattern:</p> <pre><code>&gt;&gt;&gt; pat = r'(?:.*)?(name)|nombres?' </code></pre> <p>When I test:</p> <pre><code>&gt;&gt;&gt; import re &gt;&gt;&gt; re.search('nombre', pat).group() &gt;&gt;&gt; 'nombre' &gt;&gt;&gt; re.search('name', pat).group() &gt;&gt;&gt; 'name' </code></pre> <p>But</p> <pre><...
0
2016-08-11T22:44:54Z
38,907,313
<p>As already answered the arguments are swapped it should be:</p> <pre><code>re.search(pat, 'first_name').group() </code></pre> <p>I'd say also that you may want to check if the pattern has actually matched before trying to extract the group match:</p> <pre><code>result = re.search(pat, 'first_name') if result: ...
1
2016-08-11T22:56:05Z
[ "python", "regex" ]
Detection of irregular shapes using houghcircle function opencv python
38,907,219
<p>I am currently doing circle detection on images look like this one, but some of the drops merge and form some irregular shapes(red marks in the original image). I am using houghcircle function in opencv to detect circles. For those irregular shapes, the function can only detect them as several small circles, but I r...
4
2016-08-11T22:45:16Z
38,907,373
<p>If you still want to use the HoughCircles function, you could just see if two circles overlap and make a new circle out of them.</p>
1
2016-08-11T23:02:08Z
[ "python", "opencv", "image-processing" ]
Detection of irregular shapes using houghcircle function opencv python
38,907,219
<p>I am currently doing circle detection on images look like this one, but some of the drops merge and form some irregular shapes(red marks in the original image). I am using houghcircle function in opencv to detect circles. For those irregular shapes, the function can only detect them as several small circles, but I r...
4
2016-08-11T22:45:16Z
38,917,817
<p>You can use <a href="http://docs.opencv.org/2.4/modules/imgproc/doc/structural_analysis_and_shape_descriptors.html?highlight=minenclosingcircle#minenclosingcircle" rel="nofollow">minEnclosingCircle</a> for this. Find the contours of your image, then apply the function to detect the shapes as circles.</p> <p>Below i...
0
2016-08-12T12:18:54Z
[ "python", "opencv", "image-processing" ]
Detection of irregular shapes using houghcircle function opencv python
38,907,219
<p>I am currently doing circle detection on images look like this one, but some of the drops merge and form some irregular shapes(red marks in the original image). I am using houghcircle function in opencv to detect circles. For those irregular shapes, the function can only detect them as several small circles, but I r...
4
2016-08-11T22:45:16Z
38,924,239
<p>When you have such beautiful well separated and contrasted patterns, the easiest way would be to use shape indexes. See <a href="http://www.thibault.biz/Doc/Publications/ShapeAndTextureIndexesIJPRAI2013.pdf" rel="nofollow">this paper</a> or <a href="http://www.thibault.biz/Doc/Publications/PosterWSCG2008_V4.pdf" rel...
0
2016-08-12T18:20:37Z
[ "python", "opencv", "image-processing" ]
Error when modifying list in python
38,907,266
<p>I have had a problem when trying to change a specific item that is in a nested list.The code I have written is in python 2.7. This is what i have written:</p> <pre><code>list_1 = [] list_2 = [] infin = 25 while infin != 0: list_1.append((0,0,0)) infin = infin - 1 infin = 5 while infin != 0: list_2.appen...
0
2016-08-11T22:50:36Z
38,907,305
<p>You're not actually appending different instances of lists, instead you're repeatedly appending a reference to the same list. Use list to avoid this.</p> <pre><code>list_1 = [] list_2 = [] infin = 25 while infin != 0: list_1.append((0,0,0)) infin = infin - 1 infin = 5 while infin != 0: list_2.append(li...
1
2016-08-11T22:55:07Z
[ "python", "list" ]
Error when modifying list in python
38,907,266
<p>I have had a problem when trying to change a specific item that is in a nested list.The code I have written is in python 2.7. This is what i have written:</p> <pre><code>list_1 = [] list_2 = [] infin = 25 while infin != 0: list_1.append((0,0,0)) infin = infin - 1 infin = 5 while infin != 0: list_2.appen...
0
2016-08-11T22:50:36Z
38,907,309
<p>Because you are appending the same list <code>list_1</code> 5 times. What you change in list_1 is printed 5 times, because the list has been added 5 times. If you want new lists, use:</p> <pre><code>list(list_1) </code></pre>
2
2016-08-11T22:55:27Z
[ "python", "list" ]
Error when modifying list in python
38,907,266
<p>I have had a problem when trying to change a specific item that is in a nested list.The code I have written is in python 2.7. This is what i have written:</p> <pre><code>list_1 = [] list_2 = [] infin = 25 while infin != 0: list_1.append((0,0,0)) infin = infin - 1 infin = 5 while infin != 0: list_2.appen...
0
2016-08-11T22:50:36Z
38,907,315
<p><code>list_1</code> is a object. You then add the object to another list 5 times, creating not 5 copies of the object, but 5 references to the same object.</p> <p>You need to copy the list as you create the second list:</p> <pre><code>infin = 5 while infin != 0: list_2.append(list(list_1)) infin = infin -...
1
2016-08-11T22:56:20Z
[ "python", "list" ]
Can anyone tell me what is the type of this language?
38,907,396
<p>query = 'GATTACA';! genome = 'TGATTACAGATTACC';! ! nummatches=0;! ! % At every possible offset! for offset=1:length(genome)-length(query)+1! !% Do all of the characters match?! !if (genome(offset:offset+length(query)-1) == query)! !! !disp(['Match at offset ', num2str(offset)])! !! !nummatches = nummatches+1;! !els...
-3
2016-08-11T23:03:58Z
38,907,476
<p>MATLAB amigo, the disp and '%' for comments and num2str function are all MATLAB tid bits.</p>
0
2016-08-11T23:11:14Z
[ "python" ]