title
stringlengths
10
172
question_id
int64
469
40.1M
question_body
stringlengths
22
48.2k
question_score
int64
-44
5.52k
question_date
stringlengths
20
20
answer_id
int64
497
40.1M
answer_body
stringlengths
18
33.9k
answer_score
int64
-38
8.38k
answer_date
stringlengths
20
20
tags
list
how to make tkinter window to stay at bottom?
39,630,966
<pre><code>import Tkinter from Tkinter import Button root=Tkinter.Tk() def close_window (): root.destroy() w = root.winfo_screenwidth() root.overrideredirect(1) root.geometry("200x200+%d+200" %(w-210)) root.configure(background='gray10') btn = Button(text='X',borderwidth=0,highlightthickness=0,bd=0,command = close_...
0
2016-09-22T05:32:26Z
39,632,581
<p>You're already doing something close. Get the screen height and subtract the height or more of your window.</p> <pre><code>import Tkinter from Tkinter import Button root=Tkinter.Tk() def close_window (): root.destroy() screen_width = root.winfo_screenwidth() screen_height = root.winfo_screenheight() root.ov...
0
2016-09-22T07:15:47Z
[ "python", "user-interface", "tkinter" ]
python client and perl server: packing and unpacking bytes to send/receive
39,631,009
<p>python_client.py</p> <pre><code>def send_one_message(sock, data): length = len(data) sock.sendall(struct.pack('!I', length)) sock.sendall(data) </code></pre> <p>perl_server.pl</p> <pre><code>sub ntohl { unpack("I", pack("N", $_[0])); } my $line = ""; $client_socket-&gt;recv($line, 4); my $line_le...
2
2016-09-22T05:35:38Z
39,631,400
<p>I've changed ntohl</p> <pre><code>sub ntohl { unpack("I", $_[0]); } </code></pre> <p>and</p> <pre><code>sock.sendall(struct.pack('I', length)) </code></pre>
0
2016-09-22T06:04:34Z
[ "python", "perl", "sockets" ]
How to read averaged nodal stress from abaqus odb file using python script?
39,631,065
<p>I know how to read element or element node stress value (unaveraged) using python script.</p> <pre><code>field = stressField.getSubset(region=topCenter,position=INTEGRATION_POINT, elementType = 'CAX4') </code></pre> <p>But i want averaged stress values at nodes. FYI, my odb does not contain node position data for ...
0
2016-09-22T05:40:05Z
39,647,993
<p>this is one of those things that way more cumbersome than it should be. you need to create xydata :</p> <pre><code>session.xyDataListFromField(odb=odb, outputPosition=ELEMENT_NODAL, variable=(( 'S', INTEGRATION_POINT), ), elementSets=('PART-1-1.SETNAME', )) </code></pre> <p>this creates a ...
0
2016-09-22T20:05:52Z
[ "python", "abaqus", "stress", "odb" ]
Linear Support Vector Machines multiclass classification with PySpark API
39,631,208
<p>Support Vector Machines currently does not yet support multi class classification within Spark, but will in the future as it is described on the Spark <a href="http://spark.apache.org/docs/latest/mllib-classification-regression.html" rel="nofollow">page</a>.</p> <p>Is there any release date or any chance to run it ...
0
2016-09-22T05:53:22Z
39,642,967
<p>In practice you can perform multiclass classification using an arbitrary binary classifier and one-vs-rest strategy. <code>mllib</code> doesn't provide one (there is one in <code>ml</code>) but you can easily built your own. Assuming data looks like this</p> <pre><code>import numpy as np np.random.seed(323) classe...
1
2016-09-22T15:21:16Z
[ "python", "apache-spark", "pyspark", "svm", "text-classification" ]
How to connect a socket to another computer's socket through Internet
39,631,360
<p>I recently have some difficulties to connect a socket to another computer's socket through Internet, an image is worth a thousand words:</p> <p><a href="http://i.stack.imgur.com/9CseJ.png" rel="nofollow"><img src="http://i.stack.imgur.com/9CseJ.png" alt="enter image description here"></a></p> <p>Computer <strong>A...
0
2016-09-22T06:02:55Z
39,636,475
<p>Computer B can't directly connect to computer A since it has an IP address which is not reachable from the outside. You need to set up a port forwarding rule in the 101.81.83.169 router that redirects incoming connection requests for port 50007 to IP address 192.168.0.4.</p> <p>However, since you say that you are ...
0
2016-09-22T10:22:12Z
[ "python", "sockets", "networking" ]
How to connect a socket to another computer's socket through Internet
39,631,360
<p>I recently have some difficulties to connect a socket to another computer's socket through Internet, an image is worth a thousand words:</p> <p><a href="http://i.stack.imgur.com/9CseJ.png" rel="nofollow"><img src="http://i.stack.imgur.com/9CseJ.png" alt="enter image description here"></a></p> <p>Computer <strong>A...
0
2016-09-22T06:02:55Z
39,636,832
<blockquote> <p>So I would like to know how can I connect a socket to another socket through internet without changing the router configurations.</p> </blockquote> <p>You can't. The public IP address belongs to your router. Your server isn't listening in the router, it is listening in some host behind the router. Yo...
-1
2016-09-22T10:40:30Z
[ "python", "sockets", "networking" ]
How to connect a socket to another computer's socket through Internet
39,631,360
<p>I recently have some difficulties to connect a socket to another computer's socket through Internet, an image is worth a thousand words:</p> <p><a href="http://i.stack.imgur.com/9CseJ.png" rel="nofollow"><img src="http://i.stack.imgur.com/9CseJ.png" alt="enter image description here"></a></p> <p>Computer <strong>A...
0
2016-09-22T06:02:55Z
39,637,444
<p>From the book <a href="http://www.nylxs.com/docs/cmpnet.pdf" rel="nofollow">"Computer Networking: A Top-Down Approach"</a>, there is a part which is very interesting on page 149 about how Bittorents work:</p> <blockquote> <p>Each torrent has an infrastructure node called a tracker. When a peer joins a torrent, it...
0
2016-09-22T11:12:05Z
[ "python", "sockets", "networking" ]
How to understand this raw HTML of Yahoo! Finance when retrieving data using Python?
39,631,386
<p>I've been trying to retrieve stock price from Yahoo! Finance, like for <a href="http://finance.yahoo.com/quote/AAPL/profile?p=AAPL" rel="nofollow">Apple Inc.</a>. My code is like this:(using Python 2)</p> <pre><code>import requests from bs4 import BeautifulSoup as bs html='http://finance.yahoo.com/quote/AAPL/profi...
3
2016-09-22T06:04:04Z
39,632,209
<p>Not sure what you mean by 'dynamic' in this case, but have you considered using CSS selectors?</p> <p>With Beautifulsoup you could get it e.g like this:</p> <pre><code>soup.select('div#quote-header-info section span')[0] </code></pre> <p>And there are some variations you could use on the pattern, such as using ...
3
2016-09-22T06:55:08Z
[ "python", "html", "beautifulsoup", "web-crawler", "yahoo-finance" ]
How to understand this raw HTML of Yahoo! Finance when retrieving data using Python?
39,631,386
<p>I've been trying to retrieve stock price from Yahoo! Finance, like for <a href="http://finance.yahoo.com/quote/AAPL/profile?p=AAPL" rel="nofollow">Apple Inc.</a>. My code is like this:(using Python 2)</p> <pre><code>import requests from bs4 import BeautifulSoup as bs html='http://finance.yahoo.com/quote/AAPL/profi...
3
2016-09-22T06:04:04Z
39,635,322
<p>The data is obviously populated using <em>reactjs</em> so you won't be able to parse it reliably using class names etc.. You can get all the data in <em>json</em> format from the page source from the <code>root.App.main</code> script :</p> <pre><code>import requests from bs4 import BeautifulSoup import re from js...
2
2016-09-22T09:32:47Z
[ "python", "html", "beautifulsoup", "web-crawler", "yahoo-finance" ]
making a python interpreter using javascript
39,631,465
<p>I want to make a python interpreter by using Javascript. </p> <p>Then you can input the python code and the Javascript in the webpage can interpret the code into javascript code and then run the code and return the result.</p> <p>Because I have not much experience in this area, so I want some advice from the senio...
-1
2016-09-22T06:08:59Z
39,631,568
<p>You can use pypyjs, and the detailed procedure is also available. <a href="https://github.com/pypyjs/pypyjs/releases/" rel="nofollow">https://github.com/pypyjs/pypyjs/releases/</a></p>
0
2016-09-22T06:16:21Z
[ "javascript", "python" ]
making a python interpreter using javascript
39,631,465
<p>I want to make a python interpreter by using Javascript. </p> <p>Then you can input the python code and the Javascript in the webpage can interpret the code into javascript code and then run the code and return the result.</p> <p>Because I have not much experience in this area, so I want some advice from the senio...
-1
2016-09-22T06:08:59Z
39,632,417
<p>Well, an interpreter is not really a job for a beginner, also you'd better send the code to server side with AJAX, and then display the result in the page.</p>
0
2016-09-22T07:07:28Z
[ "javascript", "python" ]
How do I ask the user if they want to play again and repeat the while loop?
39,631,540
<p>Running on Python, this is an example of my code: </p> <pre><code>import random comp = random.choice([1,2,3]) while True: user = input("Please enter 1, 2, or 3: ") if user == comp print("Tie game!") elif (user == "1") and (comp == "2") print("You lose!") brea...
1
2016-09-22T06:14:05Z
39,631,665
<p>Points for your code:</p> <ol> <li>Code you have pasted don't have <code>':'</code> after <code>if,elif</code> and <code>else.</code></li> <li>Whatever you want can be achived using Control Flow Statements like <code>continue and break</code>. <a href="https://docs.python.org/2/tutorial/controlflow.html" rel="nofol...
3
2016-09-22T06:21:38Z
[ "python", "loops", "while-loop", "nested" ]
Can a pandas DataFrame hold non-scalar values?
39,631,678
<p>I'd like a DataFrame to store non-primitive types, in particular I would need a column that can have lists as its items.</p> <pre><code>pd.DataFrame( [["foo","bar"],["rab","oof"]], ["my-column-of-lists"] ) </code></pre> <p>should result in a DataFrame with one column (<code>my-column-of-lists</code>) and 2 rows (<...
2
2016-09-22T06:22:27Z
39,631,714
<p>You can use <code>dict</code>:</p> <pre><code>df = pd.DataFrame({'my-column-of-lists': [["foo","bar"],["rab","oof"]]}) print (df) my-column-of-lists 0 [foo, bar] 1 [rab, oof] </code></pre> <p>Or pass <code>Series</code>:</p> <pre><code>df = pd.DataFrame(pd.Series([["foo","bar"],["rab","oof"]], n...
4
2016-09-22T06:24:23Z
[ "python", "list", "pandas", "dataframe" ]
Python append data reverse
39,631,817
<p>I try to use arraylist to implement graph but when I print(graph.edges()) why some of data will reverse {vertex,node},its mean I should't use append?</p> <pre><code>class Graph(object): def __init__(self, graph_dict=None): """ initializes a graph object If no dictionary or None is given, ...
0
2016-09-22T06:32:22Z
39,632,234
<p>You are using a <code>set</code> when you use this notation:</p> <pre><code>{node,vertex} </code></pre> <p>This data structure is unordered. Try a tuple instead:</p> <pre><code>(node, vertex) </code></pre>
1
2016-09-22T06:56:20Z
[ "python", "python-3.5" ]
python+pyspark: error on inner join with multiple column comparison in pyspark
39,631,870
<p>Hi I have 2 dataframes to join</p> <pre><code>#df1 name genre count satya drama 1 satya action 3 abc drame 2 abc comedy 2 def romance 1 #df2 name max_count satya 3 abc 2 def 1 </code></pre> <p>Now I want to join above 2 dfs on name and count==max_count, But i am ge...
0
2016-09-22T06:35:07Z
39,633,357
<p>Update: It seems like your code was failing also due to the use of "count" as column name. count seems to be protected keyword in DataFrame API. renaming count to "mycount" solved the problem. The below working code was modify to support spark version 1.5.2 which I used to test your issue.</p> <pre><code>df = sqlCo...
2
2016-09-22T07:55:21Z
[ "python", "apache-spark", "pyspark", "pyspark-sql" ]
python+pyspark: error on inner join with multiple column comparison in pyspark
39,631,870
<p>Hi I have 2 dataframes to join</p> <pre><code>#df1 name genre count satya drama 1 satya action 3 abc drame 2 abc comedy 2 def romance 1 #df2 name max_count satya 3 abc 2 def 1 </code></pre> <p>Now I want to join above 2 dfs on name and count==max_count, But i am ge...
0
2016-09-22T06:35:07Z
39,696,803
<h1>My work-around in spark 2.0</h1> <p>I created a single column('combined') from columns in join comparision('name','mycount')in respective dfs, so now I have one column to compare and this is not creating any issue as I am comparing only one column.</p> <pre><code>def combine_func(*args): data = '_'.join([str(x)...
0
2016-09-26T07:15:58Z
[ "python", "apache-spark", "pyspark", "pyspark-sql" ]
python+pyspark: error on inner join with multiple column comparison in pyspark
39,631,870
<p>Hi I have 2 dataframes to join</p> <pre><code>#df1 name genre count satya drama 1 satya action 3 abc drame 2 abc comedy 2 def romance 1 #df2 name max_count satya 3 abc 2 def 1 </code></pre> <p>Now I want to join above 2 dfs on name and count==max_count, But i am ge...
0
2016-09-22T06:35:07Z
39,844,319
<p>I ran into the same problem when I tried to join two DataFrames where one of them was GroupedData. It worked for me when I cached the GroupedData DataFrame before the inner join. For your code, try:</p> <pre><code>df1 = df.groupBy("name", "genre").count().cache() # added cache() df2 = df1.groupby('name').agg(F.m...
1
2016-10-04T04:44:25Z
[ "python", "apache-spark", "pyspark", "pyspark-sql" ]
Where can I find all the tag definitions of POS tagging for ClassifierBasedPOSTagger in NLTK?
39,631,938
<p>I used the following code to train a <code>ClassifierBasedPOSTagger</code> for POS tagging:</p> <pre><code>from nltk.classify import MaxentClassifier from nltk.tag.sequential import ClassifierBasedPOSTagger me_tagger = ClassifierBasedPOSTagger(train=train_sents, classifier_builder=lambda train_feats: MaxentClassif...
0
2016-09-22T06:39:55Z
39,636,569
<p>You can check - <a href="http://www.scs.leeds.ac.uk/amalgam/tagsets/brown.html" rel="nofollow">The Brown Corpus Tag-set</a>.</p> <pre><code>╔═════╦═════════════════════╦════════════════════╗ ║ Tag ║ Description ...
2
2016-09-22T10:27:05Z
[ "python", "nltk" ]
Where can I find all the tag definitions of POS tagging for ClassifierBasedPOSTagger in NLTK?
39,631,938
<p>I used the following code to train a <code>ClassifierBasedPOSTagger</code> for POS tagging:</p> <pre><code>from nltk.classify import MaxentClassifier from nltk.tag.sequential import ClassifierBasedPOSTagger me_tagger = ClassifierBasedPOSTagger(train=train_sents, classifier_builder=lambda train_feats: MaxentClassif...
0
2016-09-22T06:39:55Z
39,639,348
<p>You should understand that the tagset has nothing to do with the classifier class you chose; the tagset comes from your training data. So your question should have been "where do I find the tag definitions for (this POS-tagged corpus)". You don't say where your <code>train_sents</code> came from, but indeed (as @RAV...
1
2016-09-22T12:40:29Z
[ "python", "nltk" ]
Printing only desired values of keys in dcitionary
39,631,958
<p>I have a dictionary in Python which looks like this</p> <pre><code>{123: [u'6722000', u'6722001', u'6631999', u'PX522.X522.091003143054.S4J2', u'PXX22.XX22.140311131347.A6D4', u'7767815060', u'6631900', u'7767815062', u'18001029945', u'7767815063'],...} </code></pre> <p>When I want to print out the values of dicti...
-1
2016-09-22T06:41:03Z
39,632,327
<p><a href="https://docs.python.org/3/library/functions.html#enumerate" rel="nofollow">enumerate</a> will give you the iterator index and value of the iterable. In this case the key and index of the key. Not the values of a key. And as the value is a list of string you have to check for "P" in the strings inside the li...
0
2016-09-22T07:01:31Z
[ "python", "dictionary" ]
Printing only desired values of keys in dcitionary
39,631,958
<p>I have a dictionary in Python which looks like this</p> <pre><code>{123: [u'6722000', u'6722001', u'6631999', u'PX522.X522.091003143054.S4J2', u'PXX22.XX22.140311131347.A6D4', u'7767815060', u'6631900', u'7767815062', u'18001029945', u'7767815063'],...} </code></pre> <p>When I want to print out the values of dicti...
-1
2016-09-22T06:41:03Z
39,632,329
<p><strong>Code with comments inline:</strong></p> <pre><code>a_dict = {123: [u'6722000', u'6722001', u'6631999', u'PX522.X522.091003143054.S4J2', u'PXX22.XX22.140311131347.A6D4', u'7767815060', u'6631900', u'7767815062', u'18001029945', u'7767815063'], 456: [u'6722000', u'6722001', u'6631999', u'PX522....
0
2016-09-22T07:01:37Z
[ "python", "dictionary" ]
Check if a value comes before another in a list
39,632,023
<p>I would like to check whether a value comes before another in a list. I asked this question awhile back: <a href="http://stackoverflow.com/questions/38603449/typeerror-githubiterator-object-does-not-support-indexing">TypeError: &#39;GitHubIterator&#39; object does not support indexing</a>, which allows me to access ...
0
2016-09-22T06:44:15Z
39,632,181
<p>It looks like you're confusing yourself. The <code>for</code> loop is already iterating over the comments in order. All you need to do is test each comment for the <code>#hold-off</code> and <code>#sign-off</code> patterns and report on which one you see first.</p> <pre><code>hold_off_regex_search_string = re.compi...
1
2016-09-22T06:53:51Z
[ "python", "indexing" ]
Python MagicMock to os.listdir not raise error
39,632,177
<p>I would like to set os.listdir to raise OSError in UT but it not raise anything.</p> <p>My code:</p> <pre><code>def get_list_of_files(path): try: list_of_files = sorted([filename for filename in os.listdir(path) if filename.startswith('FIL...
0
2016-09-22T06:53:41Z
39,632,283
<p>You need to set the side effect for <code>self.mock_listdir</code>, not it's return value:</p> <pre><code>def test(self): e = OSError('abc') self.mock_listdir.side_effect = e with self.assertRaises(OSError): get_list_of_files('path') </code></pre> <p>After all, you want the call to <code>os.li...
1
2016-09-22T06:59:01Z
[ "python", "mocking" ]
How to import normalised json data from several files into a pandas dataframe?
39,632,248
<p>I have json datafiles in several directories that I want to import into Pandas to do some data analysis. The format of the json depends on the type defined in the directory name. For example,</p> <pre><code>dir1_typeA/ file1 file2 ... dir1_typeB/ file1 file2 ... dir2_typeB/ file1 ... dir2_typeA/ f...
0
2016-09-22T06:57:02Z
39,632,608
<p>I think you should concatenate the files together first before you read them into pandas, here is how you'd do it in bash (you could also do it in Python):</p> <pre><code>cat `find *typeA` &gt; typeA cat `find *typeB` &gt; typeB </code></pre> <p>Then you can import it into pandas using <code>io.json.json_normalize...
1
2016-09-22T07:16:53Z
[ "python", "json", "pandas", "dataframe" ]
Pandas NaN introduced by pivot_table
39,632,277
<p>I have a table containing some countries and their KPI from the world-banks API. this looks like <a href="http://i.stack.imgur.com/ZL4bU.jpg" rel="nofollow"><img src="http://i.stack.imgur.com/ZL4bU.jpg" alt="no nan values present"></a>. As you can see no nan values are present. </p> <p>However, I need to pivot this...
1
2016-09-22T06:58:46Z
39,632,450
<p>I think the best understand <code>pivoting</code> is in small sample:</p> <pre><code>import pandas as pd import numpy as np countryKPI = pd.DataFrame({'germanCName':['a','a','b','c','c'], 'indicator.id':['z','x','z','y','m'], 'value':[7,8,9,7,8]}) print (count...
1
2016-09-22T07:09:15Z
[ "python", "pandas", "pivot", "pivot-table", null ]
Python - thread inheritance's method (func)
39,632,311
<p>I have class A which inheritance the class B i need to send main_b to thread and continue with the program (main_a)</p> <pre><code>import threading import time class B(object): def main_b(self): i = 0 while i &lt; 5: print "main_b: %s" %time.ctime(time.time()) time.slee...
1
2016-09-22T07:00:37Z
39,633,149
<p>Just pass method as a target for thread:</p> <pre><code>b = threading.Thread(target=self.main_b) </code></pre>
0
2016-09-22T07:44:23Z
[ "python", "multithreading" ]
tastypie saving foreignkey field throws exception
39,632,403
<p>I'm trying to add the foreign key to my tastypie resources, but django throws out this error:</p> <pre><code>"error_message": "'BB' object is not iterable", </code></pre> <p>I've created a minimal working example:</p> <p><strong>models.py</strong></p> <pre><code>class AA(models.Model): n = models.IntegerFiel...
0
2016-09-22T07:06:22Z
39,681,540
<p>it was a simple (and newbie) question that make me feel like a déjà vu. The issue here is to remember when to use <code>related_name</code>, in this case that param isn't necessary.</p> <p><a href="http://django-tastypie.readthedocs.io/en/latest/fields.html#related-name" rel="nofollow">Link to the docs</a> where ...
0
2016-09-24T22:31:06Z
[ "python", "django", "tastypie", "restful-architecture" ]
Mongoengine signals listens for all models
39,632,486
<p>I have setup <code>django</code> project with <code>mongoengine</code> for using mongodb with django. I have created 2 models and they work fine, but when I use signal listener for one model It also listens for another model, so how can I keep the signals bound to their models?</p> <p>Here's my code for model User:...
3
2016-09-22T07:11:03Z
39,654,354
<p>I figured out a way to bind signals for particular models, here's the code how I did it:</p> <pre class="lang-py prettyprint-override"><code>from mongoengine import * from mongoengine import signals from datetime import datetime class User(Document): uid = StringField(max_length=60, required=True) platfor...
3
2016-09-23T06:50:04Z
[ "python", "django", "mongodb", "mongoengine" ]
Processing data with different number of features
39,632,573
<p>I have this classification/regression task but the most interesting thing is that the number of features for each record is different. Features are already extracted and already prepared thus the context of the data is unknown, and the values of the features fluctuate from -10 to 10. There are records with more than...
0
2016-09-22T07:15:22Z
39,633,064
<p>Data imputation <em>might</em> work when </p> <ul> <li>the datapoints with missing attributes represent a small percentage of your datapoints</li> <li>the amount of missing attributes per datapoint is not big.</li> </ul> <p>The reason you are getting poor results - at least as far as the data completeness is conce...
0
2016-09-22T07:39:34Z
[ "python", "pandas", "machine-learning", "scikit-learn" ]
Convert a 1D list to 2D at every "\n" - Python
39,632,629
<p>I am trying to convert a 1D list to 2D whenever there is <code>\n</code> in it. </p> <pre><code>a = ['a', 'b', '\n', 'c', 'd'] </code></pre> <p>to</p> <pre><code>a = [['a', 'b']['c', 'd']] </code></pre> <p>Can anyone help me?</p> <p><strong>Edit</strong></p> <p>This is because I have a string</p> <pre><code>a...
-1
2016-09-22T07:18:21Z
39,632,715
<p>Simplest way is to join the list to make string. Then split it on '\n' and convert the each string in the list to sub list:</p> <pre><code>&gt;&gt;&gt; a_string = ''.join(a) &gt;&gt;&gt; map(list, a_string.split()) [['a', 'b'], ['c', 'd']] </code></pre> <p>However if you do not want to go with this approach, below...
4
2016-09-22T07:22:42Z
[ "python" ]
sum based on radix in Python 2.7
39,632,834
<p>Working on a problem to calculate sum for any radix (radix between 2 to 10, inclusive), for example "10" + "20" based on 10 radix result in 30, and "10" + "20" based on radix 3 result in 100.</p> <p>I post my code and test cases to verify it works, and my question is if any performance improvement or any ideas to m...
1
2016-09-22T07:28:47Z
39,634,065
<p>Your code is mostly ok, but you repeat some tests unnecessarily. Instead of </p> <pre><code>if value &gt;= radix: remaining = 1 else: remaining = 0 if value &gt;= radix: value = value - radix </code></pre> <p>you can do</p> <pre><code>if value &gt;= radix: remaining = 1 value = value - radix e...
1
2016-09-22T08:34:26Z
[ "python", "python-2.7", "radix" ]
Dot product of patches in tensorflow
39,632,849
<p>I have two square matrices of the same size and the dimensions of a square patch. I'd like to compute the dot product between every pair of patches. Essentially I would like to implement the following operation:</p> <pre><code>def patch_dot(A, B, patch_dim): res_dim = A.shape[0] - patch_dim + 1 res = np.zer...
1
2016-09-22T07:30:05Z
39,656,992
<p>The natural way to do this is to first extract overlapping image patches of matrix B using <a href="https://www.tensorflow.org/versions/r0.10/api_docs/python/array_ops.html#extract_image_patches" rel="nofollow">tf.extract_image_patches</a>, then to apply the <a href="https://www.tensorflow.org/versions/r0.8/api_docs...
1
2016-09-23T09:12:45Z
[ "python", "machine-learning", "computer-vision", "tensorflow", "linear-algebra" ]
How to get a Python 2.7 package (Spynner) to work with Python 3?
39,632,870
<p>The Spynner docs says it supports Python >=26, but during installation I get the following error:</p> <pre><code>(spynner) spynner$ pip3 install spynner Requirement already satisfied (use --upgrade to upgrade): spynner in /Users/spynner/Envs/spynner/lib/python3.4/site-packages/spynner-2.19-py3.4.egg Collecting six ...
0
2016-09-22T07:30:55Z
39,633,021
<p>You will need to correct the offending code. There are automated tools that help you do that, such as <a href="https://docs.python.org/2/library/2to3.html" rel="nofollow">2to3</a>:</p> <blockquote> <p>2to3 is a Python program that reads Python 2.x source code and applies a series of fixers to transform it into va...
0
2016-09-22T07:37:46Z
[ "python", "spynner" ]
Passing data into flask using Ajax
39,633,202
<p>i am trying to pass some data from html to python using ajax using post request. But the arguments for request are empty.</p> <p>A simple endpoint, i am trying to print all the arguments that come in the form of request.</p> <pre><code>@app.route("/enter", methods=["POST", "GET"]) def enter_data(): if request....
-1
2016-09-22T07:47:00Z
39,633,407
<p>There is no <code>&lt;form&gt;</code> tag in your html code, so your <code>$('form').serialize()</code> doing nothing.</p>
0
2016-09-22T07:58:06Z
[ "javascript", "jquery", "python", "ajax", "flask" ]
Passing data into flask using Ajax
39,633,202
<p>i am trying to pass some data from html to python using ajax using post request. But the arguments for request are empty.</p> <p>A simple endpoint, i am trying to print all the arguments that come in the form of request.</p> <pre><code>@app.route("/enter", methods=["POST", "GET"]) def enter_data(): if request....
-1
2016-09-22T07:47:00Z
39,633,419
<p>Within render template, you need to specify elements to be filled in within your template.</p> <p>Instead of this;</p> <pre><code>@app.route("/enter", methods=["POST", "GET"]) def enter_data(): if request.method == "GET": return render_template('index.html') else: print("post") prin...
0
2016-09-22T07:58:45Z
[ "javascript", "jquery", "python", "ajax", "flask" ]
Passing data into flask using Ajax
39,633,202
<p>i am trying to pass some data from html to python using ajax using post request. But the arguments for request are empty.</p> <p>A simple endpoint, i am trying to print all the arguments that come in the form of request.</p> <pre><code>@app.route("/enter", methods=["POST", "GET"]) def enter_data(): if request....
-1
2016-09-22T07:47:00Z
39,633,532
<p>There is no <code>&lt;form&gt;</code> tag in your html code. Therefore your <code>data</code> attribute of the ajax is request is empty. Either put your <code>&lt;div&gt;</code> in a <code>&lt;form&gt;</code> environment in the html or set your <code>data</code> attribute in the ajax request by hand:</p> <pre><code...
0
2016-09-22T08:05:04Z
[ "javascript", "jquery", "python", "ajax", "flask" ]
Rollback Datastore PUT Transaction in GAE Python Web
39,633,228
<p>There is one method inside that method I'm inserting three different models record into database. But if some exception or error happens I need to rollback this insertion transaction from db. Following is show case of method.</p> <pre><code>def post(): try: model1 = Model1() model1.key1 = 'key1'...
-2
2016-09-22T07:48:13Z
39,642,932
<p>As <a href="http://stackoverflow.com/users/104349/daniel-roseman">@Daniel Roseman</a> linked for you, the answer is on the <a href="https://cloud.google.com/appengine/docs/python/ndb/transactions" rel="nofollow">NDB Transaction page</a>. Just search for the word "rollback" and you'll see it.</p> <p>For your code, t...
-1
2016-09-22T15:19:33Z
[ "python", "google-app-engine", "google-cloud-datastore", "rollback" ]
Replacing a specific index value in list of lists with corresponding dictionary value
39,633,231
<p>I am trying to replace a value in a list of lists (in all relevant sublists) with a VALUE from a dictionary and cannot quite get it to work. </p> <p>The content/details of the dictionary is as follows:</p> <pre><code>dictionary = dict(zip(gtincodes, currentstockvalues)) </code></pre> <p>The dictionary contains pa...
1
2016-09-22T07:48:31Z
39,633,389
<p>Your <code>GTIN</code> code at <em>index 0</em> of each sublist should be your dictionary key:</p> <pre><code>for sub_list in newdetails: sub_list[3] = dictionary.get(sub_list[0], sub_list[3]) # ^ </code></pre> <p>If the codes in the dictionary are integers and not s...
1
2016-09-22T07:56:45Z
[ "python", "dictionary", "sublist" ]
Move folders older than 2 days via Ansible
39,633,566
<p>Given the following directories:</p> <pre><code> /tmp/testing/test_ansible ├── [Sep 20 8:53] 2014-05-10 ├── [Sep 20 8:53] 2014-05-11 ├── [Sep 20 8:53] 2014-05-12 └── [Sep 22 9:48] 2016-09-22 4 directories </code></pre> <p>I'm trying to <...
0
2016-09-22T08:07:21Z
39,634,836
<p>Thanks to the awesome #ansible IRC community, manage to fix the error.</p> <p>I was printing the item wrong in the debug module:</p> <p>how I did it (bad):</p> <pre><code> - debug: var={{ item['path'] }} with_items: "{{ gold_data.files }}" </code></pre> <p>how they suggested (good):</p> <pre><code> ...
1
2016-09-22T09:10:30Z
[ "python", "bash", "directory", "ansible", "ansible-playbook" ]
More efficient way of computing distance matrix in Python
39,633,758
<p>Hi Everyone I am trying to write code (using python 2) that returns a matrix that contains the distance between all pairs of rows. Below is an implementation that I have written. It works as expected but can get very slow as the number of rows gets large. Hence I was wondering if anyone has any suggestions as to how...
0
2016-09-22T08:18:20Z
39,633,960
<p>I see you use <code>X.shape</code>, for me, it is find to assume that you are using <code>NumPy</code></p> <p>Code:</p> <pre><code>#!/usr/bin/env python3 import numpy as np import scipy.spatial.distance as dist a = np.random.randint(0, 10, (5, 3)) b = dist.pdist(a) print('Matrix:') print(a) print('Pdist') for d i...
0
2016-09-22T08:29:48Z
[ "python", "performance", "distance-matrix" ]
More efficient way of computing distance matrix in Python
39,633,758
<p>Hi Everyone I am trying to write code (using python 2) that returns a matrix that contains the distance between all pairs of rows. Below is an implementation that I have written. It works as expected but can get very slow as the number of rows gets large. Hence I was wondering if anyone has any suggestions as to how...
0
2016-09-22T08:18:20Z
39,634,672
<p>Without scipy (it is possible to get numpy without scipy, for instance with an Abaqus install) it's a bit more difficult.</p> <pre><code>def gendist(x,alpha=2): xCopies=x.repeat(x.shape[0],axis=0).reshape(np.conatenate(([a.shape[0]],a.shape)) #n x n x p matrix filled with copies of x xVecs=xCopies-xCop...
0
2016-09-22T09:03:57Z
[ "python", "performance", "distance-matrix" ]
Can't execute some python commands for virtual env from Fish shell
39,633,838
<p>I'm on MacOS Sierra and have python3 and python installed via brew. Using the command <code>python3 -m venv my_venv</code>, I created a vitual environment for python3. I then tried to activate it with <code>. bin/activate.fish</code> from within <code>my_venv</code>. However I get the exception</p> <pre><code>$(......
-1
2016-09-22T08:22:41Z
39,643,448
<blockquote> <p>. bin/pip -m pip install flake8.</p> </blockquote> <p>Here you are sourcing (the <code>.</code> command is an alias for <code>source</code>) the pip script with fish. Since <code>pip</code> is a python script, you'll get syntax errors.</p> <p>You want <code>./bin/pip</code>.</p> <blockquote> <p>$...
0
2016-09-22T15:44:33Z
[ "python", "shell", "fish" ]
Is my interpretation of the Lagrange polynomial and construction of graph correct?
39,633,846
<pre><code>import matplotlib.pyplot as plt import matplotlib.pyplot as plt def f(x): return (1 + np.exp(-x)) / (1 + x ** 4) def lagrange(x, y, x0): ret = [] for j in range(len(y)): numerator = 1.0 denominator = 1.0 for k in range(len(x)): if k != j: numerator *=...
0
2016-09-22T08:23:01Z
39,641,264
<p>SciPy has <code>lagrange</code>, here is an example:</p> <pre><code>import matplotlib.pyplot as plt import numpy as np from scipy.interpolate import lagrange def f(x): return (1 + np.exp(-x)) / (1 + x ** 4) x = np.linspace(-1, 1, 10) x2 = np.linspace(-1, 1, 100) y = f(x) p = lagrange(x, y) plt.plot(x, f(x), "o...
0
2016-09-22T14:03:00Z
[ "python", "matplotlib" ]
How to get array after adding a number to specific data of that array?
39,633,889
<pre><code>import numpy as np import xlrd import xlwt wb = xlrd.open_workbook('Scatter plot.xlsx') workbook = xlwt.Workbook() sheet = workbook.add_sheet("Sheet1") sh1 = wb.sheet_by_name('T180') sh2=wb.sheet_by_name("T181") x= np.array([sh1.col_values(1, start_rowx=51, end_rowx=315)]) y= np.array([sh1.col_values(2...
1
2016-09-22T08:25:40Z
39,635,155
<p>You can use <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.place.html" rel="nofollow"><code>numpy.place</code></a> to modify arrays where a logic expression holds. For complex logic expressions on the array there are the <a href="http://docs.scipy.org/doc/numpy/reference/routines.logic.html" rel=...
1
2016-09-22T09:25:39Z
[ "python", "arrays", "subtraction" ]
How to get array after adding a number to specific data of that array?
39,633,889
<pre><code>import numpy as np import xlrd import xlwt wb = xlrd.open_workbook('Scatter plot.xlsx') workbook = xlwt.Workbook() sheet = workbook.add_sheet("Sheet1") sh1 = wb.sheet_by_name('T180') sh2=wb.sheet_by_name("T181") x= np.array([sh1.col_values(1, start_rowx=51, end_rowx=315)]) y= np.array([sh1.col_values(2...
1
2016-09-22T08:25:40Z
39,635,471
<pre><code>import numpy as np #random initialization x1=np.random.randint(1,high=3000, size=10) x_prime=x1.tolist() for i in range(len(x_prime)): if(x_prime[i]&lt;=1000 and x_prime[i]&gt;=0): x_prime[i]=x_prime[i]-150 x_prime=np.asarray(x_prime) </code></pre> <p><strong>Answer:</strong></p> <pre><c...
0
2016-09-22T09:38:13Z
[ "python", "arrays", "subtraction" ]
How to get array after adding a number to specific data of that array?
39,633,889
<pre><code>import numpy as np import xlrd import xlwt wb = xlrd.open_workbook('Scatter plot.xlsx') workbook = xlwt.Workbook() sheet = workbook.add_sheet("Sheet1") sh1 = wb.sheet_by_name('T180') sh2=wb.sheet_by_name("T181") x= np.array([sh1.col_values(1, start_rowx=51, end_rowx=315)]) y= np.array([sh1.col_values(2...
1
2016-09-22T08:25:40Z
39,645,577
<p>Here is a Pandas solution:</p> <pre><code>import matplotlib import matplotlib.pyplot as plt import pandas as pd matplotlib.style.use('ggplot') fn = r'/path/to/ExcelFile.xlsx' sheetname = 'T181' df = pd.read_excel(fn, sheetname=sheetname, skiprows=47, parse_cols='B:C').dropna(how='any') # customize X-values df.ix...
0
2016-09-22T17:43:14Z
[ "python", "arrays", "subtraction" ]
Python multithreading doesn't use common memory when the parent object is created inside a process
39,633,936
<p>I'm trying to implement a thread which will run and do a task in the background. Here's my code which gives expected output.</p> <p><strong>Code 1:</strong></p> <pre><code>from time import sleep from threading import Thread class myTest( ): def myThread( self ): while True: sleep( 1 ) ...
1
2016-09-22T08:28:26Z
39,635,639
<p>When you spawn the second process, is created about a <strong>copy</strong> of the first one, so <strong><em>the threads spawned in the 2nd process can only access that process stack</em></strong>.</p> <p>In <strong>code2</strong> The object of <code>myTest</code> is created in the constructor (<code>__init__</code...
1
2016-09-22T09:45:47Z
[ "python", "multithreading", "multiprocessing" ]
Python multithreading doesn't use common memory when the parent object is created inside a process
39,633,936
<p>I'm trying to implement a thread which will run and do a task in the background. Here's my code which gives expected output.</p> <p><strong>Code 1:</strong></p> <pre><code>from time import sleep from threading import Thread class myTest( ): def myThread( self ): while True: sleep( 1 ) ...
1
2016-09-22T08:28:26Z
39,636,139
<p>Forked process sees snapshot of parent's memory at the moment of <code>fork()</code>. When either parent or child changes a single bit, their memory mappings diverge, one sees what it changed, the other sees old state. I've explained the theory more verbose in this answer: <a href="http://stackoverflow.com/a/2983878...
1
2016-09-22T10:06:53Z
[ "python", "multithreading", "multiprocessing" ]
Pandas: groupby with condition
39,634,175
<p>I have dataframe:</p> <pre><code>ID,used_at,active_seconds,subdomain,visiting,category 123,2016-02-05 19:39:21,2,yandex.ru,2,Computers 123,2016-02-05 19:43:01,1,mail.yandex.ru,2,Computers 123,2016-02-05 19:43:13,6,mail.yandex.ru,2,Computers 234,2016-02-05 19:46:09,16,avito.ru,2,Automobiles 234,2016-02-05 19:48:36,2...
1
2016-09-22T08:40:00Z
39,634,269
<p>As <a href="http://stackoverflow.com/questions/39634175/pandas-groupby-with-condition/39634269#comment66572870_39634175">EdChum commented</a>, you can use <a href="http://pandas.pydata.org/pandas-docs/stable/groupby.html#filtration" rel="nofollow"><code>filter</code></a>:</p> <p>Also you can simplify aggregation by...
2
2016-09-22T08:45:18Z
[ "python", "pandas", "filter", "group-by", "condition" ]
How can i merge or Concatenate data frame having non equal column number in spark
39,634,215
<p>I am doing a project using spark. in some stage i need to merge or concatenate 3 data frame in single data frame. these data frame is coming from spark sql table i have used union function which already merge column with same number from two table but i need to merge unequal column values too . I am confused now i...
0
2016-09-22T08:42:35Z
39,636,216
<p>You could add a column with a default value before merging.</p> <pre><code>from pyspark.sql.functions import lit updDf = df2.withColumn('zero_column', lit(0)) df1.union(updDf) </code></pre>
0
2016-09-22T10:10:41Z
[ "python", "apache-spark", "pyspark", "apache-spark-sql", "spark-dataframe" ]
Is there a way to remove proper nouns from a sentence using python?
39,634,222
<p>Is there any package which i can use to to remove proper nouns from a sentence using Python?</p> <p>I know of a few packages like NLTK, Stanford and Text Blob which does the job(removes names) but they also remove a lot of words which start with a capital letter but are not proper nouns.</p> <p>Also, i cannot have...
1
2016-09-22T08:42:58Z
39,635,503
<p>If you want to just remove single words that are proper nouns, you can use <code>nltk</code> and tag your sentence in question, then remove all words with the tags that are proper nouns.</p> <pre><code>&gt;&gt;&gt; import nltk &gt;&gt;&gt; nltk.tag.pos_tag("I am named John Doe".split()) [('I', 'PRP'), ('am', 'VBP')...
1
2016-09-22T09:39:39Z
[ "python", "python-2.7" ]
ctypes c_char_p as an input to a function in python
39,634,225
<p>I am writing a C DLL and a python script for it as below:</p> <pre><code>//test.c __declspec(dllexport) HRESULT datafromfile(char * filename) { HRESULT errorCode = S_FALSE; if (pFileName == NULL) { return E_INVALIDARG; } FILE *fp = NULL; fopen_s(&amp;fp, pFileName, "rb"); if (fp...
0
2016-09-22T08:43:06Z
39,640,169
<p>A very silly mistake I was doing, I had kept the edid file in some other folder and was running the script from other. Instead of giving only the filename, I gave the relative path.</p>
0
2016-09-22T13:16:54Z
[ "python", "c", "dll", "ctypes" ]
Pandas append multiple columns for a single one
39,634,312
<p>How can I use pandas to append multiple KPI values per single customer efficiently?</p> <p>A join of the <code>pivoted</code> df with the <code>customers</code> df makes some problems because the country is the index of the pivoted data frame and the nationality is not in the index.</p> <pre><code>countryKPI = pd....
1
2016-09-22T08:46:57Z
39,634,397
<p>I think you can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.concat.html" rel="nofollow"><code>concat</code></a>:</p> <pre><code>df_pivoted = countryKPI.pivot_table(index='country', columns='indicator', values='value', ...
2
2016-09-22T08:50:59Z
[ "python", "pandas" ]
Pandas append multiple columns for a single one
39,634,312
<p>How can I use pandas to append multiple KPI values per single customer efficiently?</p> <p>A join of the <code>pivoted</code> df with the <code>customers</code> df makes some problems because the country is the index of the pivoted data frame and the nationality is not in the index.</p> <pre><code>countryKPI = pd....
1
2016-09-22T08:46:57Z
39,635,606
<p>You could counter the mismatch in the categories through <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.merge.html" rel="nofollow"><code>merge</code></a>:</p> <pre><code>df = pd.pivot_table(data=countryKPI, index=['country'], columns=['indicator']) df.index.name = 'nationality' ...
1
2016-09-22T09:43:56Z
[ "python", "pandas" ]
Django Restul return absolute URL's
39,634,342
<p>So I have a fairly straight forward serializer in <code>serializers.py</code></p> <pre><code>class ScheduleSerializer(serializers.ModelSerializer): class Meta: model = FrozenSchedule fields = ['startDate', 'endDate', 'client', 'url'] startDate = serializers.DateField(source='start_date') ...
1
2016-09-22T08:48:03Z
39,641,783
<p>Override HyperlinkedIdentityField.</p> <pre><code>class UrlHyperlinkedIdentityField(HyperlinkedIdentityField): def get_url(self, obj, view_name, request, format): if obj.pk is None: return None return self.reverse(view_name, kwargs={ 'slug': obj.client.slug, 'pk':...
6
2016-09-22T14:25:40Z
[ "python", "django", "rest", "django-rest-framework" ]
4 dimensional nested dictionary to pandas data frame
39,634,369
<p>I need your help with converting a multidimensional dict to a pandas data frame. I get the dict from a JSON file which I retrieve from a API call (Shopify).</p> <pre><code>response = requests.get("URL", auth=("ID","KEY")) data = json.loads(response.text) </code></pre> <p>The "data" dictionary looks as follows:</p...
0
2016-09-22T08:49:14Z
39,638,210
<p>I don't really understand how <code>json_normalize()</code> fails this so hard, I have similar data with twice the nesting depth and <code>json_normalize()</code> still manages to give me a much better result.</p> <p>I wrote this recursive function to replace the lists in your example with dictionaries:</p> <pre><...
2
2016-09-22T11:49:08Z
[ "python", "json", "pandas", "dictionary", "dataframe" ]
Support required with displaying a slideshow of Images in Python w/ TKinter
39,634,374
<p>I am trying to make a set of code that will open a window and displaying 6 images in sequence over and over again very quickly for 10 seconds. This is my code, however the program simply open a blank screen. What do I do? </p> <pre><code>import time import tkinter as tk root = tk.Tk() root.overrideredirect(True) w...
0
2016-09-22T08:49:36Z
39,634,732
<p>These are some changes in your code, It should work properly.</p> <pre><code>import tkinter as tk from itertools import cycle # foreign library, need to installed from ImageTk import PhotoImage images = ["first1.jpg", "first2.jpg", "first3.jpg", "first4.jpg"] photos = cycle(PhotoImage(file=image) for image in ima...
1
2016-09-22T09:06:18Z
[ "python", "tkinter", "gif" ]
value error: setting an array element with a sequence
39,634,375
<p>I'm making a fit with a scikit model (that is a ExtraTreesRegressor ) with the aim of make supervised features selection. </p> <p>I've made a toy example in order to be as most clear as possible. That's the toy code:</p> <pre><code>import pandas as pd import numpy as np from sklearn.ensemble import ExtraTreesRegr...
0
2016-09-22T08:49:39Z
39,634,485
<p>To convert Pandas' DataFrame to NumPy's matrix,</p> <pre><code>import pandas as pd def df2mat(df): a = df.as_matrix() n = a.shape[0] m = len(a[0]) b = np.zeros((n,m)) for i in range(n): for j in range(m): b[i,j]=a[i][j] return b df = pd.DataFrame({"A":[[1,2],[3,4]]}) b = df...
1
2016-09-22T08:55:18Z
[ "python", "arrays", "numpy", "scikit-learn", "data-fitting" ]
value error: setting an array element with a sequence
39,634,375
<p>I'm making a fit with a scikit model (that is a ExtraTreesRegressor ) with the aim of make supervised features selection. </p> <p>I've made a toy example in order to be as most clear as possible. That's the toy code:</p> <pre><code>import pandas as pd import numpy as np from sklearn.ensemble import ExtraTreesRegr...
0
2016-09-22T08:49:39Z
39,637,144
<p>Have a closer look at your X:</p> <pre><code>&gt;&gt;&gt; X array([[[10, 15, 12, 14], [20, 30, 10, 43]], [2, 2], [2, 2]], dtype=object) &gt;&gt;&gt; type(X[0,0]) &lt;class 'list'&gt; </code></pre> <p>Notice that it's <code>dtype=object</code>, and one of these objects is a <code>list</code>, hence "s...
1
2016-09-22T10:57:03Z
[ "python", "arrays", "numpy", "scikit-learn", "data-fitting" ]
Are methods instanciated with classes, consuming lots of memory (in Scala)?
39,634,577
<h2>Situation</h2> <p>I am going to build a program (in Scala or Python - not yet decided) that is intensive on data manipulation. I see two mayor approaches:</p> <ol> <li><strong>Approach:</strong> Define a collection of the data. Write my function. Send the entire dataset through the function.</li> <li><strong>Appr...
4
2016-09-22T08:59:23Z
39,635,598
<p>Which approach is best depends entirely on your problem. If you have only few operations, functions are simpler. If you have many operations which depend on the type/features of data, classes are efficient.</p> <p>Personally, I prefer having classes for the same type of data to improve abstraction and modularity. B...
1
2016-09-22T09:43:14Z
[ "python", "scala", "oop", "design", "jvm" ]
Can't I run file in temporary folder using subprocess?
39,634,736
<p>I was trying to using this code below...</p> <pre><code>**subprocess.Popen('%USERPROFILE%\\AppData\\Local\\Temp\\AdobeARM - Copy.log').communicate()** </code></pre> <p>but I got an error message. Is there anyone can help this?</p>
1
2016-09-22T09:06:30Z
39,634,806
<p>Since there's an environment variable in the path you can add <code>shell=True</code> to force running a batch process which will evaluate env. vars:</p> <pre><code>subprocess.Popen('"%USERPROFILE%\\AppData\\Local\\Temp\\AdobeARM - Copy.log"',shell=True).communicate() </code></pre> <p>Note the protection with quot...
2
2016-09-22T09:09:23Z
[ "python", "subprocess" ]
Python Convert Datetime from csv for matplotlib
39,634,777
<p>I am trying to plot from a csv file with column 1 as a datetime value, as below</p> <pre><code> 27-08-2016 08:43 21.38329164 </code></pre> <p>using this code:</p> <pre><code>from matplotlib import pyplot as plt from matplotlib import style import numpy as np import datetime as dt from datetime import datetime i...
0
2016-09-22T09:08:02Z
39,637,096
<p>Source: <a href="http://docs.scipy.org/doc/numpy/reference/generated/numpy.genfromtxt.html" rel="nofollow">numpy.genfromtxt</a></p> <pre><code>numpy.genfromtxt Returns:ndarray Data read from the text file. If usemask is True, this is a masked array. </code></pre> <p>@Ev. Kounis pointed out in comment section: num...
0
2016-09-22T10:54:59Z
[ "python", "csv", "pandas", "matplotlib", "genfromtxt" ]
Python Convert Datetime from csv for matplotlib
39,634,777
<p>I am trying to plot from a csv file with column 1 as a datetime value, as below</p> <pre><code> 27-08-2016 08:43 21.38329164 </code></pre> <p>using this code:</p> <pre><code>from matplotlib import pyplot as plt from matplotlib import style import numpy as np import datetime as dt from datetime import datetime i...
0
2016-09-22T09:08:02Z
39,646,628
<pre><code>from matplotlib import pyplot as plt from matplotlib import style import numpy as np import datetime as dt from datetime import datetime import matplotlib.dates as mdates style.use('ggplot') data = np.genfromtxt('I112-1.csv', unpack=True,dtype=None, names=True,delimiter = ',', converters={0: lambda x: date...
0
2016-09-22T18:42:52Z
[ "python", "csv", "pandas", "matplotlib", "genfromtxt" ]
Can someone please explain how to use threading in my script?
39,634,883
<p>I have been playing around with python for about three months and a few days ago I was needing to do some menial task (folder creation) and I actually made a script to do it.</p> <p>Out of pure perfectionism I wanted to add a progress bar but when I run the script, it hangs, then says complete once it's finished. I...
1
2016-09-22T09:12:31Z
39,647,363
<p>It's usually best to move your business logic out of the GUI code and place it in a separate module that isn't dependent on Qt. That makes it executing it in another thread easier.</p> <p>For functions that I want progress feedback on, I usually turn them into generators.</p> <pre><code>from __future__ import div...
0
2016-09-22T19:26:08Z
[ "python", "multithreading", "for-loop", "pyqt" ]
model field not rendering on html page
39,634,969
<blockquote> <p>I want to show title or description on html page but i am not getting. how can i do that ?</p> </blockquote> <p><strong>models.py</strong></p> <pre><code>class Event(models.Model): title = models.CharField(max_length=100) description = models.TextField() </code></pre> <p><strong>views.py<...
0
2016-09-22T09:16:55Z
39,635,026
<p>This is because you are returning a list of objects. Not just one.</p> <p>Try to loop it over.</p> <pre><code>{% for item in model %} &lt;h4&gt;{{ item.title }}&lt;/h4&gt; &lt;p&gt;{{ item.description }}&lt;/p&gt; {% endfor %} </code></pre> <p>Or update your view like:</p> <pre><code>def get_event_list(...
1
2016-09-22T09:19:15Z
[ "python", "html", "django" ]
re and binary file, python strange behavior
39,635,011
<p>i have a strange behavior of re.search on a binary file. Here is my python screenshot :</p> <p><a href="http://i.stack.imgur.com/OlLnw.png" rel="nofollow"><img src="http://i.stack.imgur.com/OlLnw.png" alt="enter image description here"></a></p> <p>As you can see, i have two problems :</p> <ul> <li>re can't find a...
-4
2016-09-22T09:18:36Z
39,635,128
<p><code>\x5b</code> is the ASCII <code>[</code> character, the left square bracket. That's a <em>regex meta character</em> forming the start of a <code>[...]</code> character class specification and needs to be escaped if you want to match a literal <code>[</code> character:</p> <pre><code>&gt;&gt;&gt; import re &gt;...
2
2016-09-22T09:24:27Z
[ "python", "regex", "binaryfiles" ]
Configure Sentry for different environments (staging, production)
39,635,027
<p>I want to configure Sentry in a Django app to report errors using different environments, like staging and production. This way I can configure alerting per environment.</p> <p>How can I configure different environments for Raven using different Django settings? The <code>environment</code> variable is not listed a...
1
2016-09-22T09:19:19Z
39,635,130
<p>You can use different settings for different branches. You have your main one, with all shared settings. And for develop branch you have dev.py settings and for production you have your prod.py. And while deploying your app you just specify which settings are meant to be used. If not you can also use <a href="https:...
0
2016-09-22T09:24:31Z
[ "python", "django", "sentry", "raven" ]
Configure Sentry for different environments (staging, production)
39,635,027
<p>I want to configure Sentry in a Django app to report errors using different environments, like staging and production. This way I can configure alerting per environment.</p> <p>How can I configure different environments for Raven using different Django settings? The <code>environment</code> variable is not listed a...
1
2016-09-22T09:19:19Z
39,648,090
<p>If you are setting environment as a constant within <a href="https://docs.djangoproject.com/en/dev/topics/settings/" rel="nofollow">Django settings</a>, you can set the <code>environment</code> argument when initializing the <code>raven-python</code> client.</p> <p>You're correct—our docs didn't include the envir...
2
2016-09-22T20:12:48Z
[ "python", "django", "sentry", "raven" ]
Replace value(s) in sublists, using a dictionary
39,635,117
<p>I have a dictionary, called <code>dictionary</code> and a list of lists (<code>newdetails</code>). I want to look up the key (which is the gtin) in the dictionary and if it matches the <code>index[0]</code> in each sublist in <code>newdetails</code>, to replace <code>index[3]</code> of each sublist with the correspo...
-1
2016-09-22T09:24:02Z
39,635,526
<p><em>Thanks <strong>@MartijnPieters</strong> for all your comments.</em> </p> <p><em>Will post all three versions of my code which I converted from less efficient to efficient with your help.</em></p> <p><strong>Version 1 :</strong> (<em>Refer to comment no 1 from Martijn</em>)</p> <pre><code> for k,v in dictionar...
0
2016-09-22T09:40:31Z
[ "python", "dictionary", "replace" ]
TypeError : string indices must be integers
39,635,198
<p>I've returned to Python after a few years doing C code and I'm a little confused while training myself to get my Python coding habits back.</p> <p>I've tried to run this little, very simple, piece of code but I keep getting a TypeError as described in the title. I've searched a lot but cannot figure out what is the...
0
2016-09-22T09:27:26Z
39,635,277
<p>You are iterating over the string, so each <code>i</code> is bound to a single character, <strong>not</strong> an integer. That's because Python <code>for</code> loops are <a href="https://en.wikipedia.org/wiki/Foreach_loop" rel="nofollow">Foreach constructs</a>, unlike C.</p> <p>Just use that character directly, n...
1
2016-09-22T09:30:30Z
[ "python" ]
Overloading and wrapping method of field of parent class in python
39,635,202
<p>For example I have something like this:</p> <pre><code>class A(object): def __init__(self): pass def foo(self, a, b, c): return a + b + c class B(object): def __init__(self): self.b = A() def wrapper_func(func): def wrapper(self, *args, **kwargs): return func(se...
0
2016-09-22T09:27:34Z
39,635,884
<p>Initialize <code>C</code>'s parent class using <code>super</code> and then pass all the parameters to the <code>foo</code> method of the composed class instance <code>A()</code> via the <em>inherited</em> attribute <code>b</code> of the class <code>C</code>:</p> <pre><code>def wrapper_func(func): def wrapper(se...
1
2016-09-22T09:55:36Z
[ "python", "overloading", "wrapper" ]
Sorting dictionary both desceding and ascending in Python
39,635,256
<p>I want to sort the dictionary by values. If the values are the same, then I want to sort it by keys.</p> <p>For example, if I have the string "bitter butter a butter baggy", output has to be [(butter,2),(a,1),(baggy,1),(bitter,1)).</p> <p>My below code sorts the dictionary by values in descending order. But I am n...
-4
2016-09-22T09:29:39Z
39,636,136
<p>For this, what you need is to write a comparator which sorts the values by count first and if they are equal then it sorts the values by the keys.</p> <pre><code>from collections import defaultdict def count_words(s): def comparator(first, second): if first[1] &gt; second[1]: return 1 ...
2
2016-09-22T10:06:46Z
[ "python" ]
Sorting dictionary both desceding and ascending in Python
39,635,256
<p>I want to sort the dictionary by values. If the values are the same, then I want to sort it by keys.</p> <p>For example, if I have the string "bitter butter a butter baggy", output has to be [(butter,2),(a,1),(baggy,1),(bitter,1)).</p> <p>My below code sorts the dictionary by values in descending order. But I am n...
-4
2016-09-22T09:29:39Z
39,636,191
<p>I suppose this would help</p> <pre><code>s = { "A":1, "B":1, "C":1, "D":0, "E":2, "F":0 } rez = sorted(s.items(), key = lambda x: (x[1],x[0])) </code></pre> <p>Result is</p> <pre><code>[('D', 0), ('F', 0), ('A', 1), ('B', 1), ('C', 1), ('E', 2)] </code></pre> <p>If you need a reversed order, just use -x[1] inst...
1
2016-09-22T10:09:37Z
[ "python" ]
Scapy verbose mode documentation
39,635,324
<p>I understand that:</p> <pre><code>conf.verb = 0 </code></pre> <p>Disables Scapy verbose mode but where is the documentation to confirm this?</p> <p>My googling has failed me.</p>
1
2016-09-22T09:32:54Z
39,638,193
<p>Actually, <code>conf</code>'s docstring specifies that configuring <code>conf.verb = 0</code> sets the level of verbosity to <em>almost mute</em>, which implies that it doesn't disable it altogether.</p> <p>The relevant excerpt from the docstring is as follows:</p> <pre><code>verb : level of verbosity, from 0 ...
1
2016-09-22T11:48:26Z
[ "python", "documentation", "scapy", "verbose" ]
How to construct data structure with variable size elements
39,635,372
<p>I am trying to construct the structure with variable size of the element <code>value</code> from class <code>val</code> : </p> <pre><code>from construct import * TEST = Struct("test", UInt8("class"), Embed(switch(lambda ctx: ctx.class) { 1: UInt8("value"), 2: UInt16(...
0
2016-09-22T09:34:45Z
39,637,876
<p>You can use multiple <a href="https://docs.python.org/3/library/struct.html#format-characters" rel="nofollow">format string</a> to change <code>struct</code> behaviour and <code>struct.unpack_from</code> with <code>struct.calcsize</code> to continue parsing bytearray from the end of the last found byte sequence:</p>...
0
2016-09-22T11:33:37Z
[ "python", "construct" ]
Pass-through/export whole third party module (using __all__?)
39,635,448
<p>I have a module that wraps another module to insert some shim logic in some functions. The wrapped module uses a settings module <code>mod.settings</code> which I want to expose, but I don't want the users to import it from there, in case I would like to shim something there as well in the future. I want them to imp...
0
2016-09-22T09:37:29Z
39,636,745
<p>If I understand the situation correctly, you're writing a module <code>wrapmod</code> that is intended to transform parts of an existing package <code>mod</code>. The specific part you're transforming is the submodule <code>mod.settings</code>. You've imported the <code>settings</code> module and made your changes t...
1
2016-09-22T10:36:36Z
[ "python", "python-3.x", "python-3.4" ]
Pass-through/export whole third party module (using __all__?)
39,635,448
<p>I have a module that wraps another module to insert some shim logic in some functions. The wrapped module uses a settings module <code>mod.settings</code> which I want to expose, but I don't want the users to import it from there, in case I would like to shim something there as well in the future. I want them to imp...
0
2016-09-22T09:37:29Z
39,637,558
<p>I ended up making a code-generator for a thin wrapper module instead, since the <code>sys.module</code> hacking broke all IDE integration. </p> <pre><code>from ... import mod # this is just a pass-through wrapper around mod.settings __all__ = mod.__all__ # generate pass-through wrapper around mod.settings; doesn'...
0
2016-09-22T11:17:51Z
[ "python", "python-3.x", "python-3.4" ]
Updating already existing json file python
39,635,480
<p>I have a json file and I want to update 'filename' field with the filenames I scp from a remote server. I am pretty new to python but learning as I go. </p> <p>JSON file:</p> <pre><code>{"path":"/home/Document/Python", "md5s":[{"filename":"", "md5":"", "timestamp":""}, {"filename":"", "md5":"", ...
-1
2016-09-22T09:38:29Z
39,636,809
<p>This is as close as I can come to sorting the code for you. I don't know why you get <code>KeyError</code> but you didn't implement a counter as suggested in the comments. Since I don't have access to <code>config['servers']</code>, the counter might be in the wrong place, in which case put it in the inner <code>for...
1
2016-09-22T10:39:26Z
[ "python", "json" ]
Updating already existing json file python
39,635,480
<p>I have a json file and I want to update 'filename' field with the filenames I scp from a remote server. I am pretty new to python but learning as I go. </p> <p>JSON file:</p> <pre><code>{"path":"/home/Document/Python", "md5s":[{"filename":"", "md5":"", "timestamp":""}, {"filename":"", "md5":"", ...
-1
2016-09-22T09:38:29Z
39,637,697
<p>If I have correctly understood, you start with a json file containing a list of references to file, and you want to update the next element of the list.</p> <p>You could browse the <code>data['md5s']</code> searching for the first element where the <code>filename</code> field is empty, and add a new dictionnary to...
1
2016-09-22T11:24:28Z
[ "python", "json" ]
Assigning to global var in Python?
39,635,483
<p>I am trying out Python for a new project, and in that state, need some global variable. To test without changing the hardcoded value, I've tried to make a function that reassign thoses variables:</p> <pre><code>foo = None; def setFoo(bar): global foo = bar; setFoo(1); </code></pre> <p>However, this get:</p> ...
0
2016-09-22T09:38:34Z
39,635,512
<p><code>global</code> and assignment are both statements. You can't mix them on the same line.</p>
3
2016-09-22T09:40:01Z
[ "python" ]
Assigning to global var in Python?
39,635,483
<p>I am trying out Python for a new project, and in that state, need some global variable. To test without changing the hardcoded value, I've tried to make a function that reassign thoses variables:</p> <pre><code>foo = None; def setFoo(bar): global foo = bar; setFoo(1); </code></pre> <p>However, this get:</p> ...
0
2016-09-22T09:38:34Z
39,635,529
<pre><code>foo = None; def setFoo(bar): global foo foo = bar setFoo(1); </code></pre>
3
2016-09-22T09:40:36Z
[ "python" ]
Assigning to global var in Python?
39,635,483
<p>I am trying out Python for a new project, and in that state, need some global variable. To test without changing the hardcoded value, I've tried to make a function that reassign thoses variables:</p> <pre><code>foo = None; def setFoo(bar): global foo = bar; setFoo(1); </code></pre> <p>However, this get:</p> ...
0
2016-09-22T09:38:34Z
39,635,572
<p>As saurabh baid pointed out, the correct syntax is</p> <pre><code>foo = None def set_foo(bar): global foo foo = bar set_foo(1) </code></pre> <p>Using the <code>global</code> keyword allows the function to access the global scope (i.e. the scope of the module)</p> <p>Also notice how I renamed the variab...
1
2016-09-22T09:42:24Z
[ "python" ]
Assigning to global var in Python?
39,635,483
<p>I am trying out Python for a new project, and in that state, need some global variable. To test without changing the hardcoded value, I've tried to make a function that reassign thoses variables:</p> <pre><code>foo = None; def setFoo(bar): global foo = bar; setFoo(1); </code></pre> <p>However, this get:</p> ...
0
2016-09-22T09:38:34Z
39,635,632
<p><code>global</code> and <code>foo = bar</code> on separate lines</p> <pre><code>foo = None def setFoo(bar): global foo foo = bar setFoo(1) </code></pre> <p>don't use semicolon: <a href="http://stackoverflow.com/questions/12335358/python-what-does-a-semi-colon-do">Python: What Does a Semi Colon Do?</a></p...
1
2016-09-22T09:45:21Z
[ "python" ]
Assigning to global var in Python?
39,635,483
<p>I am trying out Python for a new project, and in that state, need some global variable. To test without changing the hardcoded value, I've tried to make a function that reassign thoses variables:</p> <pre><code>foo = None; def setFoo(bar): global foo = bar; setFoo(1); </code></pre> <p>However, this get:</p> ...
0
2016-09-22T09:38:34Z
39,635,754
<p>Python doesn't require you to explicitly declare variables and automatically assumes that a variable that you assign has function scope unless you tell it otherwise. The <code>global</code> keyword is the means that is provided to tell it otherwise. And you can't assign value when you declare it as global. Correct w...
2
2016-09-22T09:50:20Z
[ "python" ]
Unable to run AppEngine django application locally
39,635,544
<p>I am on <strong>windows 10</strong>, Installed <strong>python 2.7.11</strong>.I have a app engine application.I am able to run it locally with django, It is working perfectly.But when I am trying to run it via <strong>dev_appengine.py</strong> I am getting this error.</p> <p><strong><em><a href="http://i.stack.imgu...
0
2016-09-22T09:41:22Z
39,673,958
<p>Please include this code in your appengine_config.py file, </p> <pre><code>import os on_appengine = os.environ.get('SERVER_SOFTWARE','').startswith('Development') if on_appengine and os.name == 'nt': os.name = None </code></pre>
1
2016-09-24T07:54:45Z
[ "python", "django", "python-2.7", "google-app-engine" ]
Python - Removing \n when using default split()?
39,635,566
<p>I'm working on strings where I'm taking input from the command line. For example, with this input:</p> <pre><code>format driveName "datahere" </code></pre> <p>when I go string.split(), it comes out as:</p> <pre><code>&gt;&gt;&gt; input.split() ['format, 'driveName', '"datahere"'] </code></pre> <p>which is what I...
0
2016-09-22T09:42:06Z
39,635,616
<p>Use <code>None</code> to get the default whitespace splitting behaviour with a limit:</p> <pre><code>input.split(None, 2) </code></pre> <p>This leaves the whitespace at the <em>end</em> of <code>input()</code> untouched.</p> <p>Or you could strip the values afterwards; this removes whitespace from the start and e...
0
2016-09-22T09:44:40Z
[ "python" ]
Python - Removing \n when using default split()?
39,635,566
<p>I'm working on strings where I'm taking input from the command line. For example, with this input:</p> <pre><code>format driveName "datahere" </code></pre> <p>when I go string.split(), it comes out as:</p> <pre><code>&gt;&gt;&gt; input.split() ['format, 'driveName', '"datahere"'] </code></pre> <p>which is what I...
0
2016-09-22T09:42:06Z
39,635,699
<p>Default separator in <code>split()</code> is all whitespace which includes newlines <code>\n</code> and spaces. </p> <p>Here is what the <a href="https://docs.python.org/2/library/stdtypes.html#str.split" rel="nofollow">docs on split</a> say:</p> <pre><code>str.split([sep[, maxsplit]]) If sep is not specified or ...
2
2016-09-22T09:48:03Z
[ "python" ]
Python - Removing \n when using default split()?
39,635,566
<p>I'm working on strings where I'm taking input from the command line. For example, with this input:</p> <pre><code>format driveName "datahere" </code></pre> <p>when I go string.split(), it comes out as:</p> <pre><code>&gt;&gt;&gt; input.split() ['format, 'driveName', '"datahere"'] </code></pre> <p>which is what I...
0
2016-09-22T09:42:06Z
39,635,718
<p>The default <code>str.split</code> targets a number of "whitespace characters", including also tabs and others. If you do <code>str.split(' ')</code>, you tell it to split <em>only</em> on <code>' '</code> (a space). You can get the default behavior by specifying <code>None</code>, as in <code>str.split(None, 2)</co...
1
2016-09-22T09:48:39Z
[ "python" ]
Logging exceptions in Django commands
39,635,579
<p>I have implemented custom commands in Django, and their exceptions aren't logged in my log file.</p> <p>I created an application <code>my_app_with_commands</code> which contains a directory <code>management/commands</code> in which I implemented some commands.</p> <p>A sample command, could be like this, which cra...
0
2016-09-22T09:42:35Z
39,639,468
<p>One of the ways - you can edit <strong>manage.py</strong> file to add a try/except block in it:</p> <pre><code>log = logging.getLogger('my_app_with_commands') # ... try: execute_from_command_line(sys.argv) except Exception as e: log.error('your exception log') raise e </code></pre>
0
2016-09-22T12:46:24Z
[ "python", "django", "logging" ]
What is a good way to open configs or files during unit test in python?
39,635,850
<p>I am wondering what is a good way to read config or local file during the unit testing.</p> <p>I think it could be either to write the test config file during time. For example:</p> <pre><code>def setUp(self): self.config = ConfigParser.RawConfigParser() self.config.add_section('TestingSection') self.c...
1
2016-09-22T09:54:03Z
39,638,185
<p>A good way is to not have to open them at all.</p> <p>For your functions relying on a config file, you could create a fake object that implements the required methods that your particular function relies on. It might just be a <code>get</code> method, that supports getting a "section".</p> <p>This is exploiting <...
1
2016-09-22T11:48:01Z
[ "python", "unit-testing", "python-unittest" ]
Concatanate tuples in list of tuples
39,635,919
<p>I have a list of tuples that looks something like this: </p> <pre><code>tuples = [('a', 10, 11), ('b', 13, 14), ('a', 1, 2)] </code></pre> <p>Is there a way that i can join them together based on the first index of every tuple to make a each tuple contain 5 elements. I know for a fact there isn't more that 2 of ea...
-1
2016-09-22T09:57:06Z
39,636,306
<p>Assuming there are only one or two of every letter in the list as stated:</p> <pre><code>import itertools tuples = [('a', 10, 11), ('b', 13, 14), ('a', 1, 2)] result = [] key = lambda t: t[0] for letter,items in itertools.groupby(sorted(tuples,key=key),key): items = list(items) if len(items) == 1: ...
2
2016-09-22T10:14:30Z
[ "python", "list", "tuples" ]
travis-CI error after pull request
39,635,938
<p>I've done my first pull request on github recently.<br> The project i try to contribute to is written in python, and it uses tox and travis CI.<br> When i look at github.com/author/project/pulls, i see "Error: The Travis CI build could not complete due to an error" message near my request.<br> Never worked with CI t...
2
2016-09-22T09:58:03Z
39,699,023
<p>Yes, you should remove <code>--use-mirrors</code> from the config file, since its not used anymore and makes the build fail.</p> <p>The author probably didn't updated the repository for a while (or only the config).</p> <p>Best ;-)</p>
2
2016-09-26T09:21:12Z
[ "python", "github", "travis-ci", "pull-request", "tox" ]
How to set time limit in real time video capturing?
39,635,970
<p>I have code that capture video from camera.The frames captured are append to a list.But how to set time limit to this capture?.I only want to capture the first two minutes after that the recording must stop.My code is</p> <pre><code>import cv2 import numpy #creating video capture object capture=cv2.VideoCapture(0)...
2
2016-09-22T09:59:37Z
39,636,782
<p>Use time package</p> <pre><code>import cv2 import numpy import time capture=cv2.VideoCapture(0) capture.set(3,640) capture.set(4,480) frame_set=[] start_time=time.time() while(True): ret, frame = capture.read() gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) frame_set.append(gray) cv2.imshow('frame',...
1
2016-09-22T10:38:20Z
[ "python", "python-2.7", "video", "image-processing" ]
How to convert pandas dataframe rows into columns, based on category?
39,635,993
<p>I have a pandas data frame with a category variable and some number variables. Something like this: </p> <pre><code>ls = [{'count':5, 'module':'payroll', 'id':2}, {'count': 53, 'module': 'general','id':2}, {'id': 5,'count': 35, 'module': 'tax'}, ] df = pd.DataFrame.from_dict(ls) </code></pre> <p>The df looks like ...
2
2016-09-22T10:00:36Z
39,636,105
<p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.groupby.html" rel="nofollow"><code>groupby</code></a> by columns which first create new <code>index</code> and last <code>column</code>. then need aggreagate some way - I use <a href="http://pandas.pydata.org/pandas-docs/stab...
2
2016-09-22T10:05:08Z
[ "python", "pandas" ]
Mardown fails combining fenced_code and attr_list
39,636,154
<p>I'm trying to write markdown files for mkdocs and want an id attribute with the pre tag, generated be fenced_code. If i use both extensions in combination there is no pre-tag but a p(aragraph tag):</p> <pre><code>import markdown text = """# Welcome This is *true* markdown text. ````python a=5 print "Hello World"...
0
2016-09-22T10:07:21Z
39,787,459
<p>I posted an issue to mkdocs on github and they say it is not possible at the moment. So i tried something else. Because i needed the id of the pre-element in a javascript-function which reacts to an onclick, i figured out, how to access the pre content from there. I was lucky to find that parentNode.previousElementS...
0
2016-09-30T08:53:40Z
[ "javascript", "python", "html", "markdown", "mkdocs" ]
I got an error while using git commit -m "Added a Procfile" on heroku
39,636,164
<p>I'm using heroku for deploying a python-django project.I used <code>git add .</code> command and after that I gave <code>git commit -m "Added a Procfile"</code> .I got an error </p> <pre><code>error: pathspec 'a' did not match any file(s) known to git. error: pathspec 'Procfile”' did not match any file(s) known t...
0
2016-09-22T10:08:04Z
39,636,207
<p>Your error shows that you are somehow using curly quotes, not straight quotes. Type your command directly into the command window rather than copying and pasting from a doc.</p>
2
2016-09-22T10:10:17Z
[ "python", "django", "git", "heroku" ]
Get pandas subseries by values when each value is a ndarray
39,636,224
<p>I want to make a subseries by values when the Series consists of ndarrays.</p> <p>This one works.</p> <pre><code>sa = pd.Series([1,2,35,2],index=list('abcd')) sa[sa==2] </code></pre> <p>Results</p> <pre><code>b 2 d 2 dtype: int64 </code></pre> <p>Why below codes does not work? What should I change?. It gi...
1
2016-09-22T10:11:02Z
39,636,326
<p>The comparison operator doesn't understand how to compare for equality with np arrays here so you can use <code>apply</code> with a <code>lambda</code>:</p> <pre><code>In [211]: sa2[sa2.apply(lambda x: (x == ar).all())] Out[211]: a [out] d [out] dtype: object </code></pre> <p>So here we compare against the ...
2
2016-09-22T10:15:06Z
[ "python", "pandas", "indexing", "series" ]
Selenium webdriverwait: __init__() takes exactly 2 arguments (3 given)
39,636,236
<p>gives the error as </p> <pre><code>Traceback (most recent call last): File "p3.py", line 21, in &lt;module&gt; WebDriverWait(driver, timex).until(EC.presence_of_element_located(by, element)) TypeError: __init__() takes exactly 2 arguments (3 given) </code></pre> <p>I have not used <code>__init__()</code> why...
0
2016-09-22T10:11:31Z
39,636,404
<p><code>presence_of_element_located()</code> only takes one argument, a locator, which is a tuple. You forgot to add the <code>(...)</code> parentheses needed for a tuple in a call:</p> <pre><code>WebDriverWait(driver, timex).until( EC.presence_of_element_located((by, element))) # these make this a tuple...
1
2016-09-22T10:19:08Z
[ "python", "selenium", "selenium-chromedriver" ]
Can I create cloudshell shell without driver?
39,636,277
<p>I would like to build a quali cloudshell shell with driver. I.e. just a data model without python driver. Can I do that when working with shellfoundry?</p>
1
2016-09-22T10:13:14Z
39,637,107
<p>Yes, you can create a CloudShell Shell without a driver whether using ShellFoundry or not. </p> <p>In order to remove the driver from being attached to the Model of the Shell, open <strong>shellconfig.xml</strong> file located under <strong>datamodel</strong> directory for editing. </p> <p>Then remove <strong>Driv...
0
2016-09-22T10:55:41Z
[ "python", "continuous-integration", "continuous-deployment", "devops" ]
Shopify + Python library: how to create new shipping address
39,636,421
<p>I'm having troubles adding a new shipping address by using the Python API.</p> <p>Let's put aside the auth part and assume I have the customer_id.</p> <p>I couldn't find how to put the correct lines of code to achieve this goal. I've searched the shopify tests folder but couldn't find such example there.</p> <p>C...
2
2016-09-22T10:19:43Z
39,719,756
<p>While there is currently no <code>CustomerAddress</code> resource implemented into the official python Shopify API client, you can append the address information directly onto the <code>addresses</code> attribute of the <code>Customer</code> resource as a work-around:</p> <pre><code>customer_id = 1234567890 new_ad...
0
2016-09-27T08:28:24Z
[ "python", "shopify" ]