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
Python, Why is my script not running?
37,984,332
<p>I've made a script to calculate the probability of a point in a tennis match, depending on the current score.</p> <p>But for some reason when I want to run my script nothing happens. Explination is on the script.</p> <p>Any suggestions?</p> <pre><code> ## calculate the probability of server winning a single ga...
-4
2016-06-23T06:58:34Z
37,984,715
<p><code>s</code> is a float, so, replace this line:</p> <pre><code>def gameProb(s=[0.6], v=2, w=1): </code></pre> <p>with</p> <pre><code>def gameProb(s=0.6, v=2, w=1): </code></pre> <p>and call the function at the end of the script:</p> <pre><code>print gameProb() </code></pre> <p>You can also call it as: </p> ...
1
2016-06-23T07:18:09Z
[ "python" ]
How to increase the perfomance of R in machine learning?
37,984,354
<p>I am using both R and python(Anaconda).When it comes to modelling,R is taking more time for the same operation.Is there any method for parallel operations or multi threading in R?</p>
2
2016-06-23T06:59:54Z
37,984,647
<p>When using machine learning algorithms in R you can call some libraries that allow parallelization. In the example below the difference is huge. </p> <p>You can call them like this (note that the '2' depends on your number of clusters):</p> <pre><code>library(doParallel) cl &lt;- makeCluster(2) registerDoParallel(...
1
2016-06-23T07:14:32Z
[ "python", "performance", "machine-learning", "regression" ]
How do I store extracted titles from URL using python?
37,984,365
<p>I am given the task to extract title and meta_description from a list of URLs. I have used goose. Am I doing it correctly? </p> <p>from goose import Goose import urlparse import numpy as np import os import pandas</p> <pre><code>os.chdir("C:\Users\EDAWES01\Desktop\Cookie profiling") data = pandas.r...
1
2016-06-23T07:00:31Z
37,985,307
<p>You can open the url and assign it to any channel. When you read it and store in any variable, that would be page source with the html tags and values. The required information from that page, you can fetch using a regular expression matching your search criteria. You can do something like this:</p> <pre><code>sock...
0
2016-06-23T07:48:39Z
[ "python", "url", "store", "meta-tags", "goose" ]
Integrate tornado with celery: RuntimeError: tornado-redis must be installed to use the redis backend
37,984,445
<p>When I use tornado-celery to integrate tornado and celery,there is an error occurs: ```</p> <pre><code>traceback (most recent call last): File "/usr/local/lib/python2.7/dist-packages/tornado/web.py", line 1369, in _stack_context_handle_exception raise_exc_info((type, value, traceback)) File "/usr/local/lib/...
0
2016-06-23T07:04:20Z
37,984,743
<p>Solved, the tornado-redis version is too low. When I update the version to the newest:tornado-redis (2.4.18), everything is OK.</p>
0
2016-06-23T07:19:21Z
[ "python", "redis", "celery", "tornado" ]
How to write a complete Python wrapper around a C Struct using Cython?
37,984,481
<p>I am writing a a high level interface for a C library for Python using Cython.<br> I have an extension Type <code>A</code> that initializes the library with a pointer to a more complex C context structure <code>c_context</code>. The pointer is saved in <code>A</code>.<br> <code>A</code> also has a <code>def</code> f...
10
2016-06-23T07:06:04Z
37,998,936
<p>The trouble is that Cython doesn't know the data type of your <code>py_context</code> variable at compile time. Calls to <code>cdef</code> functions are resolved at compile time and there exists no mechanism to figure it out at runtime by attribute lookup (as with normal Python functions).</p> <p>[Note that <code>d...
5
2016-06-23T18:12:48Z
[ "python", "c", "wrapper", "cython" ]
Version of python script
37,984,531
<p>I was wondering if it is possible to set a version to a python script. I would like to be able to see the version of a script by right clicking on the file, selecting properties and then select the version tab.</p> <p>This tab exists on many other files, but is it possible to lure it out on a .py/.pyw file?</p>
1
2016-06-23T07:08:19Z
37,985,547
<p>Those are textfiles and thus they don't contain any header to include such information.</p> <p>Specify the version with <code>__version__</code> attribute and ask Microsoft to write this functionality.</p>
1
2016-06-23T08:01:37Z
[ "python", "windows", "file", "properties", "version" ]
Version of python script
37,984,531
<p>I was wondering if it is possible to set a version to a python script. I would like to be able to see the version of a script by right clicking on the file, selecting properties and then select the version tab.</p> <p>This tab exists on many other files, but is it possible to lure it out on a .py/.pyw file?</p>
1
2016-06-23T07:08:19Z
37,986,467
<p><code>__version__</code> is a string, but sometimes it's also a float or tuple. You should also make sure that the version number conforms to the format described in <a href="https://www.python.org/dev/peps/pep-0440/" rel="nofollow">PEP 440</a> (<a href="https://www.python.org/dev/peps/pep-0386/" rel="nofollow">PEP ...
-1
2016-06-23T08:44:14Z
[ "python", "windows", "file", "properties", "version" ]
file sourcing within cgi failed
37,984,559
<p>My cgi file:</p> <pre><code>#!/bin/sh -f source /Users/sfma/sastbx/build/setpaths_all.sh python processQuery.py </code></pre> <p>Then "Internal Server Error" arises. I checked the error_log, and it says:</p> <pre><code> [Thu Jun 23 15:02:39.809441 2016] [cgi:error] [pid 1327] [client ::1:52131] AH01215: /User...
0
2016-06-23T07:10:02Z
37,991,955
<p>I finally solved this problem. </p> <p>Since <code>python</code> works fine while <code>/Users/sfma/Library/Enthought/canopy_64bit/User/bin/python</code> leads to a problem, I hard coded some variables in files libtbx.path_utility and sastbx.python to "python" instead of what they used to be: "/Users/sfma/sastbx/b...
0
2016-06-23T12:42:24Z
[ "python", "permissions", "cgi" ]
How to use SURF in python?
37,984,709
<p>I am going to work on a image processing project "currency recognition system " in pycharm. I just want to match the input image with the existing images in the database and show the result(database image name). How can I do this with SURF function. I checked it on internet but didn't get any relevant code. Could yo...
1
2016-06-23T07:17:33Z
37,985,407
<p>You're looking for an implementation of Speed Up Robust Features (SURF). You'll be better off using a library like OpenCV for your use case. </p> <p>Read the <a href="http://opencv.org/documentation.html" rel="nofollow">OpenCV docs</a> on how to Install.<br> <a href="http://docs.opencv.org/3.0-beta/doc/py_tutorials...
0
2016-06-23T07:54:10Z
[ "python", "image-processing", "surf" ]
Pandas - return a dataframe after groupby
37,984,736
<p>I have a Pandas <code>df</code>:</p> <pre><code>Name No A 1 A 2 B 2 B 2 B 3 </code></pre> <p>I want to group by column <code>Name</code>, sum column <code>No</code> and then return a 2-column dataframe like this:</p> <pre><code>Name No A 3 B 7 </code></pre> <p>I tr...
1
2016-06-23T07:19:12Z
37,984,759
<p>Add parameter <code>as_index=False</code> to <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.groupby.html" rel="nofollow"><code>groupby</code></a>:</p> <pre><code>print (df.groupby(['Name'], as_index=False)['No'].sum()) Name No 0 A 3 1 B 7 </code></pre> <p>Or call <a hr...
2
2016-06-23T07:20:10Z
[ "python", "pandas", "dataframe", "group-by" ]
CPP Call slower than Python Interface Call
37,984,768
<p>The Github Page of Caffe contains a Windows Branch. I have taken this branch and created a Windows DLL. It is losely based on <a href="https://github.com/BVLC/caffe/blob/master/examples/cpp_classification/classification.cpp" rel="nofollow">https://github.com/BVLC/caffe/blob/master/examples/cpp_classification/classif...
0
2016-06-23T07:20:23Z
38,026,667
<p>We concluded following: Caffe uses GLog. GLog has Fatal Warning which may look like this</p> <pre><code>CHECK(a&lt;=b) &lt;&lt; "a must be bigger than b"; </code></pre> <p>These warnings let the program crash and are hardly catchable. For that we have created a class to replace GLog. It is fairly simple and uses s...
1
2016-06-25T08:47:38Z
[ "python", "c++", "windows", "dll", "caffe" ]
In a Flask App, where should Celery be instantiated?
37,984,809
<p>I have a Flask app, which is a very basic app with a POST handler and some DB insertions. The DB insertions are set as tasks using Celery. If I put my Celery instance creation and tasks definition in <code>tasks.py</code> file, and call the functions from my <code>main.py</code> file (which also has the Flask app cr...
3
2016-06-23T07:22:46Z
38,004,266
<p>The Flask docs <a href="http://flask.pocoo.org/docs/0.11/patterns/celery/" rel="nofollow">suggest</a> subclassing Celery's Task class and wrapping task execution in a Flask app context. So in <code>task.py</code> if your Flask app instance is named <code>app</code> and your Celery instance is named <code>celery</cod...
1
2016-06-24T01:17:27Z
[ "python", "flask", "celery", "message-queue" ]
Get text from a label using Selenium (Python)
37,984,868
<p>I'm trying to read the text from a label that changes according to certain conditions (eg. if you enter a Username already in use, the label will display "Username already in use").</p> <p>I've been trying to read in the text from the label that gets displayed, but nothing I've tried has worked so far.</p> <p>The ...
0
2016-06-23T07:26:20Z
37,985,055
<pre><code>content = driver.find_element_by_class_name('fa-exclamation-circle') content.is_displayed() </code></pre> <p>You can use the find_element_by_class_name built in method.</p> <p>You need to pass the class name as a parameter.</p>
0
2016-06-23T07:36:14Z
[ "python", "selenium" ]
Get text from a label using Selenium (Python)
37,984,868
<p>I'm trying to read the text from a label that changes according to certain conditions (eg. if you enter a Username already in use, the label will display "Username already in use").</p> <p>I've been trying to read in the text from the label that gets displayed, but nothing I've tried has worked so far.</p> <p>The ...
0
2016-06-23T07:26:20Z
37,986,149
<p>I didn't manage to find a way to read the text, but I found another solution. Instead of checking what text is displayed on the screen, I check to see which of the labels is being displayed (I'm able to do this because each of the labels is given a unique ID.</p> <p>So the code will look something like:</p> <pre><...
0
2016-06-23T08:30:06Z
[ "python", "selenium" ]
sklearn Linear Regression coefficients have single value output
37,984,934
<p>I am using dataset to see the relationship between salary and college GPA. I am using sklearn linear regression model. I think the coefficients should be intercept and the coff. value of corresponding feature. But the model is giving a single value. </p> <pre><code>from sklearn.cross_validation import train_test_sp...
-1
2016-06-23T07:29:48Z
37,985,322
<pre><code>salary_pred = regression.predict(gpa_test) print salary_pred print salary_test </code></pre> <p>I think s<code>alary_pred = regression.coef_*salary_test</code>. Have a try that printed <code>salary_pred</code> and <code>salary_test</code> via pyplot. Figure can explain every thing.</p>
0
2016-06-23T07:49:24Z
[ "python", "pandas", "scikit-learn", "sklearn-pandas" ]
sklearn Linear Regression coefficients have single value output
37,984,934
<p>I am using dataset to see the relationship between salary and college GPA. I am using sklearn linear regression model. I think the coefficients should be intercept and the coff. value of corresponding feature. But the model is giving a single value. </p> <pre><code>from sklearn.cross_validation import train_test_sp...
-1
2016-06-23T07:29:48Z
37,985,533
<p>Try:</p> <pre><code>regression = LinearRegression(fit_intercept =True) regression.fit(gpa_train, salary_train) </code></pre> <p>and the results will be in</p> <pre><code>regression.coef_ regression.intercept_ </code></pre> <p>In order to get a better understanding of your linear regression, you maybe should cons...
4
2016-06-23T08:00:51Z
[ "python", "pandas", "scikit-learn", "sklearn-pandas" ]
Python - writing to python files?
37,984,952
<p>Is there some more convenient way to write into python files than using read/write for any file (like txt files etc).</p> <p>I mean python knows what actually is the structure of python file, so if I need to write into it, maybe there is some more convenient way to do it?</p> <p><strong>If there is no such way</st...
1
2016-06-23T07:30:37Z
37,991,036
<p>I came up with solution. It is not very clean, but it works. If someone has a better answer, please write it.</p> <pre><code>content = '' file = '__config__.py' with open(file, 'r') as f: content = f.readlines() for i, line in enumerate(content): # Could use regex too here if "'version'" in ...
0
2016-06-23T12:00:49Z
[ "python", "python-2.7", "file-writing" ]
Python - writing to python files?
37,984,952
<p>Is there some more convenient way to write into python files than using read/write for any file (like txt files etc).</p> <p>I mean python knows what actually is the structure of python file, so if I need to write into it, maybe there is some more convenient way to do it?</p> <p><strong>If there is no such way</st...
1
2016-06-23T07:30:37Z
37,991,622
<p>In order to modify the config file, you can simply do sth like this:</p> <pre><code>import fileinput lines = fileinput.input("__config__.py", inplace=True) nameTag="\'name\'" versionTag="\'version\'" name="" newVersion="\'1.0.0\'" for line in lines: if line[0] != "'": print(line) else: if ...
0
2016-06-23T12:27:47Z
[ "python", "python-2.7", "file-writing" ]
Error when inserting row into MySQL database from Python
37,985,198
<p>I'm trying to update an empty mySQL database using Python. </p> <p>This is the error I receive:</p> <blockquote> <p>pymysql.err.InternalError: (1416, 'Cannot get geometry object from data you send to the GEOMETRY field')</p> </blockquote> <p>Here's the problematic code:</p> <pre><code>try: with connection....
0
2016-06-23T07:43:16Z
37,985,555
<p>It looks like you're using the MySQL type <code>linestring</code> to represent a string, while in MySQL the correct type to represent a string of characters would be <code>text</code> or <code>varchar(&lt;some_length&gt;)</code>. <code>linestring</code> is a representation of a geometric line, as you can see here: <...
1
2016-06-23T08:02:17Z
[ "python", "mysql", "pymysql" ]
what's wrong with configure fail:C compiler cannot create executables(configure: exit 77)
37,985,352
<p>I am a newer in CentOs. I try to ./configure with python2.7 then meet this problem</p> <p>See `config.log' for more details</p> <pre><code>This file contains any messages produced by compilers </code></pre> <p>while running configure, to aid debugging if configure makes a mistake.</p> <p>It was created by pytho...
0
2016-06-23T07:51:08Z
37,988,821
<hr> <blockquote> <p>C compiler cannot create executables</p> </blockquote> <p>That's about the missing files for gcc. Which you will get with # <code>yum install gcc-c++</code></p> <p>I.e. The install of gcc-c++ will also install this : { libc-devel, glibc-headers, kernel-headers } ... to /usr/include/, /usr/lib6...
0
2016-06-23T10:19:20Z
[ "python", "linux", "centos" ]
<img> tags not working properly in HTML email
37,985,529
<p>I have been working in Python to send an HTML email newsletter. The Python part seems to be working properly, and I think the issue is with the email reading the HTML. Here is the HTML of the template I am using:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Title&lt;/title&gt; &lt...
1
2016-06-23T08:00:43Z
38,005,625
<p>Figured out the issue: Apparently new lines in HTML are significant for emails. The unformatted code with no new lines works fine in browsers, but sometimes breaks images in email for whatever reason. Adding in the new lines fixed the issue.</p>
0
2016-06-24T04:30:11Z
[ "python", "html", "email", "tags" ]
How can I set override default kwargs in a parent class?
37,985,585
<p>Let's say I have the following parent and child classes:</p> <pre><code>class A(object): def __init__(self, *args, **kwargs): self.a = kwargs.get('a', 'default_A') self.b = kwargs.get('b', 'default_B') class B(A): a = "override_A" def __init__(self, *args, **kwargs): super(B, ...
-2
2016-06-23T08:04:02Z
37,985,755
<p>You're mixing class and instance variables. <code>B.a</code> is a class variable, which is shadowed by the instance variable set in <code>A.__init__()</code>.</p> <p>You could for example use <a href="https://docs.python.org/3/library/stdtypes.html#dict.setdefault" rel="nofollow"><code>dict.setdefault()</code></a>:...
4
2016-06-23T08:12:05Z
[ "python" ]
how to debug or run pytest scripts using eclipse?
37,985,589
<p>i have installed the <a href="http://pytest.org/latest/getting-started.html" rel="nofollow">pytest framework</a>.</p> <p>i am able to run the testcases using the following command. </p> <pre><code> py.test -q test_class.py </code></pre> <p>How to run the same test using eclipse?</p>
0
2016-06-23T08:04:11Z
37,985,689
<p>From eclipse Window->Preferences -->PyUnit --> Change the Test runner to "Py.test runner".</p> <p>Right Click over the file. Run As --> Python Unit-Test</p> <p>Or press Ctrl+F9:- </p> <p>It will prompt you to select the test</p>
2
2016-06-23T08:09:09Z
[ "python", "eclipse", "py.test" ]
Why my code does'nt execute on ipython notebook?
37,985,707
<p>I am totally new to jupyter notebook and I was trying to run a simple code and its not working.<a href="http://i.stack.imgur.com/iHMMC.gif" rel="nofollow"><img src="http://i.stack.imgur.com/iHMMC.gif" alt="enter image description here"></a></p> <p>I typed print (1) and hit ctrl + enter, and then that asterisk mark ...
0
2016-06-23T08:09:57Z
37,988,867
<p>yes, as Teemo pointed out all I had to do was use this,</p> <p>C:\Python27\Scripts>jupyter notebook --port=8889</p> <p>instead of,</p> <p>C:\Python27\Scripts>jupyter notebook. </p> <p>port 8889 , worked like a charm :)</p>
0
2016-06-23T10:21:12Z
[ "python", "command-line", "ipython", "ipython-notebook", "jupyter-notebook" ]
Multi-variable linear regression with scipy linregress
37,985,759
<p>I'm trying to train a very simple linear regression model. </p> <p>My code is:</p> <pre><code>from scipy import stats xs = [[ 0, 1, 153] [ 1, 2, 0] [ 2, 3, 125] [ 3, 1, 93] [ 2, 24, 5851] [ 3, 1, 524] [ 4, 1, 0] [ 2, 3, 0] [ 2, 1, 0] [ 5, ...
2
2016-06-23T08:12:15Z
37,986,018
<p>You're looking for multi variable regression. AFAIK <code>stats.linregress</code> does not have that functionality. </p> <p>You might want to try <a href="http://scikit-learn.org/stable/modules/linear_model.html#ordinary-least-squares" rel="nofollow"><code>sklearn.linear_model.LinearRegression</code></a>. Check <a ...
3
2016-06-23T08:24:38Z
[ "python", "scipy", "linear-regression" ]
Pandas Hdf Get table info
37,985,786
<p>Is there any way to get the info of a HDF table using the pandas HDF store?</p> <p>For example in SQL there is:</p> <pre><code>SELECT COUNT(*) </code></pre> <p>I would like to read basic table sizes without having to load the tables itself.</p>
1
2016-06-23T08:13:36Z
37,986,144
<p>try this:</p> <pre><code>In [4]: %paste store_path = r'c:/temp/.data/test.h5' store_key = 'test' df.to_hdf(store_path, key=store_key, mode='w', format='t', complib='zlib', complevel=4) ## -- End pasted text -- In [5]: store = pd.HDFStore(store_path) </code></pre> <p>available methods</p> <pre><code>In [6]: sto...
1
2016-06-23T08:29:53Z
[ "python", "pandas", "hdfstore" ]
If len Statement
37,985,883
<p>I type in seven digits to be able to work out a gtin-8 product code. But if I type in more than seven digits, the if len statement is meant to recognise that I have typed in more than seven digits, but it doesn't. I tried putting this into an variable but that did not work either... Any help would be appreciated!!! ...
-1
2016-06-23T08:17:54Z
37,985,987
<p>Your gtin_join is tuple, and if you want list you should use square braces. You can test type of variables with this example:</p> <pre><code>gtin1 = int(input("Enter your first digit... ")) gtin2 = int(input("Enter your second digit... ")) gtin3 = int(input("Enter your third digit... ")) gtin4 = int(input("Enter yo...
-1
2016-06-23T08:22:58Z
[ "python", "if-statement", "variable-length-array" ]
If len Statement
37,985,883
<p>I type in seven digits to be able to work out a gtin-8 product code. But if I type in more than seven digits, the if len statement is meant to recognise that I have typed in more than seven digits, but it doesn't. I tried putting this into an variable but that did not work either... Any help would be appreciated!!! ...
-1
2016-06-23T08:17:54Z
37,986,004
<p>What you probably want to do is something like that (notice that I'm using a list here):</p> <pre><code>ls = [] while len(ls) &lt; 7: try: #always check the input num = int(input("Enter your {0} digit:".format(len(ls)+1) )) ls.append(num) except: print("Input couldn't be converted!"...
1
2016-06-23T08:23:59Z
[ "python", "if-statement", "variable-length-array" ]
If len Statement
37,985,883
<p>I type in seven digits to be able to work out a gtin-8 product code. But if I type in more than seven digits, the if len statement is meant to recognise that I have typed in more than seven digits, but it doesn't. I tried putting this into an variable but that did not work either... Any help would be appreciated!!! ...
-1
2016-06-23T08:17:54Z
37,986,025
<p>I would do the following:</p> <pre><code>gtin_list = [] while len(gtin_list) != 7: gtin = input("Please enter all 7 digits separated by commas...") gtin_list = [int(x) for x in gtin.split(",")] </code></pre>
-1
2016-06-23T08:24:46Z
[ "python", "if-statement", "variable-length-array" ]
How to specify TimeZone in date formatting to get local time
37,985,892
<p>I'm trying to compare two date values:</p> <p>1) <code>Jun 23, 2016 10:36:31 EET</code></p> <p>2) <code>Thu, 23 Jun 2016 07:36:31 GMT</code></p> <p>To do this I need to convert second date to same date format as first one, so I use following code:</p> <pre><code>import datetime date = datetime.datetime.strptime(...
1
2016-06-23T08:18:21Z
37,987,150
<p>AFAIK AM isn't a timezone. Did you try to get <code>datetime.astimezone(tz)</code>to work? <a href="https://docs.python.org/2/library/datetime.html" rel="nofollow">https://docs.python.org/2/library/datetime.html</a></p>
0
2016-06-23T09:10:58Z
[ "python", "python-2.7", "date", "python-3.x", "datetime" ]
How to specify TimeZone in date formatting to get local time
37,985,892
<p>I'm trying to compare two date values:</p> <p>1) <code>Jun 23, 2016 10:36:31 EET</code></p> <p>2) <code>Thu, 23 Jun 2016 07:36:31 GMT</code></p> <p>To do this I need to convert second date to same date format as first one, so I use following code:</p> <pre><code>import datetime date = datetime.datetime.strptime(...
1
2016-06-23T08:18:21Z
37,987,158
<p>If you want to compare date-time values, it is much better to convert them both to <code>datetime</code> objects, e.g. call <code>datetime.strptime</code> on both of the input strings, each with the appropriate format string, and then compare the resulting <code>datetime</code> objects.</p>
0
2016-06-23T09:11:26Z
[ "python", "python-2.7", "date", "python-3.x", "datetime" ]
How to specify TimeZone in date formatting to get local time
37,985,892
<p>I'm trying to compare two date values:</p> <p>1) <code>Jun 23, 2016 10:36:31 EET</code></p> <p>2) <code>Thu, 23 Jun 2016 07:36:31 GMT</code></p> <p>To do this I need to convert second date to same date format as first one, so I use following code:</p> <pre><code>import datetime date = datetime.datetime.strptime(...
1
2016-06-23T08:18:21Z
38,002,782
<p>Here is the basic approach using the <code>pytz</code> module:</p> <pre><code>import datetime import pytz fmt = "%a, %d %b %Y %H:%M:%S %Z" date = datetime.datetime.strptime("Thu, 23 Jun 2016 07:36:31 GMT", fmt) gmt_date = pytz.timezone('GMT').localize(date) print("Time in GMT:", gmt_date.strftime(fmt), sep='\n')...
1
2016-06-23T22:15:59Z
[ "python", "python-2.7", "date", "python-3.x", "datetime" ]
how to pull Zendesk tickets data using python?
37,985,895
<p>I want to export all Zendesk Tickets data using Python. The data should be in csv format, and should include all fields related to tickets.</p> <p>Is there any way we can do that?</p>
0
2016-06-23T08:18:30Z
38,492,654
<p>I wrote a Python library for the Zendesk API and it has a bulk export feature for tickets and other objects - <a href="http://docs.facetoe.com.au/zenpy.html#incremental-exports" rel="nofollow">http://docs.facetoe.com.au/zenpy.html#incremental-exports</a>. Once you have the tickets writing the data to a CSV should be...
-1
2016-07-20T23:54:14Z
[ "python", "zendesk", "zendesk-api" ]
select number from list of string
37,985,950
<p>I want to convert list of strings to list of numbers but there is no luck </p> <p>my string is like </p> <pre><code>x=[u'9-9', u'-5-5',u'-45-45',u'99-99'] </code></pre> <p>i want to convert it to :</p> <pre><code>x=[9,-5,-45,99] </code></pre> <p>i tried to loop in the list and replace '-' using <code>string.rep...
2
2016-06-23T08:21:23Z
37,986,019
<p><code>str.replace</code> is not in-place. It returns a new string with the replaced characters. Therefore:</p> <pre><code>for i in x: string.replace(str(i),"-",' ') </code></pre> <p>Doesn't affect the strings in <code>x</code> whatsoever. </p> <p>You should also call <code>replace</code> directly on the strin...
2
2016-06-23T08:24:38Z
[ "python", "string", "list", "python-2.7", "replace" ]
select number from list of string
37,985,950
<p>I want to convert list of strings to list of numbers but there is no luck </p> <p>my string is like </p> <pre><code>x=[u'9-9', u'-5-5',u'-45-45',u'99-99'] </code></pre> <p>i want to convert it to :</p> <pre><code>x=[9,-5,-45,99] </code></pre> <p>i tried to loop in the list and replace '-' using <code>string.rep...
2
2016-06-23T08:21:23Z
37,986,217
<p>As pointed out strings in python are immutable. Operations on them return new strings instead of changing the original. Your output requirement is also a list of integers, so you have to parse the strings:</p> <pre><code>In [1]: x=[u'9-9', u'-5-5',u'-45-45',u'99-99'] In [2]: [int(i.rsplit('-', 1)[0]) for i in x] O...
4
2016-06-23T08:33:21Z
[ "python", "string", "list", "python-2.7", "replace" ]
select number from list of string
37,985,950
<p>I want to convert list of strings to list of numbers but there is no luck </p> <p>my string is like </p> <pre><code>x=[u'9-9', u'-5-5',u'-45-45',u'99-99'] </code></pre> <p>i want to convert it to :</p> <pre><code>x=[9,-5,-45,99] </code></pre> <p>i tried to loop in the list and replace '-' using <code>string.rep...
2
2016-06-23T08:21:23Z
37,986,401
<p>id like to use e regular expressions. just take a look <a href="https://docs.python.org/3/library/re.html#module-contents" rel="nofollow">here</a> and use <a href="https://regex101.com/#" rel="nofollow">this</a> for composing a regexp</p> <pre><code>import re x=[u'9-9', u'-5-5',u'-45-45',u'99-99'] rexp = '(.*)-\d+...
2
2016-06-23T08:41:15Z
[ "python", "string", "list", "python-2.7", "replace" ]
select number from list of string
37,985,950
<p>I want to convert list of strings to list of numbers but there is no luck </p> <p>my string is like </p> <pre><code>x=[u'9-9', u'-5-5',u'-45-45',u'99-99'] </code></pre> <p>i want to convert it to :</p> <pre><code>x=[9,-5,-45,99] </code></pre> <p>i tried to loop in the list and replace '-' using <code>string.rep...
2
2016-06-23T08:21:23Z
37,986,519
<p>Use a regular expression:</p> <pre><code>import re x = [u'9-9', u'-5-5',u'-45-45',u'99-99'] regex = "([-]?\d*)-.*" x = [int(re.search(regex, m).group(1)) for m in x] print(x) # [9, -5, -45, 99] </code></pre>
3
2016-06-23T08:46:45Z
[ "python", "string", "list", "python-2.7", "replace" ]
select number from list of string
37,985,950
<p>I want to convert list of strings to list of numbers but there is no luck </p> <p>my string is like </p> <pre><code>x=[u'9-9', u'-5-5',u'-45-45',u'99-99'] </code></pre> <p>i want to convert it to :</p> <pre><code>x=[9,-5,-45,99] </code></pre> <p>i tried to loop in the list and replace '-' using <code>string.rep...
2
2016-06-23T08:21:23Z
37,987,281
<pre><code>import re [int(re.sub(r"(-\d+$)", r"", i)) for i in x] #[9, -5, -45, 99] </code></pre>
2
2016-06-23T09:17:30Z
[ "python", "string", "list", "python-2.7", "replace" ]
Why might I be getting a 500 Error when using Python Requests, but not using cURL
37,985,982
<p>I am trying to work on a basic implementation of the Synchroteam API using python's requests. I was able to establish a connection using cURL as a proof of concept and get all the data I wanted, but using requests I am able to get into the site with my credentials, but all I get is:</p> <pre><code>500 text/html; ch...
0
2016-06-23T08:22:44Z
38,053,506
<p>This is the Python code I generate using Postman. I'm sure it will help you! </p> <pre><code>import requests url = "https://apis.synchroteam.com/Api/v1/User/list" payload = "{\n \"status\":\"1\"\n}" headers = { 'content-type': "application/json", 'accept': "application/json", 'authorization': "Basic ZGVtbzoxM...
-1
2016-06-27T12:03:50Z
[ "php", "python", "curl", "python-requests" ]
Fitting bimodal gaussian distribution with some parameters fixed
37,986,080
<p><strong>Problem:</strong> I want to fit empirical data to a bimodal normal distribution from which I know from the physical context the distance of the peaks (fixed) and also that both peaks must have the same standard deviation.</p> <p>I was trying to create an own distribution with <a href="http://docs.scipy.org/...
2
2016-06-23T08:26:57Z
37,992,867
<p>I was able to get your distribution to fit the data after making a couple tweaks:</p> <ul> <li>Using <code>w</code> as you did, you have an implied constraint that 0 &lt;= <code>w</code> &lt;= 1. The solver used by the <code>fit()</code> method isn't aware of this constraint, so <code>w</code> could end up with un...
2
2016-06-23T13:19:31Z
[ "python", "scipy", "statistics", "distribution" ]
What does the $\ symbol mean in Python code?
37,986,084
<p>I find below code from a book to show how to use matplotlib in Python. The code runs normally. But I don't understand what does the symbol $ or $\ mean here?</p> <pre><code># -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 1000) y = np.sin(x) + 1 z = np.cos(x**2) + 1...
0
2016-06-23T08:27:13Z
37,986,159
<p>It represents a Latex-like syntax.</p> <p>Example: <code>$X_y$</code> &lt;-- Latex for X with "y" as it's subscript.</p> <p>It looks like this, when rendered:</p> <p><a href="http://i.stack.imgur.com/etwHq.png" rel="nofollow"><img src="http://i.stack.imgur.com/etwHq.png" alt="enter image description here"></a></...
0
2016-06-23T08:30:28Z
[ "python", "matplotlib", "latex" ]
What does the $\ symbol mean in Python code?
37,986,084
<p>I find below code from a book to show how to use matplotlib in Python. The code runs normally. But I don't understand what does the symbol $ or $\ mean here?</p> <pre><code># -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 1000) y = np.sin(x) + 1 z = np.cos(x**2) + 1...
0
2016-06-23T08:27:13Z
37,986,222
<p>It doesn't mean anything in Python. <code>$</code> marks the beginning and end of maths in a LaTeX string. </p> <p><code>$\sin x+1$</code> means <img src="https://latex.codecogs.com/gif.download?%24%5Csin%20x+1%24" alt=""> </p> <p>Similarly, <code>$\cos x^2+1$</code> will be <img src="https://latex.codecogs.com/...
1
2016-06-23T08:33:37Z
[ "python", "matplotlib", "latex" ]
What does the $\ symbol mean in Python code?
37,986,084
<p>I find below code from a book to show how to use matplotlib in Python. The code runs normally. But I don't understand what does the symbol $ or $\ mean here?</p> <pre><code># -*- coding: utf-8 -*- import numpy as np import matplotlib.pyplot as plt x = np.linspace(0, 10, 1000) y = np.sin(x) + 1 z = np.cos(x**2) + 1...
0
2016-06-23T08:27:13Z
37,986,430
<p>Actually your question title is misleading. </p> <p><code>$...$</code> It is latex syntax for mathematical environment (as already mentioned above). </p> <p>The backslash has nothing to do with the dollar sign, it is a LaTeX command, for example here for drawing <code>sin</code></p> <pre><code>$\sin x+1$ </code><...
0
2016-06-23T08:42:30Z
[ "python", "matplotlib", "latex" ]
Print ERROR and hidden name
37,986,096
<p>I have .txt file have lines like</p> <pre><code>.txt A B C </code></pre> <p>I use the following code to create some new csv file.</p> <pre><code>with open(name, "rb") as f: name = f.readlines() for i in files: open(path+'%s.csv' %i, "w") </code></pre> <p>However, when I use code</p> <pre><code>t...
2
2016-06-23T08:27:59Z
37,986,132
<p>Readlines return each line with the trailing newline character(s) intact. Add a call to <a href="https://docs.python.org/2/library/string.html#string.strip" rel="nofollow"><code>strip()</code></a>:</p> <pre><code>open(path+'%s.csv' % i.strip(), "w") </code></pre>
1
2016-06-23T08:29:21Z
[ "python" ]
PyOpenCL - Different results on Intel and NVidia
37,986,138
<p>I'm trying to run a simulation that is based on gaussian pulses propagation. I'm cross developing between my windows desktop with an i5 4590 &amp; GTX 970 (latest drivers) and my early 2015 macbook air.</p> <p>When running my main code i couldn't get any decent results on my desktop (the calculations diverged) but ...
0
2016-06-23T08:29:39Z
37,987,920
<p><em>EDIT: oh, just read @talonmies comment, it is same solution as this.</em></p> <p>This code is not safe in OpenCL, it has datarace problem:</p> <pre><code>A[gid_x] = A[gid_x] + EPS*complex_mul((A[gid_x+1] + A[gid_x-1]), complex_unit); </code></pre> <p>Every work item <code>x</code> uses <code>x+1</code> and <c...
3
2016-06-23T09:42:58Z
[ "python", "numpy", "opencl", "nvidia", "pyopencl" ]
comparing two text files and extracting text in python
37,986,225
<p>I have two text files, one of them contains list of ids with numbers, and the other one contains list of ids with text. I want to compare two files, and for the lines having the same id print the text inside parentheses. This is what I have so file:</p> <pre><code>import fileinput import sys def clean(file1): ...
-1
2016-06-23T08:33:46Z
37,986,958
<p><code>file1</code> is an iterator that is exhausted after all the lines in the file have been read (which will happen during the first <code>for</code> loop). Therefore, the following loop</p> <pre><code>for line in file1: </code></pre> <p>will never run. But even if it did, the condition</p> <pre><code> if id...
0
2016-06-23T09:03:59Z
[ "python", "file" ]
comparing two text files and extracting text in python
37,986,225
<p>I have two text files, one of them contains list of ids with numbers, and the other one contains list of ids with text. I want to compare two files, and for the lines having the same id print the text inside parentheses. This is what I have so file:</p> <pre><code>import fileinput import sys def clean(file1): ...
-1
2016-06-23T08:33:46Z
37,987,247
<pre><code>def clean(file1): with open(sys.argv[1], "r") as file1: file1_lines = file1.readlines() id1 = [line.strip().split() for line in file1_lines] with open(sys.argv[2], "r") as file2: file2_lines = file2.readlines() id2 = [line.strip().split() for line in file2_lines] ...
1
2016-06-23T09:15:35Z
[ "python", "file" ]
comparing two text files and extracting text in python
37,986,225
<p>I have two text files, one of them contains list of ids with numbers, and the other one contains list of ids with text. I want to compare two files, and for the lines having the same id print the text inside parentheses. This is what I have so file:</p> <pre><code>import fileinput import sys def clean(file1): ...
-1
2016-06-23T08:33:46Z
37,988,108
<p>To compare the same lines(line no) in the two files:</p> <pre><code> file1 = open(sys.argv[1], "r") file2 = open(sys.argv[2], "r") for line1, line2 in file1,file2: if(line1.split()[-1] == line2.split()[0]): print line1 # use regex to extract the infromation needed file1.close() file2.close() </c...
0
2016-06-23T09:50:01Z
[ "python", "file" ]
AssetError Bound Method in unit test
37,986,329
<p>Currently, I am creating a test script. but I am getting this error:</p> <pre><code> &lt;bound method Score.percentage of &lt;Score: Score object&gt;&gt; != 100 </code></pre> <p>these are my codes:</p> <p>models.py</p> <pre><code>class Score(models.Model): id = models.UUIDField(primary_key=True, default=uu...
0
2016-06-23T08:38:06Z
37,986,404
<p>Percentage is a method so you need to call it</p> <pre><code>self.assertEqual(Score.percentage, 100) </code></pre> <p>should be </p> <pre><code>self.assertEqual(Score.percentage(), 100) </code></pre> <p>Note: it still won't work correctly though since you need to call the method on an <em>instance</em> of score,...
1
2016-06-23T08:41:28Z
[ "python", "django" ]
Parsing and printing JSON data using Python
37,986,406
<p>I'm new to JSON and I'm working on extracting values from JSON data using Python. I'm getting the JSON data using another shell script with cURL.</p> <p>Here is my JSON output from the shell script (Called test.sh):</p> <pre><code>{"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,...
0
2016-06-23T08:41:35Z
37,986,690
<p>I see several things either wrong or misinterpreted in the post:</p> <ol> <li><p>If you have a collection of JSON objects, you should make them an array of objects, or parse them one at a time as separate files or separate lines in one file (not recommended). The former would be easier and more reliable:</p> <pre>...
1
2016-06-23T08:53:15Z
[ "python", "json", "curl" ]
Parsing and printing JSON data using Python
37,986,406
<p>I'm new to JSON and I'm working on extracting values from JSON data using Python. I'm getting the JSON data using another shell script with cURL.</p> <p>Here is my JSON output from the shell script (Called test.sh):</p> <pre><code>{"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,...
0
2016-06-23T08:41:35Z
37,986,707
<p>Your data is multiple json objects.</p> <p>You may want to wrap it in curly brackets (<code>{</code> and <code>}</code>) and treat it as one unique set of all your objects.</p> <pre><code>{ {"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,"offset":1,"result":{"Country":"BG","coun...
-1
2016-06-23T08:53:52Z
[ "python", "json", "curl" ]
Parsing and printing JSON data using Python
37,986,406
<p>I'm new to JSON and I'm working on extracting values from JSON data using Python. I'm getting the JSON data using another shell script with cURL.</p> <p>Here is my JSON output from the shell script (Called test.sh):</p> <pre><code>{"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,...
0
2016-06-23T08:41:35Z
37,986,757
<p>For the result output</p> <pre><code>{"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,"offset":1,"result":{"Country":"BG","count":"7"}} {"preview":true,"offset":2,"result":{"Country":"CA","count":"198"}} {"preview":true,"offset":3,"result":{"Country":"CH","count":"1"}} {"preview":...
0
2016-06-23T08:55:52Z
[ "python", "json", "curl" ]
Parsing and printing JSON data using Python
37,986,406
<p>I'm new to JSON and I'm working on extracting values from JSON data using Python. I'm getting the JSON data using another shell script with cURL.</p> <p>Here is my JSON output from the shell script (Called test.sh):</p> <pre><code>{"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,...
0
2016-06-23T08:41:35Z
37,986,881
<p>Simple solution would be, Let's start with your answer:</p> <pre><code>answer = '''{"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,"offset":1,"result":{"Country":"BG","count":"7"}} {"preview":true,"offset":2,"result":{"Country":"CA","count":"198"}} {"preview":true,"offset":3,"res...
0
2016-06-23T09:00:40Z
[ "python", "json", "curl" ]
Parsing and printing JSON data using Python
37,986,406
<p>I'm new to JSON and I'm working on extracting values from JSON data using Python. I'm getting the JSON data using another shell script with cURL.</p> <p>Here is my JSON output from the shell script (Called test.sh):</p> <pre><code>{"preview":true,"offset":0,"result":{"Country":"AU","count":"417"}} {"preview":true,...
0
2016-06-23T08:41:35Z
37,986,983
<p>Please save the code into <code>test.py</code> and data into <code>test.json</code>.</p> <p><strong>test.py</strong></p> <pre><code>import json with open('/tmp/test.json') as f: for i in f: data = json.loads(i) print("{Country} {count}".format(**data["result"])) </code></pre> <p><strong>test...
0
2016-06-23T09:04:35Z
[ "python", "json", "curl" ]
Chrome silently embedded in desktop application, and that can save files locally via Javascript
37,986,553
<p>Is it possible to have a Python application with a GUI (such as TkInter or WxPython) with :</p> <ul> <li><p>a Chrome browser as a widget using the main part of the GUI, displaying a certain .html page</p></li> <li><p><strong>be able to save files locally thanks to Javascript that is run in the embedded Chrome</stro...
1
2016-06-23T08:48:06Z
38,002,068
<p>Yes, it should be doable. In current versions of wxPython there is the <code>wx.html2</code> module, which provides classes for embedding a fully featured browser in a wx window. It's not Chrome itself, but probably close enough. See <a href="https://wxpython.org/Phoenix/docs/html/wx.html2.WebView.html" rel="nofol...
0
2016-06-23T21:21:37Z
[ "javascript", "python", "google-chrome", "wxpython" ]
Chrome silently embedded in desktop application, and that can save files locally via Javascript
37,986,553
<p>Is it possible to have a Python application with a GUI (such as TkInter or WxPython) with :</p> <ul> <li><p>a Chrome browser as a widget using the main part of the GUI, displaying a certain .html page</p></li> <li><p><strong>be able to save files locally thanks to Javascript that is run in the embedded Chrome</stro...
1
2016-06-23T08:48:06Z
38,030,245
<p>You mention that you're open to trying platforms other than Python. Have you seen Electron? It's a framework and runtime for building desktop applications in JavaScript with full access to the file system made by GitHub. It's based on Chromium, the same open source project that Chrome is based on.</p> <ul> <li><a h...
3
2016-06-25T15:55:01Z
[ "javascript", "python", "google-chrome", "wxpython" ]
terminal runs python 2.7 when I have python 3.5 installed on mac.
37,986,572
<p>I was installing, uninstalling and reinstalling pythons on my mac, and I think things are screwed up a little.</p> <p>At first by default, terminal ran Python 3.5 when I typed</p> <pre><code>$python </code></pre> <p>, but after doing some things, it installed 2.7 and now the terminal runs python 2.7 instead of 3....
0
2016-06-23T08:48:45Z
38,944,646
<p>This worked for me:</p> <p><strong>Python 3.x</strong></p> <pre><code>python3 </code></pre> <p><strong>Python 2.x</strong></p> <pre><code>python </code></pre> <blockquote> <p>in terminal</p> </blockquote>
1
2016-08-14T17:18:04Z
[ "python", "osx", "python-2.7", "python-3.5" ]
terminal runs python 2.7 when I have python 3.5 installed on mac.
37,986,572
<p>I was installing, uninstalling and reinstalling pythons on my mac, and I think things are screwed up a little.</p> <p>At first by default, terminal ran Python 3.5 when I typed</p> <pre><code>$python </code></pre> <p>, but after doing some things, it installed 2.7 and now the terminal runs python 2.7 instead of 3....
0
2016-06-23T08:48:45Z
38,944,750
<p>To see what command is actually going to run when you type <code>python</code> at the prompt, check the top result of:</p> <pre><code>type -a python </code></pre> <p>This will list any aliases as well as taking into account the full <code>PATH</code> definition. To figure out why python 2 is getting precedence ov...
0
2016-08-14T17:28:36Z
[ "python", "osx", "python-2.7", "python-3.5" ]
Does `psycopg2` in Python 2.x block the GIL
37,986,676
<p>I'm trying to settle an argument with a coworker. Say that I have a Python 2.6 app that uses <code>psycopg2</code> to communicate with a Postgres database. The app is multithreaded. When a thread makes a database call using <code>psycopg2</code>, does it release the GIL so other threads could also make a database ca...
5
2016-06-23T08:52:39Z
37,987,064
<p>From a quick glance at <a href="http://initd.org/psycopg/docs/news.html" rel="nofollow">the Psycopg release notes</a>, there are many references to releasing the GIL. So apparently it tries to release the GIL when appropriate. You didn't ask about a specific scenario, so I don't think a more specific answer is possi...
2
2016-06-23T09:07:57Z
[ "python", "postgresql", "gil" ]
Does `psycopg2` in Python 2.x block the GIL
37,986,676
<p>I'm trying to settle an argument with a coworker. Say that I have a Python 2.6 app that uses <code>psycopg2</code> to communicate with a Postgres database. The app is multithreaded. When a thread makes a database call using <code>psycopg2</code>, does it release the GIL so other threads could also make a database ca...
5
2016-06-23T08:52:39Z
37,987,170
<p>As you said, a rule exists that only the thread that has acquired the GIL may operate on Python objects or call Python/C API functions. In order to emulate concurrency of execution, the Python interpreter regularly tries to switch threads. The lock is also released around potentially blocking I/O operations like rea...
0
2016-06-23T09:11:53Z
[ "python", "postgresql", "gil" ]
MS Face API oxford Identity/Grouping by Python
37,986,749
<p>I am trying to create image classifier based on MS API by using python.</p> <p>At first, I would like follow a instruction via MSDN "How to identify Face" This instruction is based on C#, but I would like to refer and convert into python</p> <p><a href="https://msdn.microsoft.com/en-us/library/mt605327.aspx" rel="...
0
2016-06-23T08:55:40Z
38,018,779
<p>Q1: Once you successfully create a PersonGroup you then create Person objects as part of that group using the Create Person POST call <a href="https://dev.projectoxford.ai/docs/services/563879b61984550e40cbbe8d/operations/563879b61984550f3039523c" rel="nofollow">API Reference</a> | <a href="https://www.microsoft.com...
0
2016-06-24T17:10:28Z
[ "python", "image-recognition", "microsoft-cognitive", "face" ]
Error with import pandas
37,986,834
<p>I'm using Python, and just start importing pandas, then the terminal reports failure like this:</p> <pre><code>Traceback (most recent call last): File "C:/Users/L30607/PycharmProjects/untitled1/pandas.py", line 1, in &lt;module&gt; import pandas as pd </code></pre> <p>Any idea whats wrong?</p>
0
2016-06-23T08:59:06Z
37,986,883
<p>If you have installed <code>pandas</code>, then your local <code>pandas.py</code> is shadowing the <code>pandas</code> library. To get the original pandas, do:</p> <pre><code>from __future__ import absolute_import import pandas as pd </code></pre> <p>Or save the trouble and just rename your own script to somethin...
2
2016-06-23T09:00:41Z
[ "python" ]
How to search for multiple data from multiple lines and store them in dictionary?
37,986,864
<p>Say I have a file with the following:</p> <pre><code>/* Full name: abc */ ..... .....(.....) .....(".....) ; /* ..... /* ..... ..... : "....." } "....., ..... Car : true ; House : true ; .... .... Age : 33 .... /* Full name: xyz */ .... .... Car : true ; .... .... Age : 56 .... </code></pre> <p>I am only intereste...
0
2016-06-23T09:00:11Z
37,987,293
<p>Well, you just have to keep track of the current record:</p> <pre><code>def parse_name(line): # first remove the initial '/* ' and final ' */' stripped_line = line.strip('/* ') return stripped_line.split(':')[-1] WANTED_KEYS = ('Car', 'Age', 'House') # default values for when the lines are not presen...
1
2016-06-23T09:18:02Z
[ "python", "regex", "python-2.7", "dictionary" ]
Unable to deploy django app locally
37,986,945
<p><strong>Update:</strong> I seem to have some progress, although haven't yet solved the main problem. Currently, I can access tasks as described <a href="https://devcenter.heroku.com/articles/celery-heroku#running-locally" rel="nofollow">here</a> and this will then produce some output in my local server (specifically...
0
2016-06-23T09:03:24Z
37,988,935
<p><a href="https://en.wikipedia.org/wiki/0.0.0.0" rel="nofollow">0.0.0.0</a> is a special address. In this context, it means <em>"all IPv4 addresses on the local machine"</em>, i.e.: the server will accept connections to port <code>5000</code> on any IP address your machine has. </p> <p>Thus you can connect to it usi...
0
2016-06-23T10:24:27Z
[ "python", "django", "heroku" ]
Dismiss rows from DataFrame by condition in different one
37,986,947
<p>I have two sets of csv, both with different time frequencies throughout- i.e Measurment every 5 minutes, then every hour etc.</p> <p>What I want to do is for the second csv (<code>column 2</code>) if there is a value greater than <code>190</code> anywhere in that <code>hour</code>, then get rid of CSV one's respect...
1
2016-06-23T09:03:25Z
37,987,578
<p>Setup double <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.read_csv.html" rel="nofollow"><code>read_csv</code></a>:</p> <pre><code>import pandas as pd import io temp=u"""24-jan-08 23:50,-8.6,7.7,0.0213,.9820,0.0213,1.6316,1.00,46.810 24-jan-08 23:55,-6.7,7.7,0.0213,.9824,0.0213,1.6321,1.00,...
1
2016-06-23T09:29:33Z
[ "python", "csv", "pandas", "dataframe", "timestamp" ]
how to do such calculation task in pandas?
37,986,948
<p>I have a dataframe like this</p> <pre><code> disc val a -1.140502 1 b -0.916104 2 c -0.828460 3 d -2.828460 4 e -2.238450 5 </code></pre> <p>I would like to get the a result dataframe like</p> <pre><code> ...
-5
2016-06-23T09:03:26Z
37,987,025
<p>try this:</p> <pre><code>In [17]: df.val.cumprod() Out[17]: a 1 b 2 c 6 d 24 e 120 Name: val, dtype: int64 </code></pre>
1
2016-06-23T09:06:20Z
[ "python", "pandas" ]
Set driver's memory size programmatically in PySpark
37,986,963
<p>In order to write a standalone script, I would like to start and configure a Spark context directly from Python. Using PySpark's script I can set the driver's memory size with:</p> <pre><code>$ /opt/spark-1.6.1/bin/pyspark ... INFO MemoryStore: MemoryStore started with capacity 511.5 MB ... $ /opt/spark-1.6.1/bin/p...
2
2016-06-23T09:04:05Z
39,644,647
<p>There is no point in using the conf as you are doing. Try to add this preamble to your code:</p> <pre><code>memory = '10g' pyspark_submit_args = ' --driver-memory ' + memory + ' pyspark-shell' os.environ["PYSPARK_SUBMIT_ARGS"] = pyspark_submit_args </code></pre>
2
2016-09-22T16:46:58Z
[ "python", "apache-spark", "pyspark" ]
Set driver's memory size programmatically in PySpark
37,986,963
<p>In order to write a standalone script, I would like to start and configure a Spark context directly from Python. Using PySpark's script I can set the driver's memory size with:</p> <pre><code>$ /opt/spark-1.6.1/bin/pyspark ... INFO MemoryStore: MemoryStore started with capacity 511.5 MB ... $ /opt/spark-1.6.1/bin/p...
2
2016-06-23T09:04:05Z
39,646,083
<p>you can pass it through the spark-submit command using <B>--driver-memory</B> flag.</p> <pre><code>spark-submit \ --master yarn \ --deploy-mode cluster \ --driver-cores 12 --driver-memory 20g \ --num-executors 52 --executor-cores 6 --executor-memory 30g MySparkApp.py </code></pre> <p>Have this...
0
2016-09-22T18:12:13Z
[ "python", "apache-spark", "pyspark" ]
Set driver's memory size programmatically in PySpark
37,986,963
<p>In order to write a standalone script, I would like to start and configure a Spark context directly from Python. Using PySpark's script I can set the driver's memory size with:</p> <pre><code>$ /opt/spark-1.6.1/bin/pyspark ... INFO MemoryStore: MemoryStore started with capacity 511.5 MB ... $ /opt/spark-1.6.1/bin/p...
2
2016-06-23T09:04:05Z
39,649,113
<p>I had this exact same problem and just figured out a hacky way to do it. And it turns out <a href="http://stackoverflow.com/a/39644647/953327">there is an existing answer</a> which takes the same approach. But I'm going to explain why it works.</p> <p>As you know, the driver-memory cannot be set <a href="http://spa...
1
2016-09-22T21:24:30Z
[ "python", "apache-spark", "pyspark" ]
How to get a Django application view on 127.0.0.1:8000?
37,986,979
<p>I am new to Django and was learning about views and urls. This is from the official Django documentation.</p> <p>urls.py -></p> <pre><code>from django.conf.urls import url from . import views urlpatterns = [ # ex: /polls/ url(r'^$', views.index, name='index'), ] </code></pre> <p>views.py -></p> <pre><c...
0
2016-06-23T09:04:24Z
37,987,096
<p>you have to change it at the main <code>urls.py</code>. This file is maybe in the <code>mysite</code> folder. So change</p> <p><code>url(r'^polls', include('polls.urls')),</code> </p> <p>to</p> <p><code>url(r'^', include('polls.urls')),</code> </p>
2
2016-06-23T09:09:01Z
[ "python", "django" ]
How to get a Django application view on 127.0.0.1:8000?
37,986,979
<p>I am new to Django and was learning about views and urls. This is from the official Django documentation.</p> <p>urls.py -></p> <pre><code>from django.conf.urls import url from . import views urlpatterns = [ # ex: /polls/ url(r'^$', views.index, name='index'), ] </code></pre> <p>views.py -></p> <pre><c...
0
2016-06-23T09:04:24Z
37,987,144
<p>You need to add the <strong>url(r'^$', views.index, name='index'),</strong> to your project's <strong>urls.py</strong> not in app's urls.py.</p>
1
2016-06-23T09:10:38Z
[ "python", "django" ]
Multiple rows returned with unique key?
37,987,026
<p>Given those 3 simple SQLAlchemy models:</p> <pre><code>class Customer(ModelBase): __tablename__ = 'customers' id = sa.Column(sa.Integer, primary_key=True) uid = sa.Column(sa.Unicode, nullable=False, unique=True) class Handset(ModelBase): __tablename__ = 'handsets' id = sa.Column(sa.Integer, ...
1
2016-06-23T09:06:20Z
37,987,917
<p>The 1st query produces an implicit cross join between handsets, customers and channels (which is the source of multiple rows for one) + 2 left joins (from customers and handsets for eager load), which is probably not what you want:</p> <pre><code>In [7]: print(session.query(Channel).filter(Handset.imei == '1234', C...
4
2016-06-23T09:42:54Z
[ "python", "sqlalchemy" ]
pyspark - creating dataframes using sqlCtx.load() from CSV file
37,987,113
<p>I get an error while creating a dataframe in pyspark. Pls let me know how to fix it. I am learning pyspark commands through Coursera. </p> <p>Here are the commands that I used:</p> <p>PYSPARK_DRIVER_PYTHON=ipython pyspark -- packages com.databricks:spark-csv_2.10:1.4.0</p> <p>this seemed to work fine.</p> <p>Onc...
0
2016-06-23T09:09:35Z
37,988,761
<p>Load it as a text file, split according to your delimiter ',' then convert to dataframe. With sc being your spark context,</p> <pre><code>sc.textFile('file:///usr/lib/hue/apps/search/examples/collections/solr_configs_yelp_demo/index_data.csv').map(lambda row:row.split(',')).toDF </code></pre>
0
2016-06-23T10:16:50Z
[ "python", "csv", "pyspark" ]
Lxml error when parsing kml using pykml
37,987,165
<p>Im trying to parse a kml file containing multiple placemarks using pykml. I want to edit the HTML code inside the kml's description, mainly for visualization purposes of geographic data in Google Earth. Ive researched a lot of ways to do so:</p> <ul> <li><a href="http://stackoverflow.com/questions/13712132/extract-...
0
2016-06-23T09:11:43Z
37,989,416
<p>The xml has some issues, if you want to remove the error, add <code>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"</code> to the second line:</p> <pre><code>&lt;kml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.opengis.net/kml/2.2" xmlns:gx="http://www.google.com/kml/ext/2.2" xmlns...
0
2016-06-23T10:45:49Z
[ "python", "parsing", "lxml", "kml" ]
Selenium won't see elements unless I manually resize the window
37,987,260
<p>One of the desired elements is in the right corner of the page, and selenium will not see it unless I manually resize the window to make the element present. If I do so, everything works fine. Selenium will find the element, click on it, and do what I want it to do. Here is my code in python</p> <pre><code>wait.unt...
1
2016-06-23T09:16:24Z
37,987,377
<p>The error means that there is a different <code>element</code> covering the <code>element</code> you're trying to click. If Selenium tries to click on it the click will actually happen on the element that is covering it, thus it throws this error. You could use <code>javascript</code> to click on it, this way it doe...
3
2016-06-23T09:21:47Z
[ "python", "selenium", "selenium-chromedriver" ]
Pyqt5 designer and Python 3.5
37,987,290
<p>I'm new to coding. I'm really enjoying it and have worked my way through a number of tutorials for Python 3 and feel the basics are coming along. I've now started to think about gui creation. I first started with tkinter but quickly decided that pyqt5 was good for me. I've started a tutorial that I found from zetcod...
-2
2016-06-23T09:17:53Z
37,995,379
<p>If you used one of the Windows <a href="http://www.riverbankcomputing.com/software/pyqt/download5" rel="nofollow">binary packages</a>, it should create a PyQt submenu which has a menu item for Qt Designer (amongst other things). Alternatively, you can start it by entering <code>designer</code> in the Run dialog or a...
0
2016-06-23T15:04:06Z
[ "python", "windows", "python-3.x", "windows-10", "pyqt5" ]
Pyqt5 designer and Python 3.5
37,987,290
<p>I'm new to coding. I'm really enjoying it and have worked my way through a number of tutorials for Python 3 and feel the basics are coming along. I've now started to think about gui creation. I first started with tkinter but quickly decided that pyqt5 was good for me. I've started a tutorial that I found from zetcod...
-2
2016-06-23T09:17:53Z
39,795,019
<p>I had the same problem.</p> <p>I fix it be installing additional tools with</p> <blockquote> <p>pip install PyQt5-tools</p> </blockquote> <p>Then I located the "designer.exe" executable in <code>C:\Users\%USERNAME%\AppData\Local\Programs\Python\Python35-32\Lib\site-packages\pyqt5-tools\designer</code></p> <p><...
2
2016-09-30T15:27:17Z
[ "python", "windows", "python-3.x", "windows-10", "pyqt5" ]
django-pytest: AssertionError
37,987,368
<p>Im new to Django testing and Iam passing a context inside my views but my test case fails.when I query <code>Question.objects.all()</code> in django shell I get one value</p> <p>My views</p> <pre><code>def home(request): list = Question.objects.all() context = {'list': list} return render(request,'inde...
0
2016-06-23T09:21:16Z
37,988,830
<p>Make sure, that you have data in your test DB first. You can do it with debugger, just insert <a href="https://pytest.org/latest/usage.html#setting-a-breakpoint-aka-set-trace" rel="nofollow">pytest.set_trace()</a> in your code and then invoke your query <code>Question.objects.all()</code> by hand. Also, check <a hre...
1
2016-06-23T10:19:52Z
[ "python", "django", "pytest-django" ]
PyCharm code search woes
37,987,462
<p>Not sure if this is the right place to ask this question but I hope it is.</p> <p>I have been using PyCharm for Python development in the last month and a half and there's an issue that irks me a lot since I've moved from Visual Studio (I had to). I am trying to find stuff in the code and PyCharm for some reason ju...
0
2016-06-23T09:24:59Z
37,993,017
<p>I needed to use Ctrl Shift F instead of double Tab</p>
0
2016-06-23T13:26:24Z
[ "python", "pycharm" ]
Python specific parsing
37,987,465
<p>I'm having trouble parsing my string entirely. I have this string (response from my server):</p> <pre><code>vision = 'item1,item2,,,item5' </code></pre> <p>I'm trying to parse it with this line:</p> <pre><code>list_v = [x for x in vision.split(',') if x.strip()] </code></pre> <p>And I expected :</p> <pre><code>...
-4
2016-06-23T09:25:01Z
37,987,493
<p>You are explicitly filtering using <code>if x.strip()</code>. Remove that filter:</p> <pre><code>list_v = [x for x in vision.split(',')] </code></pre> <p>You may still want to strip whitespace from the resulting elements:</p> <pre><code>list_v = [x.strip() for x in vision.split(',')] </code></pre>
1
2016-06-23T09:26:12Z
[ "python", "python-3.x", "parsing" ]
Fast algorithm to find indices where multiple arrays have the same value
37,987,553
<p>I'm looking for ways to speed up (or replace) my algorithm for grouping data.</p> <p>I have a list of numpy arrays. I want to generate a new numpy array, such that each element of this array is the same for each index where the original arrays are the same as well. (And different where this is not the case.)</p> <...
7
2016-06-23T09:28:37Z
37,987,818
<p>If I understand correctly, you are trying to hash values according to columns. Its better to convert the columns into arbitrary values by themselves, and then find the hashes from them. </p> <p>So you actually want to hash on <code>list(np.array(values).T)</code>. </p> <p>This functionality is already built into P...
-1
2016-06-23T09:39:04Z
[ "python", "performance", "numpy" ]
Fast algorithm to find indices where multiple arrays have the same value
37,987,553
<p>I'm looking for ways to speed up (or replace) my algorithm for grouping data.</p> <p>I have a list of numpy arrays. I want to generate a new numpy array, such that each element of this array is the same for each index where the original arrays are the same as well. (And different where this is not the case.)</p> <...
7
2016-06-23T09:28:37Z
37,987,965
<p>This should work, and should be considerably faster, since we're using <a href="http://docs.scipy.org/doc/numpy/user/basics.broadcasting.html" rel="nofollow">broadcasting</a> and numpy's inherently fast boolean comparisons:</p> <pre><code>import numpy as np # Test values: values = [ np.array([10, 11, 10, 11, 1...
2
2016-06-23T09:44:24Z
[ "python", "performance", "numpy" ]
Fast algorithm to find indices where multiple arrays have the same value
37,987,553
<p>I'm looking for ways to speed up (or replace) my algorithm for grouping data.</p> <p>I have a list of numpy arrays. I want to generate a new numpy array, such that each element of this array is the same for each index where the original arrays are the same as well. (And different where this is not the case.)</p> <...
7
2016-06-23T09:28:37Z
37,989,912
<p>Cracked it finally for a vectorized solution! It was an interesting problem. The problem was we had to tag each pair of values taken from the corresponding array elements of the list. Then, we are supposed to tag each such pair based on their uniqueness among othet pairs. So, we can use <code>np.unique</code> abusin...
3
2016-06-23T11:09:36Z
[ "python", "performance", "numpy" ]
Fast algorithm to find indices where multiple arrays have the same value
37,987,553
<p>I'm looking for ways to speed up (or replace) my algorithm for grouping data.</p> <p>I have a list of numpy arrays. I want to generate a new numpy array, such that each element of this array is the same for each index where the original arrays are the same as well. (And different where this is not the case.)</p> <...
7
2016-06-23T09:28:37Z
37,990,750
<p>The <a href="https://github.com/EelcoHoogendoorn/Numpy_arraysetops_EP" rel="nofollow">numpy_indexed</a> package (disclaimer: I am its author) contains generalized variants of the numpy arrayset operations, which can be used to solve your problem in an elegant and efficient (vectorized) manner:</p> <pre><code>import...
1
2016-06-23T11:48:10Z
[ "python", "performance", "numpy" ]
Plotting proportional data python (stacked barplot)
37,987,596
<p>I have a data set where clients answer a question, and clients belong to a certain category. The category is ordinal. I want to visualize the change in percentages as a proportional stacked barplot. Here is some test data:</p> <pre><code>answer | categ 1 1 2 1 3 2 1 2 2 3 3 ...
0
2016-06-23T09:30:21Z
37,987,789
<p>You can make a barplot with the matplotlib library. Follow this tuto : <a href="http://matplotlib.org/examples/api/barchart_demo.html" rel="nofollow">http://matplotlib.org/examples/api/barchart_demo.html</a></p>
-1
2016-06-23T09:38:11Z
[ "python", "pandas", "matplotlib", "data-visualization" ]
Plotting proportional data python (stacked barplot)
37,987,596
<p>I have a data set where clients answer a question, and clients belong to a certain category. The category is ordinal. I want to visualize the change in percentages as a proportional stacked barplot. Here is some test data:</p> <pre><code>answer | categ 1 1 2 1 3 2 1 2 2 3 3 ...
0
2016-06-23T09:30:21Z
37,989,260
<p>This is by no means perfect but it's a start:</p> <pre><code>for i in set(df.categ): colors = ["r", "g", "b", "y", "o"] #etc.... if i == 1: x = np.zeros(len(set(df.answer))) else: x += df[df.categ == i - 1].perc.as_matrix() plt.bar(df[df.categ == i].answer, df[df.categ == i].perc, b...
0
2016-06-23T10:39:04Z
[ "python", "pandas", "matplotlib", "data-visualization" ]
Plotting proportional data python (stacked barplot)
37,987,596
<p>I have a data set where clients answer a question, and clients belong to a certain category. The category is ordinal. I want to visualize the change in percentages as a proportional stacked barplot. Here is some test data:</p> <pre><code>answer | categ 1 1 2 1 3 2 1 2 2 3 3 ...
0
2016-06-23T09:30:21Z
37,990,323
<p>Once I had the last dataframe, I could get it fairly easily. By doing this:</p> <pre><code>rel_data = rel_data.groupby(['answer','categ']).\ perc.sum().unstack().plot(kind='bar', stacked=True, ylim=(0,1)) </code></pre> <p>It's again dirty but at least it got the job done. The perc.sum turns it into one value p...
2
2016-06-23T11:27:39Z
[ "python", "pandas", "matplotlib", "data-visualization" ]
How to run python function using html form as input?
37,987,683
<p>I have a html form asking for album selection from a menu and client's email address from an input.</p> <pre class="lang-html prettyprint-override"><code>&lt;form&gt; &lt;h3&gt;Please select an album:&lt;/h3&gt; &lt;select&gt; &lt;option&gt;2016_May_Birthday_Party&lt;/option&gt; &lt;option&gt;20...
1
2016-06-23T09:33:48Z
37,987,842
<p>You need to specify <strong>action</strong> in <strong>form</strong> tag and create a view on the specified action's url where you can call that function. To create view you need to use anyone of the frameworks like flask, bottle, django etc. </p>
0
2016-06-23T09:40:05Z
[ "javascript", "python", "html" ]
How to run python function using html form as input?
37,987,683
<p>I have a html form asking for album selection from a menu and client's email address from an input.</p> <pre class="lang-html prettyprint-override"><code>&lt;form&gt; &lt;h3&gt;Please select an album:&lt;/h3&gt; &lt;select&gt; &lt;option&gt;2016_May_Birthday_Party&lt;/option&gt; &lt;option&gt;20...
1
2016-06-23T09:33:48Z
37,987,874
<p><em>There is no easy and short answer to this question.</em></p> <p>You need some simple server running to grab data that you want to send through email and then run sending mail part.</p> <p>If you are capable of learning from Python documentation, <a href="https://pythonhosted.org/flask-mail/" rel="nofollow">thi...
1
2016-06-23T09:41:30Z
[ "javascript", "python", "html" ]
Force function caller decide which default value is used
37,987,702
<p>Lets say I have the following function:</p> <pre><code>def myFun(a=None, b=None): print a, b </code></pre> <p>Now I call the function:</p> <pre><code>myFun("hi") # Case 1 &gt;&gt;&gt;hi None myFun(b="hi") # Case 2 &gt;&gt;&gt;None hi myFun(a="hi") # Case 3 &gt;&gt;&gt;hi None </code></pre> <p>Is there a wa...
1
2016-06-23T09:34:39Z
37,987,836
<pre><code>def my_fun(**kwargs): a = kwargs.get("a", None) b = kwargs.get("b", None) # have your code here... </code></pre> <p>Then: <code>my_fun("hi")</code> shouldn't work...</p>
2
2016-06-23T09:39:54Z
[ "python", "parameter-passing", "variable-assignment", "default-value", "function-call" ]
Force function caller decide which default value is used
37,987,702
<p>Lets say I have the following function:</p> <pre><code>def myFun(a=None, b=None): print a, b </code></pre> <p>Now I call the function:</p> <pre><code>myFun("hi") # Case 1 &gt;&gt;&gt;hi None myFun(b="hi") # Case 2 &gt;&gt;&gt;None hi myFun(a="hi") # Case 3 &gt;&gt;&gt;hi None </code></pre> <p>Is there a wa...
1
2016-06-23T09:34:39Z
37,987,984
<p>In Python3 you can specify <a href="https://www.python.org/dev/peps/pep-3102/">keyword-only arguments</a>:</p> <pre><code>def myFun(*, a=None, b=None): print(a, b) myFun('hi') </code></pre> <p>raises </p> <pre><code>TypeError: myFun() takes 0 positional arguments but 1 was given </code></pre> <hr> <p>In Py...
5
2016-06-23T09:45:11Z
[ "python", "parameter-passing", "variable-assignment", "default-value", "function-call" ]
Force function caller decide which default value is used
37,987,702
<p>Lets say I have the following function:</p> <pre><code>def myFun(a=None, b=None): print a, b </code></pre> <p>Now I call the function:</p> <pre><code>myFun("hi") # Case 1 &gt;&gt;&gt;hi None myFun(b="hi") # Case 2 &gt;&gt;&gt;None hi myFun(a="hi") # Case 3 &gt;&gt;&gt;hi None </code></pre> <p>Is there a wa...
1
2016-06-23T09:34:39Z
37,988,002
<p>You can actually allow the user to provide any arguments they'd like by using **kwargs.</p> <pre><code>def myFun(**kwargs): print kwargs[a] print kwargs[b] </code></pre> <p>This will cause an error if a or b aren't defined, but they're not very helpful.</p> <p>You can make your own errors by checking if t...
1
2016-06-23T09:46:04Z
[ "python", "parameter-passing", "variable-assignment", "default-value", "function-call" ]
Change encoding of XML file from ISO-8859-1 to ISO-8859-8
37,987,731
<p>I have an XML file that's in <code>ISO-8859-1</code> and I need it in <code>ISO-8859-8</code><br> I know it's <code>ISO-8859-1</code> by using <code>file -i output.xml</code> and I get <code>charset=iso-8859-1</code></p> <p>The xml is generated using a python script that gets a csv file.</p> <p>I've tried numerous...
-1
2016-06-23T09:35:46Z
37,988,222
<p>Errors like <code>UnicodeEncodeError: 'charmap' codec can't encode characters in position ...</code> usually show up when your source file isn't really encoded like you could think it is.</p> <p>To make sure your file is encoded as ISO-8859-1 you can check it with <a href="https://pypi.python.org/pypi/chardet" rel=...
0
2016-06-23T09:54:55Z
[ "python", "bash", "character-encoding" ]
Update collection in pymongo
37,987,913
<p>I would like to check the number of document inserted into my collection.</p> <p>Here is my code in Python:</p> <pre><code>from pymongo import MongoClient connection = MongoClient() db = connection['mydatabase'] collection1 = db.mycollection collection2=db.mycollection1 pipe = [{......}] result = collection1.aggre...
0
2016-06-23T09:42:48Z
38,029,415
<p>The <code>collection.aggregate()</code> method returns a <a href="https://api.mongodb.com/python/current/api/pymongo/command_cursor.html" rel="nofollow"><code>CommandCursor</code></a>, which is kind of like a Python generator that is iterable for only once. Therefore when you call <code>list(result)</code> you will ...
1
2016-06-25T14:15:54Z
[ "python", "mongodb", "aggregate", "updates" ]
Split String with unicode and backslash with Python
37,988,080
<p>I am experiencing trouble extracting a float from a string. The string is the output of webscraping:</p> <pre><code>input = u'&lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt;\r\n\xa3450.00pw&lt;/strong&gt;' </code></pre> <p>I want to get:</p> <p><code>output: 3450.00</code> </p> <p>but I...
1
2016-06-23T09:49:13Z
37,988,217
<p>The problem is <code>\xa3</code> is the pound sign in unicode. You're trying to split a unicode character in half when you do <code>split('\xa')</code>. The output you actually want is <code>450.00</code> because <code>\xa3450.00</code> translates to <code>£450.00</code>.</p> <pre><code>str.split('\xa3') </code></...
0
2016-06-23T09:54:39Z
[ "python", "unicode", "split", "web-scraping" ]
Split String with unicode and backslash with Python
37,988,080
<p>I am experiencing trouble extracting a float from a string. The string is the output of webscraping:</p> <pre><code>input = u'&lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt;\r\n\xa3450.00pw&lt;/strong&gt;' </code></pre> <p>I want to get:</p> <p><code>output: 3450.00</code> </p> <p>but I...
1
2016-06-23T09:49:13Z
37,988,430
<p><code>\xa3</code> is the pound sign.</p> <pre><code>import unidecode print unidecode.unidecode(input) &lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt; PS450.00pw&lt;/strong&gt; </code></pre> <p>To get the number from that, you better use regex:</p> <pre><code>import re num = re.compile(...
1
2016-06-23T10:03:21Z
[ "python", "unicode", "split", "web-scraping" ]
Split String with unicode and backslash with Python
37,988,080
<p>I am experiencing trouble extracting a float from a string. The string is the output of webscraping:</p> <pre><code>input = u'&lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt;\r\n\xa3450.00pw&lt;/strong&gt;' </code></pre> <p>I want to get:</p> <p><code>output: 3450.00</code> </p> <p>but I...
1
2016-06-23T09:49:13Z
37,988,433
<p>This code may help you:</p> <pre><code>import requests from bs4 import BeautifulSoup input = u'&lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt;\r\n\xa3450.00pw&lt;/strong&gt;' soup = BeautifulSoup(input) # Find all script tags for n in soup.find_all('strong'): # Check if the src attri...
-1
2016-06-23T10:03:22Z
[ "python", "unicode", "split", "web-scraping" ]
Split String with unicode and backslash with Python
37,988,080
<p>I am experiencing trouble extracting a float from a string. The string is the output of webscraping:</p> <pre><code>input = u'&lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt;\r\n\xa3450.00pw&lt;/strong&gt;' </code></pre> <p>I want to get:</p> <p><code>output: 3450.00</code> </p> <p>but I...
1
2016-06-23T09:49:13Z
37,988,548
<pre><code>input.encode('utf-8').split('\xa3')[1].split('pw')[0] &gt;&gt; 450.00 </code></pre> <p>Voilà</p>
-1
2016-06-23T10:07:50Z
[ "python", "unicode", "split", "web-scraping" ]
Split String with unicode and backslash with Python
37,988,080
<p>I am experiencing trouble extracting a float from a string. The string is the output of webscraping:</p> <pre><code>input = u'&lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt;\r\n\xa3450.00pw&lt;/strong&gt;' </code></pre> <p>I want to get:</p> <p><code>output: 3450.00</code> </p> <p>but I...
1
2016-06-23T09:49:13Z
37,988,672
<p>There is another possible solution for that:</p> <pre><code>import re x = u'&lt;strong class="ad-price txt-xlarge txt-emphasis " itemprop="price"&gt;\r\n\xa3450.00pw&lt;/strong&gt;' print re.findall(r'\d+.\d*', x) </code></pre> <blockquote> <p>output: [u'450.00']</p> </blockquote>
0
2016-06-23T10:12:59Z
[ "python", "unicode", "split", "web-scraping" ]
Python function (lettuce step) always retrurn True
37,988,096
<p>I am working with selenium and lettuce for testing in python. I have this step for counting employee table rows </p> <pre><code>@step('I count employee table rows') def i_count_emp_table_rows(step): try: elems = world.driver.find_elements_by_xpath(".//*[@id='myTable']/tr") sum = 0 for it...
2
2016-06-23T09:49:42Z
37,988,906
<p>You need to put the count into some global variable. See below updated steps.</p> <pre><code>@step('I count employee table rows') def i_count_emp_table_rows(step): try: elems = world.driver.find_elements_by_xpath(".//*[@id='myTable']/tr") world.count = len(elems) except Exception, e: ...
1
2016-06-23T10:22:57Z
[ "python", "selenium", "lettuce" ]