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 |
|---|---|---|---|---|---|---|---|---|---|
Use python to reduce number of hits in tabular blast output file | 37,703,222 | <p>I have a large blast files in tabular format, for which the number of target sequences weren't limited, so it takes a long time to parse. I want to reduce the number of hits for each query sequence to the first 10.
My python is basic but here's what I have so far</p>
<pre><code>import sys
blastfile = open(sys.argv... | 1 | 2016-06-08T12:58:55Z | 37,704,012 | <p>The problem here seems to be that you are iterating through your file object twice. In Python, file objects work a lot like pointers that read through every line. If you do not move the pointer back, it has nothing to read.</p>
<p>What you would have to do is use the <code>.seek</code> function to move this pointer... | 2 | 2016-06-08T13:32:50Z | [
"python",
"string",
"search",
"blast"
] |
iterate mysql table in python | 37,703,320 | <p>I have an array containning some mysql tables and I want to iterate and visualize.
For example but the programm is not working </p>
<pre><code> tab=["spectreH20","spectreH50"]
for features in tab:
sqlf="select * from WHERE table_name like",features
df=sql.read_sql(sqlf,conn)
p... | 1 | 2016-06-08T13:03:24Z | 37,703,481 | <p>You have a few issues.</p>
<p><code>"select * from WHERE table_name like"</code> isn't a valid SQL query, and <code>sqlf = "select * from WHERE table_name like", features</code> isn't a valid string formatting, so <code>sqlf</code> ends up being a tuple.</p>
<p>In an ideal world you would use a parameterized query... | 0 | 2016-06-08T13:10:44Z | [
"python",
"mysql",
"sql"
] |
Error using Google distance matrix API with Python | 37,703,524 | <p>This is my code:</p>
<pre><code>from googlemaps import Client as GoogleMaps
mapServices = GoogleMaps('')
start = 'texarkana'
end = 'atlanta'
direction = mapServices.directions(start, end)
for step in direction['Direction']['Routes'][0]['Steps']:
print(step['descriptionHtml'])
</code></pre>
<p>I am getting th... | -2 | 2016-06-08T13:12:48Z | 37,704,812 | <p>I would not be able to help you to directly pinpoint the error as I do not have an API key to try it for myself. However, I can give you some things that you can try and consider to find the root of the problem.</p>
<p>It seems that one of the indexes in your for loop (<code>for step in direction['Direction']['Rout... | -1 | 2016-06-08T14:04:49Z | [
"python",
"google-maps-api-2"
] |
How to serialize recursive relationship with self in Django REST Framework? | 37,703,567 | <p>consider the below assumptive models:</p>
<pre><code>class Category(models.Model):
name = models.CharField(max_length=100)
sub_category = models.ManyToManyField(u'self', null=True, blank=True,
through=u'SubCategory', symmetrical=False)
def __unicode__(self):
... | 3 | 2016-06-08T13:14:38Z | 37,704,133 | <p>I'd try the <code>djangorestframework-recursive</code> package, available here: <a href="https://github.com/heywbj/django-rest-framework-recursive" rel="nofollow">https://github.com/heywbj/django-rest-framework-recursive</a></p>
| 1 | 2016-06-08T13:38:08Z | [
"python",
"django",
"recursion",
"django-rest-framework",
"serializer"
] |
How to create custom testcase settings in Robot Framework | 37,703,590 | <p>I want to create a custom settings (OR Attribute) (say <code>TEST_ID</code>) in Robot Framework to tag them with test id.
During teardown I will use that settings to update my test management tool to record the execution result.</p>
<pre><code>*** Test Cases ***
Test With Settings
[Documentation] Another dum... | 0 | 2016-06-08T13:15:22Z | 37,704,252 | <p>There is no need to create a new attribute. You can use tags.
You could tag your tests with something like ALMID:5432. In the teardown, the tags are available via the builtin variable @{TEST_TAGS}. The list could be searched and the id extracted from the tag.</p>
| 1 | 2016-06-08T13:42:50Z | [
"python",
"robotframework"
] |
Using python Logging with AWS Lambda | 37,703,609 | <p>As the AWS documentation suggests:</p>
<pre><code>import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def my_logging_handler(event, context):
logger.info('got event{}'.format(event))
logger.error('something went wrong')
</code></pre>
<p>Now I made:</p>
<pre><code>import logging
loggi... | 2 | 2016-06-08T13:15:55Z | 37,705,997 | <p>Probably not referencing the same logger, actually.
In the first snippet, log the return of: <code>logging.Logger.manager.loggerDict</code></p>
<p>It will return a <code>dict</code> of the loggers already initialized.</p>
<p>Also, from the <code>logging</code> documentation, an important note on <code>logging.basi... | 1 | 2016-06-08T14:52:54Z | [
"python",
"amazon-web-services",
"logging",
"aws-lambda"
] |
How to import a text file on AWS S3 into pandas without writing to disk | 37,703,634 | <p>I have a text file saved on S3 which is a tab delimited table. I want to load it into pandas but cannot save it first because I am running on a heroku server. Here is what I have so far.</p>
<pre><code>import io
import boto3
import os
import pandas as pd
os.environ["AWS_ACCESS_KEY_ID"] = "xxxxxxxx"
os.environ["AWS... | 2 | 2016-06-08T13:16:49Z | 37,703,861 | <p><code>pandas</code> uses <code>boto</code> for <code>read_csv</code>, so you should be able to:</p>
<pre><code>import boto
data = pd.read_csv('s3:/bucket....csv')
</code></pre>
<p>If you need <code>boto3</code> because you are on <code>python3.4+</code>, you can</p>
<pre><code>import boto3
s3 = boto3.client('s3')... | 1 | 2016-06-08T13:26:22Z | [
"python",
"pandas",
"heroku",
"amazon-s3",
"boto3"
] |
Django migrate unique field between models with data | 37,703,729 | <p>Let's assume I have this models structure:</p>
<pre><code>class User(AbstractUser):
first_name = models.CharField(max_length=40, blank=True)
last_name = models.CharField(max_length=40, blank=True)
class UserProfile(models.Model):
uuid = models.UUIDField(unique=True, null=False, default=uuid4)
user... | 0 | 2016-06-08T13:21:05Z | 37,714,645 | <p>First, add the <code>uuid</code> field to the <code>User</code> model. Create a migration.</p>
<p>Then, create a <a href="https://docs.djangoproject.com/en/dev/topics/migrations/#data-migrations" rel="nofollow">data migration</a> and add a <a href="https://docs.djangoproject.com/en/dev/ref/migration-operations/#dja... | 1 | 2016-06-08T23:35:10Z | [
"python",
"django",
"django-models",
"django-migrations"
] |
I want to delete data that do not serve me, and retrieve only the data from the link | 37,703,739 | <p>Thanks to Ethernet connection from my laptop to a i40 from precia molen I can catch informations by typing this in the web :
<a href="http://192.168.1.101/ValPoids.cgx" rel="nofollow">http://192.168.1.101/ValPoids.cgx</a>
This retrieves me a value of the weighing sensors.
Thanks to python I wrote a little code like... | 0 | 2016-06-08T13:21:25Z | 37,703,992 | <p>Use BeautifulSoup to get only the text of the elements.
Or you can use regex.
If you don't have BeautifulSoup you should install it first.</p>
<p><strong>pip install beautifulsoup4</strong></p>
<p>With BeautifulSoup:</p>
<pre><code>from bs4 import BeautifulSoup
soup = BeautifulSoup(page.read(), 'html.parser')
all... | 1 | 2016-06-08T13:32:13Z | [
"python",
"html-parsing"
] |
I want to delete data that do not serve me, and retrieve only the data from the link | 37,703,739 | <p>Thanks to Ethernet connection from my laptop to a i40 from precia molen I can catch informations by typing this in the web :
<a href="http://192.168.1.101/ValPoids.cgx" rel="nofollow">http://192.168.1.101/ValPoids.cgx</a>
This retrieves me a value of the weighing sensors.
Thanks to python I wrote a little code like... | 0 | 2016-06-08T13:21:25Z | 37,704,833 | <pre><code>import urllib.request
import time
pip install beautifulsoup4
from bs4 import BeautifulSoup
soup = BeautifulSoup(page.read(), 'html.parser')
all_forms = soup.findAll('form')
for form in all_forms:
print (form.text)
while True :
page = urllib.request.urlopen('http://192.168.1.101/ValPoids.cgx')
... | 0 | 2016-06-08T14:05:30Z | [
"python",
"html-parsing"
] |
I want to delete data that do not serve me, and retrieve only the data from the link | 37,703,739 | <p>Thanks to Ethernet connection from my laptop to a i40 from precia molen I can catch informations by typing this in the web :
<a href="http://192.168.1.101/ValPoids.cgx" rel="nofollow">http://192.168.1.101/ValPoids.cgx</a>
This retrieves me a value of the weighing sensors.
Thanks to python I wrote a little code like... | 0 | 2016-06-08T13:21:25Z | 37,734,791 | <p>Finally, I try to find a solution and by this way you can easily erase the part of the result that you don't need : </p>
<p>You load the file with :</p>
<pre><code>ln=open("your_file")
</code></pre>
<p>Then you read ln and you convert ln to a string thanks to this :</p>
<pre><code>ln = str(ln.read())
ln = str(ln... | 0 | 2016-06-09T19:38:56Z | [
"python",
"html-parsing"
] |
How to reshape data to None in tensorflow? | 37,703,886 | <p>I'm using tensorflow run queues to feed my data during training time:</p>
<pre><code>X, Y = tf.train.batch(
[image, label],
batch_size=64
)
</code></pre>
<p>However X, Y have forced shape of [64, 32, 32,3], and [64, 10]. During evaluation time I'd like to run loss operation on whole ... | 1 | 2016-06-08T13:27:07Z | 37,704,866 | <p>This is a bit subtle: in TensorFlow terminology, you don't actually want to <code>reshape</code> the tensor (i.e. change the number of elements in each dimension), but instead you want TensorFlow to "forget" a specific dimension, in order to feed values with a range of sizes.</p>
<p>The <a href="https://www.tensorf... | 3 | 2016-06-08T14:07:09Z | [
"python",
"tensorflow"
] |
Bytes from zip file to text in python | 37,703,897 | <p>Once the contents of a gzip file is extracted into a string called <code>text</code>, it looks like gibberish. How can I turn it into something human-readable?</p>
<pre><code>with open("zipped_ex.gz.2016") as f:
text = f.read()
print text
</code></pre>
<p>Note: I'm not searching for a way to go from zipp... | 0 | 2016-06-08T13:27:42Z | 37,703,918 | <pre><code>import gzip
with gzip.GzipFile("zipped_ex.gz.2016") as f:
text = f.read()
print text
</code></pre>
<p>On the disk, the file is a binary blop that is humanly unreadable.<br>
To work with the data inside the archive you need to some how extract it.</p>
<p>In this case, in memory via the <code>GzipFil... | 2 | 2016-06-08T13:29:00Z | [
"python",
"file-io",
"gzip"
] |
How cache data from SQL-database with python? | 37,703,938 | <p>I have queries result from Postgresql which I want to be cached. I can't use external soft like memcached. How I can do it with python with standard library? Or may be with third party python module.</p>
| 0 | 2016-06-08T13:29:52Z | 37,707,333 | <p>If you want to use a 3rd party library you could take a look at <a href="http://dogpilecache.readthedocs.io/en/latest/usage.html" rel="nofollow">dogpile.cache</a>. It will allow you to cache things like data from SQL databases in memory, and in addition you can choose from different <a href="http://dogpilecache.read... | 0 | 2016-06-08T15:52:51Z | [
"python",
"caching"
] |
"if" statement Looping through twice when using data driven pages | 37,704,014 | <p>I have a script which is designed to place inset maps onto specific pages while exporting Data Driven Pages, the script is amalgamation of a friend's work and some of my own code from other projects. </p>
<p>The issue is the code exports pages 15 and 16 twice one with my inset maps and the other without and I can't... | 0 | 2016-06-08T13:33:00Z | 37,709,670 | <p>I believe your problem is that when the pgIndex is 15 it performs the export as intended. Then it checks if the pgIndex is 16. The pgIndex is not 16 so it drops into the <code>else</code> and re-exports without the inset maps. I would recommend changing the second if to an <code>elif</code></p>
| 1 | 2016-06-08T17:58:55Z | [
"python",
"python-3.x",
"arcgis",
"arcpy"
] |
How to return primary keys generated from a COPY FROM statement in postgreSQL? | 37,704,119 | <p>I'm uploading thousands of rows into my postgreSQL database and to do so I'm using the <code>COPY FROM</code> statement to save processing time.</p>
<p>I didn't found any information about that on StackExchange so I'm asking now: is it possible to retrieve the primary keys (or other column value) generated from the... | 1 | 2016-06-08T13:37:34Z | 37,705,751 | <p>It's not possible with <code>COPY</code>.</p>
<p>Only an <code>INSERT</code> with <code>RETURNING id</code> can give you id-s.</p>
<p>The fastest next to <code>COPY</code> approach would be a multi-row insert:</p>
<pre><code>INSERT INTO table(col1, col2) VALUES (val1, val2), (val3, val4),... RETURNING id
</code><... | 1 | 2016-06-08T14:43:30Z | [
"c#",
"python",
"postgresql",
"return",
"primary-key"
] |
Dynamically create class instances from given strings and save deep copy in dictionary | 37,704,145 | <p>I want to create multiple class instances (copied) dynamically from a set of given strings and got stuck with it.</p>
<p>Here's my approach:</p>
<pre><code># -*- coding: utf-8 -*-
# I have an number of different classes
class FourLegs:
def __init__(self, name, age):
self.name = name
self.age ... | 0 | 2016-06-08T13:38:34Z | 37,704,207 | <p>You are not creating <em>instances</em>, you are setting attributes directly on the class instead. Because you are altering attributes on the <em>same two classes</em> each time, you see the last values set reflected in the attributes on these two classes.</p>
<p><em>Call</em> your class, passing in the name and ag... | 2 | 2016-06-08T13:40:56Z | [
"python",
"python-3.x"
] |
get a return value from a Daemon Process in Python | 37,704,171 | <p>I have written a python daemon process that can be started and stopped using the following commands</p>
<pre><code>/usr/local/bin/daemon.py start
/usr/local/bin/daemon.py stop
</code></pre>
<p>I can achieve the same results by calling these commands from a python script</p>
<pre><code>os.system('/usr/local/bin/da... | 0 | 2016-06-08T13:39:36Z | 37,704,511 | <p>I think, marshaling is what you need: <a href="https://docs.python.org/2.7/library/marshal.html" rel="nofollow">https://docs.python.org/2.7/library/marshal.html</a> & <a href="https://docs.python.org/2/library/pickle.html" rel="nofollow">https://docs.python.org/2/library/pickle.html</a></p>
| 0 | 2016-06-08T13:52:45Z | [
"python",
"unix",
"daemon"
] |
get a return value from a Daemon Process in Python | 37,704,171 | <p>I have written a python daemon process that can be started and stopped using the following commands</p>
<pre><code>/usr/local/bin/daemon.py start
/usr/local/bin/daemon.py stop
</code></pre>
<p>I can achieve the same results by calling these commands from a python script</p>
<pre><code>os.system('/usr/local/bin/da... | 0 | 2016-06-08T13:39:36Z | 37,704,636 | <p>Don't you mean you want to implement simple serialization and deserialization?
In that case I'd propose to look at pickle (<a href="https://docs.python.org/2/library/pickle.html" rel="nofollow">https://docs.python.org/2/library/pickle.html</a>) to transform your data into a generic text format at the daemon side and... | 1 | 2016-06-08T13:57:44Z | [
"python",
"unix",
"daemon"
] |
How to update the command of an OptionMenu | 37,704,176 | <p>I am trying to set or update the command of an OptionMenu after its instantiation. </p>
<p>The <code>widget.configure(command=foo)</code> statement works for <code>Button</code> and <code>CheckButton</code>, but not for <code>OptionMenu</code>. </p>
<p>The following code raises this error: <code>_tkinter.TclError:... | 2 | 2016-06-08T13:39:45Z | 37,705,574 | <p>Good question! Its a good thing I never had to do this in any one of my projects before because (unless someone proves me wrong here)<b> you can't set/update the command of a OptionMenu widget once its already defined.</b></p>
<p>If Tkinter wanted you to be able to do that, it definitely would've included it to be ... | 3 | 2016-06-08T14:36:05Z | [
"python",
"tkinter"
] |
How to update the command of an OptionMenu | 37,704,176 | <p>I am trying to set or update the command of an OptionMenu after its instantiation. </p>
<p>The <code>widget.configure(command=foo)</code> statement works for <code>Button</code> and <code>CheckButton</code>, but not for <code>OptionMenu</code>. </p>
<p>The following code raises this error: <code>_tkinter.TclError:... | 2 | 2016-06-08T13:39:45Z | 37,707,308 | <p>I think what you're really asking is how to associate a command to an <code>Optionmenu</code>, rather than <em>update</em> a command (there is no command, so there's nothing to update).</p>
<p>If you want a function to be called every time a value is selected from an <code>Optionmenu</code>, you can add a trace on ... | 2 | 2016-06-08T15:51:39Z | [
"python",
"tkinter"
] |
Site not serving media files but serving static files correctly | 37,704,197 | <p>I have a Django site in production. Static files are being served fine, but media files are failing to be retrieved.</p>
<p>my setting.py :</p>
<pre><code>PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')
STATIC_URL = '/static/'
MEDIA_ROOT = os.path.join(... | 0 | 2016-06-08T13:40:30Z | 37,704,752 | <p>Are you sure <code>/var/www/MySite/media</code> is your media directory? </p>
<p>Maybe you confuse the staticfiles (which are collected by the <code>collectstatic</code> command) with the mediafiles, which are saved by users of the webapp.</p>
<p>Looking at your settings, I believe your apache configuration should... | 1 | 2016-06-08T14:02:36Z | [
"python",
"django",
"apache"
] |
How to parse values like \x00, \x95x95? | 37,704,200 | <p>I have String which is like:
<code>\x00\x00\x01\x90\x27</code> and on. </p>
<p>How can I parse this value to a simple long value? </p>
<p>Like, what is the long value of <code>\x00</code>? <code>0</code> or <code>00</code>?</p>
| -3 | 2016-06-08T13:40:35Z | 37,704,592 | <p>I am assuming that you thing your data is character... </p>
<p>So using python 3</p>
<pre><code> a=b'\x00\x00\x01\x90'
b=b.decode('utf-8')
</code></pre>
<p>If your binary data has some 'nasty' i.e. bad characters this will fail - but adding an option like errors='ignore' or errors='replace' will assist you unhan... | 0 | 2016-06-08T13:55:43Z | [
"python"
] |
How to parse values like \x00, \x95x95? | 37,704,200 | <p>I have String which is like:
<code>\x00\x00\x01\x90\x27</code> and on. </p>
<p>How can I parse this value to a simple long value? </p>
<p>Like, what is the long value of <code>\x00</code>? <code>0</code> or <code>00</code>?</p>
| -3 | 2016-06-08T13:40:35Z | 37,704,663 | <p>Your question is not very clear so I am making some assumptions here. If you need fixed length conversions then you can use standard <a href="https://docs.python.org/2/library/struct.html" rel="nofollow">structs</a> module.</p>
<p>For example:</p>
<pre><code>In [11]: unpack('>i', '\x00\x01\x90\x27')
Out[11]: (1... | 0 | 2016-06-08T13:58:52Z | [
"python"
] |
telnetlib.write() doesn't replicate telnet.interact() | 37,704,228 | <p>I've got this spectrum analyzer from the 90's that has a telnet client on it. I can telnet in with the Linux telnet CLI, and that works great...controls the machine as expected.</p>
<p>I'd like to automate this thing to do 100's of different measurements in a set-it-and-forget-it style setup, so Python is natural.... | 0 | 2016-06-08T13:41:59Z | 37,755,847 | <p>This is a duplicate of <a href="http://stackoverflow.com/a/14606871/440558.">this</a></p>
<p>Needed to add an <code>\r</code> to the newline binary portion of the message, so
<code>tn.write(b'freq:star 110khz\r</code> won't work, but <code>tn.write(b'freq:star 110khz\r\n</code> will.</p>
| 0 | 2016-06-10T19:29:31Z | [
"python",
"linux",
"python-3.x",
"automated-tests",
"telnet"
] |
Python - Bug in code | 37,704,264 | <p>This might be an easy one, but I can't spot where I am making the mistake. </p>
<p>I wrote a simple program to read words from a wordfile (don't have to be dictionary words), sum the characters and print them out from lowest to highest. (PART1)</p>
<p>Then, I wrote a small script after this program to filter and s... | 0 | 2016-06-08T13:43:08Z | 37,704,738 | <p>The problem is that <code>charAt</code> does not exist in python.</p>
<p>You can use directly: 'for ch in my_word`.</p>
<p>Notes:</p>
<ol>
<li><p>you can use the builtin <code>str.isalnum()</code> for you test</p></li>
<li><p>valid_characters contains only the uppercase version of the alphabet</p></li>
</ol>
| 1 | 2016-06-08T14:01:45Z | [
"python"
] |
Cannot create a python 3 virtualenv | 37,704,367 | <p>I do not succeed to create a python 3 virtualenv. This is what I get:</p>
<pre><code>poiuytrez$ virtualenv --no-site-packages -p /usr/local/bin/python3.5
Running virtualenv with interpreter /usr/local/bin/python3.5
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/enum/__init__.py", line ... | 2 | 2016-06-08T13:46:24Z | 37,704,666 | <p>You are using the virtualenv for Python 2.7 to create a virtual environment for Python 3.5, which I don't think will work.</p>
<p>Instead of <code>virtualenv</code>, On Python 3.3+ you could use the <a href="https://docs.python.org/3/library/venv.html" rel="nofollow">built-in <code>pyvenv</code> tool</a> to create ... | 2 | 2016-06-08T13:58:53Z | [
"python",
"osx",
"virtualenv"
] |
Integrating Google Sign-in and Calendar access in an Django application | 37,704,491 | <p>I'm trying to integrate Google Sign-in and access to Google Calendar, in a Django app. I've successfully dealt with the former using <code>python-social-auth</code>. </p>
<p>I've also managed to get a simple django app with calendar access using <code>google-api-python-client</code> based on the code <a href="http... | 1 | 2016-06-08T13:52:07Z | 37,743,757 | <p>Try the <a href="https://developers.google.com/google-apps/calendar/quickstart/python" rel="nofollow">Calendar Quickstart for Python</a>. It includes signing-in and using that authentication to generate tokens. This tokens will be used to perform Calendar API calls. Play with it and add your own code.</p>
<p>Here's... | 0 | 2016-06-10T08:42:45Z | [
"python",
"django",
"google-calendar",
"google-signin"
] |
Integrating Google Sign-in and Calendar access in an Django application | 37,704,491 | <p>I'm trying to integrate Google Sign-in and access to Google Calendar, in a Django app. I've successfully dealt with the former using <code>python-social-auth</code>. </p>
<p>I've also managed to get a simple django app with calendar access using <code>google-api-python-client</code> based on the code <a href="http... | 1 | 2016-06-08T13:52:07Z | 38,431,868 | <p>Here's how I managed to get it working:</p>
<p>models.py</p>
<pre><code>from django.db import models
from oauth2client.contrib.django_orm import CredentialsField
class Credentials(models.Model):
id = models.OneToOneField(User, primary_key=True)
credential = CredentialsField()
class Meta:
db_t... | 0 | 2016-07-18T08:25:02Z | [
"python",
"django",
"google-calendar",
"google-signin"
] |
Cannot access functions from an imported module under Python 3.5 | 37,704,721 | <p>I am trying to get a Python module called MTpy to run on my computer; this package allows handling and processing of magnetotelluric (geophysical) data.
I am using Python 3.5 with the Anaconda/Spyder IDE under Windows 10.
I am just getting started with Python so I apologize if my question seems trivial!</p>
<p>My ... | 1 | 2016-06-08T14:01:04Z | 37,704,798 | <p><code>distortion.py</code> <strong>isn't</strong> a function it's a sub package of <code>analysis</code> and <strong>it's not callable</strong>. You can methods which is defined in <a href="https://github.com/geophysics/mtpy/blob/master/mtpy/analysis/distortion.py" rel="nofollow">mtpy.analysis.distortion</a>. You ca... | 1 | 2016-06-08T14:04:27Z | [
"python"
] |
How to put item on top of the Queue in python? | 37,704,832 | <p>Is it possible to put items on the top of a Queue instead of the bottom?
In same cases I need to re-popoulate the Queue by mantaining the original order after that I've get items.</p>
| 0 | 2016-06-08T14:05:30Z | 37,704,906 | <p>No, by definition, putting into a queue is to the end.</p>
<p>You want to use <a href="https://docs.python.org/3/library/collections.html#collections.deque" rel="nofollow">deque</a> instead.</p>
| 2 | 2016-06-08T14:08:50Z | [
"python",
"python-2.7",
"queue"
] |
How can i solve a migration issue in django project hosted on heroku? | 37,704,938 | <p>My project hosted on heroku and recently i want to change the size of one column
in db
but after running <strong>makemigrations</strong> command and then <strong>migrate</strong> command it gives an error and i don't want to lose my data .</p>
<pre><code> H:\shuboy2014>heroku run python manage.py makemigration... | 1 | 2016-06-08T14:10:16Z | 37,705,627 | <p>I just run <strong>makemigrations</strong> and <strong>migrate</strong> command on my local computer and then push it on heroku and run both commands again and its done .</p>
<pre><code> H:\shuboy2014>heroku run python manage.py migrate
Running python manage.py migrate on shuboy2014... up, run.6192
Operations... | 1 | 2016-06-08T14:37:56Z | [
"python",
"django",
"heroku",
"django-models"
] |
How can i solve a migration issue in django project hosted on heroku? | 37,704,938 | <p>My project hosted on heroku and recently i want to change the size of one column
in db
but after running <strong>makemigrations</strong> command and then <strong>migrate</strong> command it gives an error and i don't want to lose my data .</p>
<pre><code> H:\shuboy2014>heroku run python manage.py makemigration... | 1 | 2016-06-08T14:10:16Z | 37,706,536 | <p><code>heroku run</code> commands run on One-Off Dynos with an ephemeral file system, so you are generating the migrations files on a file system that is immediately destroyed.</p>
<p>You should generate migrations locally, committing and pushing them, and then executing the <code>heroku run python manage.py migrate... | 2 | 2016-06-08T15:15:11Z | [
"python",
"django",
"heroku",
"django-models"
] |
Parsed a XML file using lxml based of text string | 37,705,016 | <p>I have an XML file which i would like to retrive the <em>text</em> attribute of an element based on a string.</p>
<p>In the example below, i would like to find all subject elements which contains the string <em>home</em> (two elements). Once i get the elements, I can retrive the <em>text</em> value.</p>
<pre><code... | -1 | 2016-06-08T14:14:27Z | 37,705,100 | <p>Use the <a href="https://developer.mozilla.org/en-US/docs/Web/XPath/Functions/contains" rel="nofollow"><code>contains()</code></a> XPath function:</p>
<pre><code>//subject[contains(., 'home')]/text()
</code></pre>
<p>Demo:</p>
<pre><code>>>> import lxml.etree as ET
>>>
>>> data = """<... | 2 | 2016-06-08T14:18:17Z | [
"python",
"python-3.x",
"lxml"
] |
Permissions denied on production server when using pip install | 37,705,021 | <p>I am trying to install a package to my Django application on the production server, and am getting a permission denied error. Below is the traceback. I have installed other packages with pip install, and it hasn't given me any issues, so I am not entirely sure why I am getting this issue. </p>
<pre><code>[humanlink... | 0 | 2016-06-08T14:14:41Z | 37,705,084 | <p>Have you search on google about this issue ?</p>
<p>try this :
<a href="https://community.webfaction.com/questions/16163/getting-permission-denied-trying-to-install-sqlalchemy" rel="nofollow">https://community.webfaction.com/questions/16163/getting-permission-denied-trying-to-install-sqlalchemy</a></p>
<p>OR<... | 1 | 2016-06-08T14:17:27Z | [
"python",
"django",
"pip",
"production"
] |
Permissions denied on production server when using pip install | 37,705,021 | <p>I am trying to install a package to my Django application on the production server, and am getting a permission denied error. Below is the traceback. I have installed other packages with pip install, and it hasn't given me any issues, so I am not entirely sure why I am getting this issue. </p>
<pre><code>[humanlink... | 0 | 2016-06-08T14:14:41Z | 37,705,151 | <p>You should be root to install system-wide, if you can't you can just do</p>
<pre><code>pip install --user cryptography
</code></pre>
| 2 | 2016-06-08T14:19:56Z | [
"python",
"django",
"pip",
"production"
] |
How to create a dictionary from a list with a list of keys only and key-value pairs (Python)? | 37,705,101 | <p>This is an extension of this question: <a href="http://stackoverflow.com/questions/12739911/how-to-separate-string-and-create-a-key-value-pairs-python">How to split a string within a list to create key-value pairs in Python</a></p>
<p>The difference from the above question is the items in my list are not all key-va... | 3 | 2016-06-08T14:18:22Z | 37,705,271 | <pre><code>input_list = ['abc=ddd', 'ef', 'ghj', 'jkl=yui', 'rty']
output_dict = {}
for item in input_list:
item_split = item.split('=')
key = item_split[0]
value = item_split[1] if len(item_split)>1 else 1
output_dict[key] = value
</code></pre>
<p>a bit more concisely</p>
<pre><code>for item in i... | 1 | 2016-06-08T14:24:55Z | [
"python",
"string",
"list",
"dictionary"
] |
How to create a dictionary from a list with a list of keys only and key-value pairs (Python)? | 37,705,101 | <p>This is an extension of this question: <a href="http://stackoverflow.com/questions/12739911/how-to-separate-string-and-create-a-key-value-pairs-python">How to split a string within a list to create key-value pairs in Python</a></p>
<p>The difference from the above question is the items in my list are not all key-va... | 3 | 2016-06-08T14:18:22Z | 37,705,455 | <p>For each split "pair", you can append <code>[1]</code> and extract the first 2 elements. This way, 1 will be used when there isn't a value:</p>
<pre><code>print dict((s.split('=')+[1])[:2] for s in l)
</code></pre>
| 9 | 2016-06-08T14:31:52Z | [
"python",
"string",
"list",
"dictionary"
] |
How to create a dictionary from a list with a list of keys only and key-value pairs (Python)? | 37,705,101 | <p>This is an extension of this question: <a href="http://stackoverflow.com/questions/12739911/how-to-separate-string-and-create-a-key-value-pairs-python">How to split a string within a list to create key-value pairs in Python</a></p>
<p>The difference from the above question is the items in my list are not all key-va... | 3 | 2016-06-08T14:18:22Z | 37,705,606 | <p>I would be using something similar to the post you linked.</p>
<pre><code>d = dict(s.split('=') for s in a)
</code></pre>
<p>If you combine what you can learn from this post -- that is to use lists to create dictionaries -- and from using <a href="http://stackoverflow.com/questions/4260280/if-else-in-pythons-list-... | 3 | 2016-06-08T14:37:24Z | [
"python",
"string",
"list",
"dictionary"
] |
How to create a dictionary from a list with a list of keys only and key-value pairs (Python)? | 37,705,101 | <p>This is an extension of this question: <a href="http://stackoverflow.com/questions/12739911/how-to-separate-string-and-create-a-key-value-pairs-python">How to split a string within a list to create key-value pairs in Python</a></p>
<p>The difference from the above question is the items in my list are not all key-va... | 3 | 2016-06-08T14:18:22Z | 37,705,621 | <p>Here are the step-by-step approach.</p>
<pre><code>In [50]: mylist = ['abc=ddd', 'ef', 'ghj', 'jkl=yui', 'rty']
In [51]: [element.split('=') for element in mylist]
Out[51]: [['abc', 'ddd'], ['ef'], ['ghj'], ['jkl', 'yui'], ['rty']]
In [52]: [element.split('=') + [1] for element in mylist]
Out[52]: [['abc', 'ddd',... | 1 | 2016-06-08T14:37:48Z | [
"python",
"string",
"list",
"dictionary"
] |
Pymongo error Server Timeout | 37,705,231 | <p>I installed the latest version of Pymongo 3.2.2 using pip. Additionally I use Python 3.4 Anaconda. I am trying to do a simple insert. Here is my code:</p>
<pre><code>>>> from pymongo import MongoClient
>>> client = MongoClient(connect=False)
>>> client["mydb"]
Database(MongoClient(host=['... | 0 | 2016-06-08T14:23:00Z | 37,713,748 | <p>Resolved in <a href="https://jira.mongodb.org/browse/PYTHON-1100" rel="nofollow">https://jira.mongodb.org/browse/PYTHON-1100</a>. The issue was the machine's hosts file had localhost mapped only to IPv6 and MongoDB doesn't listen on IPv6 by default.</p>
| 1 | 2016-06-08T22:04:49Z | [
"python",
"mongodb",
"pymongo-3.x"
] |
Django REST Framework -- update view method never called | 37,705,233 | <p>I am designing an API endpoint using Django REST Framework, and would like for it to accept GET, PATCH, and PUT methods at the following endpoint:</p>
<pre><code>/department/<department_pk>/details/population/
</code></pre>
<p>there is a 1:1 relationship between the Department model and the DepartmentPopulat... | 1 | 2016-06-08T14:23:05Z | 37,705,882 | <p>You will need a different URL to handle those cases. </p>
<p>Create means that your DepartmentStudyPopulation is new, and won't have a primary key (it gets generated on createion). </p>
<p>Update will require a url that has the primary key in it, so that Django knows what object to update. </p>
<p>(Showing the UR... | 0 | 2016-06-08T14:48:37Z | [
"python",
"django",
"rest",
"django-rest-framework"
] |
Django REST Framework -- update view method never called | 37,705,233 | <p>I am designing an API endpoint using Django REST Framework, and would like for it to accept GET, PATCH, and PUT methods at the following endpoint:</p>
<pre><code>/department/<department_pk>/details/population/
</code></pre>
<p>there is a 1:1 relationship between the Department model and the DepartmentPopulat... | 1 | 2016-06-08T14:23:05Z | 37,706,006 | <p><strong>Why the <code>update()</code> method never gets called</strong>?</p>
<p>This is because you have incorrectly defined the urls. </p>
<p>This url </p>
<pre><code>'departments/(?P<department_pk>[0-9]+)/details/population'
</code></pre>
<p>with router generates the following urls.</p>
<pre><code>'dep... | 3 | 2016-06-08T14:53:20Z | [
"python",
"django",
"rest",
"django-rest-framework"
] |
"pygame.display.update()" does not clear blit image | 37,705,361 | <p>I have this main loop that updates an image at a point:</p>
<p>The loop:</p>
<pre><code>while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
self.spaceship.buttons()
self.spaceship.update(self.screen)
pygame.display.update()
</code></pre>
<p>Whe... | 1 | 2016-06-08T14:28:20Z | 37,705,492 | <p>It's quite simple, pygame doesn't do this for you.<br>
<code>pygame.display.update()</code> updates the entire scene to show the user <strong>the new content</strong> you've "blipped". It doesn't erase the past.</p>
<p><em>It can also be used to only update certain areas where you know you've done some updates (to ... | 2 | 2016-06-08T14:33:04Z | [
"python",
"pygame"
] |
"pygame.display.update()" does not clear blit image | 37,705,361 | <p>I have this main loop that updates an image at a point:</p>
<p>The loop:</p>
<pre><code>while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
sys.exit()
self.spaceship.buttons()
self.spaceship.update(self.screen)
pygame.display.update()
</code></pre>
<p>Whe... | 1 | 2016-06-08T14:28:20Z | 37,748,786 | <p>Pygame will only draw what you tell it to. If you only tell it to draw your spaceship in a new position, it will do just that, and not touch any of the other things you have previously drawn. This is useful, because it allows you to only update those portions of the screen that have changed since your last update, w... | 1 | 2016-06-10T12:51:50Z | [
"python",
"pygame"
] |
Plug-in org.python.pydev was unable to load class org.python.pydev.editor.PyEdit | 37,705,427 | <p>My Eclipse stalled so I shut it down (normally, I didn't send any kill signal or anything, the editor was bugging but the menu was still working so I simply quit it from the menu).</p>
<p>When I reopened eclipse however I got the problem:</p>
<blockquote>
<p>Plug-in org.python.pydev was unable to load class org.... | 0 | 2016-06-08T14:30:49Z | 37,706,507 | <p>I have absolutely no idea why it solved the problem, but updating the Maven Plugins solved the problem.</p>
| 0 | 2016-06-08T15:13:47Z | [
"python",
"eclipse",
"pydev"
] |
How can I automate the creation of Pandas dataframes, from a folder of .xls, with a list of variable names? | 37,705,483 | <p>I have a folder with a number of files. I want to import the sheet 'sheet1' as a pandas dataframe for each of them, assigned to the name of a portion of that title.</p>
<p>I've successfully gotten a list of filenames:</p>
<pre><code>path = "/Users/path"
files = os.listdir(path)
files_xls = [f for f in files if f[-... | 1 | 2016-06-08T14:32:52Z | 37,705,836 | <p>Use <code>.zip</code> to combine your two <code>lists</code> into a <code>dict</code>, iterate over the result using <code>.items()</code> and collect <code>pd.read_excel()</code> in a <code>dict</code>:</p>
<pre><code>df = {}
for name, f in dict(zip(names, files_xls)).items():
df[name] = pd.read_excel(f, 'shee... | 1 | 2016-06-08T14:46:59Z | [
"python",
"excel",
"pandas",
"dataframe"
] |
How can I automate the creation of Pandas dataframes, from a folder of .xls, with a list of variable names? | 37,705,483 | <p>I have a folder with a number of files. I want to import the sheet 'sheet1' as a pandas dataframe for each of them, assigned to the name of a portion of that title.</p>
<p>I've successfully gotten a list of filenames:</p>
<pre><code>path = "/Users/path"
files = os.listdir(path)
files_xls = [f for f in files if f[-... | 1 | 2016-06-08T14:32:52Z | 37,705,887 | <p>There are two options that suppose to work for you:</p>
<p><strong>1.</strong></p>
<pre><code>for name in names:
xlsx[name] = pd.ExcelFile('PATH\' + name + '.xlsx')
sheets[name] = xlsx.parse(0)
</code></pre>
<p><strong>2.</strong> </p>
<pre><code>for name in names:
xlsx[name] = pd.read_exc... | -1 | 2016-06-08T14:48:47Z | [
"python",
"excel",
"pandas",
"dataframe"
] |
NameError: name 'VAR' is not defined | 37,705,535 | <p>I have a Python script here that is for figuring out the dimensions of a work space to then figure out where the automation script should be clicking or inputting data.</p>
<p>I am running into a problem with a variable have made in one function but isn't accessible in another. I returned the variable I'd like to c... | 0 | 2016-06-08T14:34:24Z | 37,705,881 | <p>I found my mistake!</p>
<p>I didn't state that the variables were coming from those functions when I called them in the function areaSetup()</p>
<p>Here's what I did :</p>
<pre><code> def areaSetup():
workSpace = getWorkSpace ('img/dimen/loginDimTop.png' , 'img/dimen/loginDimBot.png')
W, H, Hh, Wh =... | 0 | 2016-06-08T14:48:36Z | [
"python",
"namespaces",
"defined",
"pyautogui"
] |
NameError: name 'VAR' is not defined | 37,705,535 | <p>I have a Python script here that is for figuring out the dimensions of a work space to then figure out where the automation script should be clicking or inputting data.</p>
<p>I am running into a problem with a variable have made in one function but isn't accessible in another. I returned the variable I'd like to c... | 0 | 2016-06-08T14:34:24Z | 37,705,885 | <p>The problem is that Python has a variable scope much like any other programming language.<br>
Meaning that depending on where you put the variable, it might only be accessible within that scope, in this case your function <code>getWorkSpace()</code> that creates it.</p>
<p>In order for everyone else to access it yo... | 0 | 2016-06-08T14:48:45Z | [
"python",
"namespaces",
"defined",
"pyautogui"
] |
sum over matrix entries in sympy 1.0 with python 3.5 | 37,705,571 | <p>I just discovered Sympy so I'm still not quite sure how to best work with it.
I have an equation </p>
<p><img src="http://i.stack.imgur.com/sa2Cj.png" alt="Image"></p>
<p>with X a 20x5 Matrix, Y a 20x1 Matrix/Vektor and beta a 5x1 Matrix/Vektor</p>
<p>However the notation I know only allows me to use the i as ... | 1 | 2016-06-08T14:35:51Z | 37,706,704 | <p>Use <code>IndexedBase</code>:</p>
<pre><code>In [1]: X = IndexedBase("X")
In [2]: Y = IndexedBase("Y")
In [4]: beta = IndexedBase("beta")
In [5]: expr = Sum(Y[i]*exp(Sum(X[i, j]*beta[j], (j, 1, 5))), (i, 1, 20))
In [7]: pprint(expr)
20
_____
\ ... | 3 | 2016-06-08T15:22:55Z | [
"python",
"matrix",
"sympy"
] |
Pydoop call not working when inside Celery task | 37,705,625 | <p>I've set up two files for a project using <a href="http://www.celeryproject.org/" rel="nofollow">Celery</a> and <a href="https://crs4.github.io/pydoop/" rel="nofollow">Pydoop</a>, <strong>tasks.py</strong> and <strong>HDFSStorage.py</strong></p>
<pre><code># tasks.py
from celery import Celery
from celery import sh... | 1 | 2016-06-08T14:37:55Z | 37,713,512 | <p>The HDFSStorage instance must be created inside the task</p>
<pre><code># tasks.py
from celery import Celery
from celery import shared_task
from celery.utils.log import get_task_logger
from HDFSStorage import HDFSStorage
app = Celery('tasks', broker='amqp://guest@localhost//')
logger = get_task_logger(__name__)
... | 1 | 2016-06-08T21:46:55Z | [
"python",
"hadoop",
"celery"
] |
Install TensorFlow-0.9.0rc0 on Ubuntu 14.04 (64bit) gets not a supported wheel on this platform | 37,705,673 | <p>While this seems to be a dupe, I cannot resolve, I have a fully current 14.04 Ubuntu and updated PIP yet I am getting, wondering if it is related to being a new release of tensorflow?:</p>
<pre><code>tensorflow-0.9.0rc0-cp27-none-linux_x86_64.whl is not a supported wheel on this platform.
</code></pre>
<p>in respo... | 0 | 2016-06-08T14:39:39Z | 37,706,408 | <p>Using Python 2 it works for me (on Ubuntu 14.04).</p>
<pre><code>sudo pip2 install https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.9.0rc0-cp27-none-linux_x86_64.whl
</code></pre>
<p>To use it with Python 3.4, use this:</p>
<pre><code>sudo pip install https://storage.googleapis.com/tensorflow/linu... | 5 | 2016-06-08T15:09:51Z | [
"python",
"pip",
"ubuntu-14.04",
"tensorflow"
] |
Installing MAYAVI in Mac OS X | 37,705,685 | <p>I installed Python 2.7 via Home brew and installed all other library packages using pip </p>
<p>To install Mayavi initially, I installed VTK using </p>
<pre><code>brew reinstall --python --qt vtk5
</code></pre>
<p>Later, I did</p>
<pre><code>pip install mayavi
</code></pre>
<p>but this gives out this error for ... | 0 | 2016-06-08T14:40:12Z | 38,011,411 | <p>The first thing is to check your environment here, via the commands</p>
<pre><code>which python
which pip
which brew
echo $PATH
brew doctor
</code></pre>
<p>Installing Python packages on OS X where there is a compilation involved can lead to various errors related to the choice of compiler and python executable. <... | 1 | 2016-06-24T10:38:50Z | [
"python",
"osx",
"fatal-error",
"mayavi"
] |
Remove duplicates from the list of dictionaries (with a unique value) | 37,705,884 | <p>I have a list of dictionaries each of them describing a file (file format, filename, filesize, ... and a full path to the file [<strong>always unique</strong>]). The goal is to <em>exclude all but one dictionaries describing copies of the same file</em> (I just want a single dict (entry) per file, no matter how many... | 2 | 2016-06-08T14:48:41Z | 37,729,353 | <p>Use another dictionary to map the dictionaries from the list <em>without</em> the "ignored" keys to the actual dictionaries. This way, only one of each kind will be retained. Of course, dicts are not hashable, so you have to use (sorted) tuples instead.</p>
<pre><code>src_list = [{'filename': 'abc', 'filetype': '.t... | 1 | 2016-06-09T14:51:30Z | [
"python",
"list",
"python-3.x",
"dictionary",
"python-2.x"
] |
Remove duplicates from the list of dictionaries (with a unique value) | 37,705,884 | <p>I have a list of dictionaries each of them describing a file (file format, filename, filesize, ... and a full path to the file [<strong>always unique</strong>]). The goal is to <em>exclude all but one dictionaries describing copies of the same file</em> (I just want a single dict (entry) per file, no matter how many... | 2 | 2016-06-08T14:48:41Z | 37,730,832 | <p>My own solution (maybe not the best, but it worked):</p>
<pre><code> dst_list = []
seen_items = set()
for dictionary in src_list:
# here we cut the unique key (path) out to add it back later after a duplicate check
path = dictionary.pop('path', None)
t = tuple(dictionary.items())
... | 0 | 2016-06-09T15:53:11Z | [
"python",
"list",
"python-3.x",
"dictionary",
"python-2.x"
] |
Custom User Model extending AbstractUser, authenticate return None | 37,705,914 | <p>I want create my custom user extending <strong>AbstractUser</strong>, but when i want authenticate my custom user return None.</p>
<p>When i create CustomUser() is stored in database but the passwowrd is not encrypted. Can i use authenticate function of banckend default? or i must create a custom backend for my cus... | 0 | 2016-06-08T14:49:41Z | 37,771,830 | <p>SOLVED!</p>
<p>The problem was not to extend AbstracUser, the problem was when i saved the user,
CustomUser(username='myusername', password='mypassword'), the password is saved like plain text and de function authenticate() doesn't work with this.</p>
<p>It's necessary save user usinng UserCreationForm, or extendi... | 0 | 2016-06-12T07:37:44Z | [
"python",
"django",
"django-authentication",
"django-users",
"django-custom-user"
] |
How can I prevent a field from displaying on a ModelForm? | 37,705,956 | <p>In a project I'm working on, I have:</p>
<pre><code>class Foo(models.Model):
bar = models.BazField()
class FooForm(forms.ModelForm):
class Meta:
exclude = ('bar')
</code></pre>
<p>The page displaying the ModelForm is displaying the field bar even though I don't want it to.</p>
<p>What, besides pl... | -1 | 2016-06-08T14:51:30Z | 37,706,084 | <p>exclude expects a tuple or list (one element in parenthesis without a comma, as you currently have it, isn't treated as a tuple). </p>
<p>Try either</p>
<pre><code>exclude = ('bar',) # with the comma so its treated as a tuple
</code></pre>
<p>or </p>
<pre><code>exclude = ['bar'] # less ambiguous
</code></pre>
| 2 | 2016-06-08T14:56:15Z | [
"python",
"django",
"django-models",
"django-forms",
"pinax"
] |
Update pandas dataframe without iterrows | 37,705,957 | <p>I have 2 dataframes such as:</p>
<pre><code> df1:
index x y
abc DF UK
cde DF FR
grt FD UK
</code></pre>
<p>and:</p>
<pre><code> df2:
index DF UK FR FD
abc nan nan nan nan
cde nan nan nan nan
grt nan nan nan nan
</code></pre>
<p>I would l... | 1 | 2016-06-08T14:51:35Z | 37,706,366 | <p>Take a look at <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.get_dummies.html" rel="nofollow"><code>pd.get_dummies</code></a>:</p>
<pre><code>pd.get_dummies(df1.set_index('index')).replace(0, np.nan)
df.columns = [c[2:] for c in df.columns]
DF FD FR UK
index ... | 0 | 2016-06-08T15:08:01Z | [
"python",
"pandas",
"dataframe",
"vectorization"
] |
Why are multiprocessing.sharedctypes assignments so slow? | 37,705,974 | <p>Here's a little bench-marking code to illustrate my question:</p>
<pre><code>import numpy as np
import multiprocessing as mp
# allocate memory
%time temp = mp.RawArray(np.ctypeslib.ctypes.c_uint16, int(1e8))
Wall time: 46.8 ms
# assign memory, very slow
%time temp[:] = np.arange(1e8, dtype = np.uint16)
Wall time: 1... | 3 | 2016-06-08T14:52:15Z | 37,708,015 | <p>On ms-windows when you create a <code>Process</code>, a new Python interpreter will be spawned which then <em>imports</em> your program as a module. (This is why on ms-windows you should only create <code>Process</code> and <code>Pool</code> from within a <code>if __name__ is "__main__"</code> block.) This will recr... | 0 | 2016-06-08T16:27:11Z | [
"python",
"multiprocessing",
"shared-memory"
] |
Why are multiprocessing.sharedctypes assignments so slow? | 37,705,974 | <p>Here's a little bench-marking code to illustrate my question:</p>
<pre><code>import numpy as np
import multiprocessing as mp
# allocate memory
%time temp = mp.RawArray(np.ctypeslib.ctypes.c_uint16, int(1e8))
Wall time: 46.8 ms
# assign memory, very slow
%time temp[:] = np.arange(1e8, dtype = np.uint16)
Wall time: 1... | 3 | 2016-06-08T14:52:15Z | 37,708,824 | <p>This is slow for the reasons given in <a href="https://stackoverflow.com/questions/33853543/demystifying-sharedctypes-performance">your second link</a>, and the solution is actually pretty simple: <strong>Bypass the (slow) <code>RawArray</code> slice assignment code</strong>, which in this case is inefficiently read... | 3 | 2016-06-08T17:10:33Z | [
"python",
"multiprocessing",
"shared-memory"
] |
matplotlib: coordinates convention of image imshow incompatible with plot | 37,706,005 | <p>I have a problem of plotting points over a image using matplotlib.pyplot. </p>
<p>As we know, the convention of imshow is that the origin is located on the top left corner, x-axis pointing downward and y-axis pointing rightward. </p>
<p>But when I use plt.plot() to plot some points, the axes seem to becomes x-axis... | 0 | 2016-06-08T14:53:20Z | 37,706,399 | <p><a href="http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.imshow" rel="nofollow"><code>plt.imshow</code></a> has an option called <code>origin</code>, which changes where the origin is placed. From the docs:</p>
<blockquote>
<p>origin : [âupperâ | âlowerâ], optional, default: None</p>
<p>P... | 2 | 2016-06-08T15:09:26Z | [
"python",
"matplotlib"
] |
standard in must be a tty Python script removing Sudo | 37,706,171 | <p>I am trying to run the command </p>
<pre><code>"sudo service awslogs start"
</code></pre>
<p>from a python script. I cannot use 'sudo' so I change the command to </p>
<pre><code>"su -c 'service awslogs start'"
</code></pre>
<p>but that does not seem to work either. I still get the error</p>
<p>su: user if=/dev... | 0 | 2016-06-08T14:59:50Z | 37,706,678 | <p><code>sudo -S</code> reads from stdin, see <code>man sudo</code>:</p>
<pre><code> -S, --stdin
Write the prompt to the standard error and read the password from the
standard input instead of using the terminal device. The password must be
followed by a newline character.
</code></pre>
<p>You can als... | 1 | 2016-06-08T15:21:55Z | [
"python",
"bash",
"amazon-web-services",
"scripting",
"sudo"
] |
Merge or Concat Dataframes using Pandas | 37,706,182 | <p>Simplified. I have 2 dataframes that I would like to merge/concatenate/join together into one using the following scenario as framework.</p>
<p>df1 looks like</p>
<pre><code> C1 C2 C3
0 1659712000.0 1659712000.0 YQHDK
1 5797862000.0 5797862000.0 YQHJW
2 846369000.... | 0 | 2016-06-08T15:00:09Z | 37,706,548 | <p>Take a look at <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.combine_first.html" rel="nofollow"><code>combine_first()</code></a>:</p>
<pre><code>df1.set_index('C3')
df2.set_index('C3')
df2.combine_first(df1)
C1 C2
C3
YQHDK 1... | 3 | 2016-06-08T15:15:39Z | [
"python",
"pandas",
"join",
"dataframe",
"merge"
] |
Python pip install options | 37,706,197 | <p><a href="https://pip.pypa.io/en/stable/reference/pip_install/#options" rel="nofollow">https://pip.pypa.io/en/stable/reference/pip_install/#options</a></p>
<p>so i have multiple python and i want to install a package to one specific python</p>
<p>for example, python lib is located in /top/python-demo-5/lib/python2.... | 0 | 2016-06-08T15:00:41Z | 37,706,291 | <p>Run the <code>pip</code> executable from that installation.</p>
<pre><code>/top/python-demo-5/lib/python2.7/Scripts/pip install <package>
</code></pre>
| 2 | 2016-06-08T15:04:55Z | [
"python",
"pip"
] |
Python AppEngine Sort Query Object Through Two Attributes | 37,706,344 | <p>I have a model </p>
<pre><code>class Neighborhood(model) {
name = db.StringProperty(required=True)
city = EncodedProperty(encoder=_get_city_name)
}
</code></pre>
<p>and I would like to retrieve all of the Neighborhood objects and sort them through both "name" and "city" attributes. Initially, I tried </p>
<pr... | 0 | 2016-06-08T15:07:10Z | 37,709,501 | <p>I think you have to fetch the entities and then sort it.</p>
<pre><code>neighborhoods = Neighborhood.all().fetch(1000)
neighborhoods = sorted(neighborhoods, key=attrgetter('city', 'name'))
</code></pre>
| 0 | 2016-06-08T17:49:33Z | [
"python",
"sorting",
"google-app-engine",
"google-cloud-datastore"
] |
Python AppEngine Sort Query Object Through Two Attributes | 37,706,344 | <p>I have a model </p>
<pre><code>class Neighborhood(model) {
name = db.StringProperty(required=True)
city = EncodedProperty(encoder=_get_city_name)
}
</code></pre>
<p>and I would like to retrieve all of the Neighborhood objects and sort them through both "name" and "city" attributes. Initially, I tried </p>
<pr... | 0 | 2016-06-08T15:07:10Z | 38,234,922 | <p>The question is tagged as gae-datastore but "EncodedProperty" isn't a datastore property type.
<a href="https://cloud.google.com/appengine/docs/python/datastore/typesandpropertyclasses" rel="nofollow">https://cloud.google.com/appengine/docs/python/datastore/typesandpropertyclasses</a></p>
<p>The model should be:</p... | 0 | 2016-07-06T22:37:39Z | [
"python",
"sorting",
"google-app-engine",
"google-cloud-datastore"
] |
Nested json to csv - generic approach | 37,706,351 | <p>I am very new to Python and I am struggling with converting nested <code>json</code> file into <code>cvs</code>. To do so I started with loading the <code>json</code> and then transformed it in a way that prints out nice output with json_normalize, then using pandas package I output the normalised parts into <code>c... | 1 | 2016-06-08T15:07:19Z | 37,706,661 | <p>use pandas (run "<em>pip install pandas</em>" in the console), 2 lines of code:</p>
<pre><code>import pandas
json = pandas.read_json('2.json')
json.to_csv('1.csv')
</code></pre>
| -1 | 2016-06-08T15:21:09Z | [
"python",
"json",
"csv",
"pandas"
] |
Nested json to csv - generic approach | 37,706,351 | <p>I am very new to Python and I am struggling with converting nested <code>json</code> file into <code>cvs</code>. To do so I started with loading the <code>json</code> and then transformed it in a way that prints out nice output with json_normalize, then using pandas package I output the normalised parts into <code>c... | 1 | 2016-06-08T15:07:19Z | 37,730,835 | <p>Thanks to the great blog post by Amir Ziai which you can find <a href="https://medium.com/@amirziai/flattening-json-objects-in-python-f5343c794b10#.y46j8vr6ghttps://medium.com/@amirziai/flattening-json-objects-in-python-f5343c794b10#.y46j8vr6g" rel="nofollow">here</a> I managed to output my data in form of a flat ta... | 0 | 2016-06-09T15:53:18Z | [
"python",
"json",
"csv",
"pandas"
] |
Design an encrypted time-limited API on Client/Server side | 37,706,365 | <p>I am planning design an encrypted time-limited API on both Client and Server sides, the server side is written in Django, the client side is a GUI program which call the API by</p>
<pre><code>import requests
c = requests.post("http://127.0.0.1:8000/VideoParser/", data={'videoUrl': videoUrl })
</code></pre>
<p>The ... | 0 | 2016-06-08T15:07:56Z | 37,706,542 | <p>I think this will address your objectives:</p>
<ol>
<li>Create an <strong>access key</strong> and a <strong>secret key</strong> for each user who is allowed to make requests.</li>
<li>Give one copy of each key to the user and keep one copy of each key on the server.</li>
<li>Add the following two parameters to each... | 0 | 2016-06-08T15:15:20Z | [
"python",
"django",
"api",
"python-3.x",
"encryption"
] |
How to display the actual number of each word being vectored | 37,706,396 | <p>I'm working through a tutorial book on Scikit-learn, and one of the sections has this block of code:</p>
<pre><code>from sklearn.feature_extraction.text import CountVectorizer
corpus = ['The dog ate a sandwich, the wizard transfigured a sandwich, and I ate a sandwich']
vectorizer = CountVectorizer(stop_words='engli... | 1 | 2016-06-08T15:09:14Z | 37,723,376 | <p>You would access the <code>.vocabulary_</code> property after the model is fitted:</p>
<pre><code>>>> vectorizer.vocabulary_
{'ate': 0, 'dog': 1, 'sandwich': 2, 'transfigured': 3, 'wizard': 4}
</code></pre>
| 1 | 2016-06-09T10:27:47Z | [
"python",
"python-3.x",
"vector",
"scikit-learn"
] |
Django 1.9 cannot pass context variable to template using {{}} | 37,706,421 | <p>I don't know why I cannot use context to pass my template, I checked online, I have to use context processor and also set context processor in my <code>settings.py</code>, why can I not use this to pass the context from <code>view.py</code> to template. I use django 1.9</p>
<p>In <code>view.py</code>:</p>
<pre><co... | 0 | 2016-06-08T15:10:23Z | 37,706,459 | <p>If your model is</p>
<pre><code>class Product(models.Model):
product=models.CharField(max_length=200)
companyname=models.ForeignKey(Company)
description=models.TextField()
price=models.DecimalField(decimal_places=2,max_digits=10)
stock=models.IntegerField(default=0)
</code></pre>
<p>Then you ... | 2 | 2016-06-08T15:12:02Z | [
"python",
"django"
] |
time.time() values jumping | 37,706,457 | <p><strong><em>Issue:</em></strong>
When calling the function <em>time.time()</em> I notice it jumping about 30 seconds after reboot. By jumping I mean it <em>changes its return value</em> by about 40 seconds instantly.</p>
<p><strong><em>Setup:</em></strong>
I am running my script on a <em>Raspberry Pi 3B</em>, immea... | 0 | 2016-06-08T15:11:59Z | 37,706,564 | <p>Check wheather it ajusts clock from external source like NPT. </p>
| 0 | 2016-06-08T15:16:25Z | [
"python",
"time",
"raspberry-pi",
"clock"
] |
time.time() values jumping | 37,706,457 | <p><strong><em>Issue:</em></strong>
When calling the function <em>time.time()</em> I notice it jumping about 30 seconds after reboot. By jumping I mean it <em>changes its return value</em> by about 40 seconds instantly.</p>
<p><strong><em>Setup:</em></strong>
I am running my script on a <em>Raspberry Pi 3B</em>, immea... | 0 | 2016-06-08T15:11:59Z | 37,706,721 | <p>Many operating systems update their clock on boot. <a href="https://docs.python.org/3/library/time.html#time.time" rel="nofollow"><code>time.time()</code></a> returns the time since Epoch, so if the clock changes, the delta between now and Epoch changes too.</p>
<p>You may want to use monotonic timer if you want to... | 2 | 2016-06-08T15:23:34Z | [
"python",
"time",
"raspberry-pi",
"clock"
] |
time.time() values jumping | 37,706,457 | <p><strong><em>Issue:</em></strong>
When calling the function <em>time.time()</em> I notice it jumping about 30 seconds after reboot. By jumping I mean it <em>changes its return value</em> by about 40 seconds instantly.</p>
<p><strong><em>Setup:</em></strong>
I am running my script on a <em>Raspberry Pi 3B</em>, immea... | 0 | 2016-06-08T15:11:59Z | 37,706,757 | <p>This is most likely because the Raspberry Pi does not have a real time clock. I would instead recommend that you use monotonic. This should provide you with consistent output, regardless if the system clock changes.</p>
<p>The library I usually use is available <a href="https://github.com/atdt/monotonic" rel="nofol... | 2 | 2016-06-08T15:25:16Z | [
"python",
"time",
"raspberry-pi",
"clock"
] |
Color-mapping a 3D quiver function using matplotlib | 37,706,467 | <p>I have created a lovely 3D displacement vector field in python using Matplotlib and I am happy with the results. However, visually it is not very east to see the magnitude of the displacements only the direction. Is there a way in python that I could use a colour scale for the arrows so that the magnitude of the dis... | 1 | 2016-06-08T15:12:14Z | 37,713,023 | <p>You have to calculate wind speed (or another array which you use as magnitude) then add this array to quiver function:</p>
<pre><code>import matplotlib as mpl
import matplotlib.pyplot as plt
from numpy import arange,meshgrid,sqrt
u,v = arange(-50,51,10),arange(-50,51,10)
u,v = meshgrid(u,v)
M = sqrt(u*u+v*v) # ma... | 1 | 2016-06-08T21:13:34Z | [
"python",
"vector",
"matplotlib",
"3d",
"color-mapping"
] |
Android app crashes after loading trained tensorflow protobuf model | 37,706,476 | <p>I am trying to load a model that I trained myself on the tensorflow android app. I trained the model in Caffe and then converted it to Tensorflow, but I am sure that this is not the problem because I tested it using classify.py and it works. </p>
<p>I then serialize the model and put it in a .pb, I replace the tens... | 1 | 2016-06-08T15:12:46Z | 37,757,925 | <p>Unfortunately you're hitting a limitation of the mobile build target for TensorFlow. By default, we only include the operations that are typically needed for inference, which doesn't include FIFOQueue.</p>
<p>Assuming that you don't actually need to run that op during your inference pass on mobile, you can look at ... | 0 | 2016-06-10T22:22:19Z | [
"android",
"python",
"c++",
"protocol-buffers",
"tensorflow"
] |
Why is list multiplication so fast? | 37,706,477 | <p>When creating a list, I thought comprehension is recommended whenever possible as it is fastest. But lo and behold.</p>
<pre><code>In [1]: %timeit -n1000 [0]*1000000
1000 loops, best of 3: 2.3 ms per loop
In [2]: %timeit -n1000 [0 for _ in range(1000000)]
1000 loops, best of 3: 27.1 ms per loop
In [3]: a = np.zer... | 1 | 2016-06-08T15:12:51Z | 37,706,654 | <p>In the first case, python can create a list with all the zeroes referring to the same <code>id</code>. This works great since primitives are <em>literal</em>, but it wouldn't work as expected if you're passing an object. In that case, every element would actually be a reference to the same object.</p>
<p>In the <co... | 0 | 2016-06-08T15:20:45Z | [
"python",
"performance",
"python-3.x"
] |
Why is list multiplication so fast? | 37,706,477 | <p>When creating a list, I thought comprehension is recommended whenever possible as it is fastest. But lo and behold.</p>
<pre><code>In [1]: %timeit -n1000 [0]*1000000
1000 loops, best of 3: 2.3 ms per loop
In [2]: %timeit -n1000 [0 for _ in range(1000000)]
1000 loops, best of 3: 27.1 ms per loop
In [3]: a = np.zer... | 1 | 2016-06-08T15:12:51Z | 37,706,969 | <p>The <a href="https://docs.python.org/2/library/dis.html#dis.dis" rel="nofollow"><code>dis</code></a> module is useful for comparing the first two methods.</p>
<pre><code>def list_mult():
return [0]*1000000
dis.dis(list_mult)
# 2 0 LOAD_CONST 1 (0)
# 3 BUILD_LIST ... | 3 | 2016-06-08T15:35:14Z | [
"python",
"performance",
"python-3.x"
] |
Satisfiability of a formula having forall quantifier | 37,706,521 | <p>This is my Python code:</p>
<pre><code>s = z3.Solver()
f = z3.Function('f', z3.IntSort(), z3.IntSort())
g = z3.Function('g', z3.IntSort(), z3.IntSort())
h = z3.Function('h', z3.IntSort(), z3.IntSort())
a, b, c = z3.Ints('a b c')
imp_a = z3.And(f(a) == b, g(a) == c)
imp_b = h(c) == b
ax = z3.ForAll(a, z3.Implies(... | 0 | 2016-06-08T15:14:22Z | 37,707,035 | <p>You forgot to bind <code>b</code> and <code>c</code>:</p>
<pre><code>ax = z3.ForAll([a,b,c], z3.Implies(imp_a, imp_b))
</code></pre>
<p>After binding <code>b</code>, <code>c</code>, then the result is <code>unsat</code>. If you don't bind <code>b</code>,<code>c</code>, then they are treated as free constants and t... | 2 | 2016-06-08T15:37:58Z | [
"python",
"z3",
"smt",
"z3py",
"first-order-logic"
] |
Median of a List in Python | 37,706,539 | <p>i've looked up similar posts to these and the examples people have posted are throwing the same error at me just as my own version is. I keep getting the error "list indices must be integers, not float." I believe my logic behind getting the median is fine but I can't figure out how to get around this. I understand ... | 0 | 2016-06-08T15:15:13Z | 37,706,624 | <p>Use <a href="https://docs.python.org/2/library/math.html#math.floor" rel="nofollow"><code>math.floor</code></a>,</p>
<pre><code>import math
l = sorted([1,8,10,11,5])
m = l[int(math.floor(len(myList)/2))] # 8
</code></pre>
<p>As mentioned by <strong>@schwobaseggl</strong>, just use <code>l[len(l)//2]</code>.... | 1 | 2016-06-08T15:19:31Z | [
"python",
"list"
] |
Median of a List in Python | 37,706,539 | <p>i've looked up similar posts to these and the examples people have posted are throwing the same error at me just as my own version is. I keep getting the error "list indices must be integers, not float." I believe my logic behind getting the median is fine but I can't figure out how to get around this. I understand ... | 0 | 2016-06-08T15:15:13Z | 37,706,702 | <p>Exception is caused by <code>/</code> operator that returns <code>float</code> on Python 3.x. Use integer division <code>//</code> instead when calculating the index:</p>
<pre><code>>>> 2 / 1
2.0
>>> 2 // 1
2
</code></pre>
| 4 | 2016-06-08T15:22:54Z | [
"python",
"list"
] |
Median of a List in Python | 37,706,539 | <p>i've looked up similar posts to these and the examples people have posted are throwing the same error at me just as my own version is. I keep getting the error "list indices must be integers, not float." I believe my logic behind getting the median is fine but I can't figure out how to get around this. I understand ... | 0 | 2016-06-08T15:15:13Z | 37,706,737 | <p>A better way to do in python version 3 is with module statistics</p>
<pre><code>import statistics
items = [1, 2, 3, 6, 8]
statistics.median(items)
</code></pre>
<p>If you want a function, try this.</p>
<pre><code>def median(lst):
quotient, remainder = divmod(len(lst), 2)
if remainder:
return sor... | 3 | 2016-06-08T15:24:27Z | [
"python",
"list"
] |
Median of a List in Python | 37,706,539 | <p>i've looked up similar posts to these and the examples people have posted are throwing the same error at me just as my own version is. I keep getting the error "list indices must be integers, not float." I believe my logic behind getting the median is fine but I can't figure out how to get around this. I understand ... | 0 | 2016-06-08T15:15:13Z | 37,706,788 | <p>There are some other answers about fixing the float problem. However to answer your question about even length lists, from Google:</p>
<blockquote>
<p>The median is also the number that is halfway into the set. To find the median, the data should be arranged in order from least to greatest. If there is an even nu... | 2 | 2016-06-08T15:26:35Z | [
"python",
"list"
] |
Median of a List in Python | 37,706,539 | <p>i've looked up similar posts to these and the examples people have posted are throwing the same error at me just as my own version is. I keep getting the error "list indices must be integers, not float." I believe my logic behind getting the median is fine but I can't figure out how to get around this. I understand ... | 0 | 2016-06-08T15:15:13Z | 37,706,944 | <p>Of the top of my head, this seems like valid approach, avoiding modulo altogether:</p>
<pre><code>def median(lst):
lst.sort()
half = len(lst)//2 # integer division
b = lst[half]
c = lst[-half-1] # for odd lengths, b == c
return (b + c) / 2
> median([1,8,10,11,5])
8.0
> median([10,5,7,2,... | 0 | 2016-06-08T15:33:49Z | [
"python",
"list"
] |
python linear regression date as axis | 37,706,623 | <p>i'm getting data from mysql and using panda DataFrame i'm separating the data to column </p>
<pre><code>data = pd.DataFrame(data)
print(data.ix[:,3])
0 2006-04-01
1 2006-08-01
2 2006-12-01
3 2006-02-01
4 2006-01-01
5 2006-07-01
6 2006-06-01
7 2006-03-01
8 2006-05-01
9 2006-1... | 1 | 2016-06-08T15:19:29Z | 37,707,581 | <p>you can convert the dates into ordinals by:</p>
<pre><code>data.loc[:, 3].apply(lambda x: x.toordinal())
</code></pre>
<p>assuming this column is of type <code>dtype('<M8[ns]')</code></p>
<p>It would look like:</p>
<pre><code>2006-04-01 732402
2006-08-01 732524
2006-12-01 732646
2006-02-01 732343
... | 1 | 2016-06-08T16:05:10Z | [
"python",
"pandas",
"linear-regression"
] |
re.sub python to gather height | 37,706,783 | <p>I am writing a python program to parse some user data from a txt file.
One of the rows in the text file will contain the user's height.
I have specified an order that the user is expected to follow like</p>
<p>First line of the file should contain name, the next line, date of birth,
3rd line, height etc.</p>
<p... | 3 | 2016-06-08T15:26:24Z | 37,712,427 | <p>pyparsing is a nice module for simple parsing situations like this, especially when trying to process less-than-predictable-but-still-fairly-structured human input. You can compose your parser using some friendly-named classes (<code>Keyword</code>, <code>Optional</code>, <code>OneOrMore</code>, and so on) and arith... | 4 | 2016-06-08T20:36:10Z | [
"python",
"regex",
"string",
"parsing"
] |
re.sub python to gather height | 37,706,783 | <p>I am writing a python program to parse some user data from a txt file.
One of the rows in the text file will contain the user's height.
I have specified an order that the user is expected to follow like</p>
<p>First line of the file should contain name, the next line, date of birth,
3rd line, height etc.</p>
<p... | 3 | 2016-06-08T15:26:24Z | 37,712,707 | <p>In JavaScript (one of the few computational languages that I'm familiar with), there is an operation called "computed access" where the Object property read is determined through the result of a given expression, as an alternative to the normal dot operator. Personally, I mostly use it for iteration and reading prop... | 1 | 2016-06-08T20:52:50Z | [
"python",
"regex",
"string",
"parsing"
] |
How to the find the longest match from a set of lists in Python? | 37,706,839 | <p>If I have a list like this </p>
<pre><code>my_list = [1, 7, 3, 4, 2, 9, 6, 5, 8]
</code></pre>
<p>Also I have other lists of length less than the length of <code>my_list</code>. For instance, let us say I have two other lists as follows:</p>
<pre><code>my_other_list_1 = [1, 7, 3, 4, 2]
my_other_list_2 = [1, 7, 4,... | 0 | 2016-06-08T15:28:35Z | 37,707,364 | <pre><code>def longest_match(main_list, *other_lists, **options):
try:
if options:
ordered = options['ordered']
else:
raise Exception
except:
ordered = False
best_match = 0
longest_match = 0
for index, list in enumerate(other_lists):
current_m... | 1 | 2016-06-08T15:54:48Z | [
"python",
"algorithm"
] |
How to the find the longest match from a set of lists in Python? | 37,706,839 | <p>If I have a list like this </p>
<pre><code>my_list = [1, 7, 3, 4, 2, 9, 6, 5, 8]
</code></pre>
<p>Also I have other lists of length less than the length of <code>my_list</code>. For instance, let us say I have two other lists as follows:</p>
<pre><code>my_other_list_1 = [1, 7, 3, 4, 2]
my_other_list_2 = [1, 7, 4,... | 0 | 2016-06-08T15:28:35Z | 37,707,929 | <p>I'd be more than happy to help bud!
Here you go!</p>
<pre><code>def matcher_algorithm_large(original_list, **kwargs):
match_dict = {}
for i in kwargs:
counter=0
for j in kwargs[i]:
if j == original_list[kwargs[i].index(j)]:
counter += 1
else:
break
match_dict[i]=c... | 1 | 2016-06-08T16:23:13Z | [
"python",
"algorithm"
] |
Python : Unable to compare two directories | 37,706,855 | <p>I have two directories (below) that I am trying to compare</p>
<p>Left:</p>
<pre><code>C:\Temp\Sync\GUI\config.xml
C:\Temp\Sync\GUI\jobs
C:\Temp\Sync\GUI\jobs\Add
C:\Temp\Sync\GUI\jobs\Add\builds
C:\Temp\Sync\GUI\jobs\Add\config.xml
C:\Temp\Sync\GUI\jobs\Add\builds\legacyIds
C:\Temp\Sync\Risk\jobs\TOP_Deriv_RiskAl... | 0 | 2016-06-08T15:29:47Z | 37,711,555 | <p>According to the <a href="https://docs.python.org/2/library/filecmp.html" rel="nofollow">docs</a>, dircmp will only recurse into common directories, and only if you tell it to.</p>
<p>If a subdirectory only exists on one side, then the same holds true for its contents.</p>
<p>It may be possible to build a utility ... | 1 | 2016-06-08T19:44:23Z | [
"python",
"python-2.7",
"diff"
] |
Not all arguments converted | 37,706,912 | <p>In Python, I am getting <strong>'TypeError: not all arguments converted during string formatting'</strong></p>
<p>I am not sure why this is happening. This line is being highlighted as where the problem lies - <code>data.append('%s,%s,%s'%line['code'],line['level'],line['target'],line['distancefromtarget']</code></... | 0 | 2016-06-08T15:32:30Z | 37,706,976 | <p>You've got a tuple with 4 elements:</p>
<pre><code>(line['code'],line['level'],line['target'],line['distancefromtarget'])
</code></pre>
<p>But only 3 substitution placeholders:</p>
<pre><code>'%s,%s,%s'
</code></pre>
<p>When you try to format that, not all of the "arguments" (tuple elements) will be converted to... | 3 | 2016-06-08T15:35:24Z | [
"python"
] |
astroquery: vizier.query_region over a large area failing | 37,706,925 | <p>I try to make relatively large queries on the 2MASS catalogue with astroquery.vizier.query_region().
While it works for small areas, it fails for large area.
Here is the code I use:</p>
<pre><code>twomass_query=Vizier(columns=["Jmag","Hmag","Kmag","e_Jmag","e_Hmag","e_Kmag","Qflg"],
catalog=["II/24... | 0 | 2016-06-08T15:33:10Z | 37,727,822 | <p>I am now almost sure it is a bug of the VizieR server. I cannot execute the request on the Vizier webpage, it also returns an error or an empty table. The problem seems to be the requested output format (return_type='asu-binfits'). If I request a Votable then it works on the Vizier webpage, and with astroquery as we... | 1 | 2016-06-09T13:47:34Z | [
"python",
"astropy"
] |
Django: Attach custom field options for specifying external representation | 37,706,947 | <p>I would like to add some custom field option to fields of Django models, since I'm building an application that will be used with models that only follow a general scheme. The idea is that the app should still work with newly defined models and that all the configuration should happen directly in <code>models.py</co... | 0 | 2016-06-08T15:34:07Z | 37,731,772 | <p>Irrespective of whether the approach is right here is my solution for attaching custom keyword arguments to all Django <code>Field</code> classes. The custom options can be specified in a <code>dict</code> with variable names as <code>keys</code> defaults as <code>values</code>.</p>
<pre><code>from django.db.models... | 0 | 2016-06-09T16:41:59Z | [
"python",
"django",
"django-models"
] |
Delete Multiple Specified Folders (+Contents) in Python | 37,706,992 | <p>i'm trying to learn Phython so I dont know a lot of this coding language yet ;)</p>
<p>I'm trying to delete some pre-specified folders (including it's content) with a python script, I know how to remove ONE folder like this:</p>
<pre><code>def purgeOld():
import os,xbmc,shutil
xvbmc = os.listdir(xbmc.trans... | 0 | 2016-06-08T15:36:14Z | 37,966,320 | <p>1st try/test, changed it into:</p>
<pre><code>def purgeOld():
XvbmcEntries = setupXvbmcEntries()
for entry in XvbmcEntries:
xvbmcaddons = xbmc.translatePath(entry.path)
if os.path.exists(xvbmcaddons)==True:
for root, dirs, files in os.walk(xvbmcaddons):
file... | 0 | 2016-06-22T11:11:11Z | [
"python",
"delete-file",
"folders",
"multiple-files",
"shutil"
] |
Delete Multiple Specified Folders (+Contents) in Python | 37,706,992 | <p>i'm trying to learn Phython so I dont know a lot of this coding language yet ;)</p>
<p>I'm trying to delete some pre-specified folders (including it's content) with a python script, I know how to remove ONE folder like this:</p>
<pre><code>def purgeOld():
import os,xbmc,shutil
xvbmc = os.listdir(xbmc.trans... | 0 | 2016-06-08T15:36:14Z | 38,120,191 | <p>2nd try/test,
and still in need of double removal (1st run leaves empty directories somehow)...</p>
<pre><code>def purgeOLD():
XvbmcEntries = setupXvbmcEntries()
for entry in XvbmcEntries:
xvbmcaddons = xbmc.translatePath(entry.path)
if os.path.exists(xvbmcaddons)==True:
f... | 0 | 2016-06-30T10:15:42Z | [
"python",
"delete-file",
"folders",
"multiple-files",
"shutil"
] |
Pandas error when trying to use get_loc | 37,707,011 | <p>I've been working on a program to do some parsing on a CSV and have Anaconda2 installed with the latest pandas package updated through pip. But for some reason, no matter how simple the program, I get an error trying to use get_loc.</p>
<pre><code>import sys
import pandas as pd
infile = pd.read_csv("Path/to/CSV")
... | 1 | 2016-06-08T15:37:07Z | 37,707,059 | <p>I think you need add <code>columns</code>, because <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.Index.get_loc.html" rel="nofollow"><code>Index.get_loc</code></a>. Last select desired columns by <a href="http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.iloc.html" rel="no... | 1 | 2016-06-08T15:39:09Z | [
"python",
"csv",
"pandas",
"dataframe"
] |
Mongo query in python if I use variable as value | 37,707,033 | <p>Am trying to find documents from the mongo collection using the following query. <code>db.collection_name.find({"id" : Id})</code> where Id is the variable am getting as input. But it doesn't work. If I hard code the value like this <code>db.collection_name.find({"id" : "1a2b"})</code> it works. "id" is of string ty... | 0 | 2016-06-08T15:37:50Z | 37,707,412 | <p>Try str();</p>
<pre><code>Id = str(raw_input("enter id"))
cursor = db.collection_name.find({"id" : Id})
</code></pre>
| 1 | 2016-06-08T15:57:13Z | [
"python",
"mongodb",
"pymongo",
"pymongo-3.x",
"pymongo-2.x"
] |
Mongo query in python if I use variable as value | 37,707,033 | <p>Am trying to find documents from the mongo collection using the following query. <code>db.collection_name.find({"id" : Id})</code> where Id is the variable am getting as input. But it doesn't work. If I hard code the value like this <code>db.collection_name.find({"id" : "1a2b"})</code> it works. "id" is of string ty... | 0 | 2016-06-08T15:37:50Z | 38,053,597 | <p>This may help you..in python3 it is working..</p>
<pre><code>Id = raw_input("enter id: ")
cursor = db.collection_name.find({"id" : Id})
for i in cursor:
print(i)
</code></pre>
<p>there is no require to convert raw_input() to string,Because raw_input() is already get input from user as string..</p>
| 0 | 2016-06-27T12:08:11Z | [
"python",
"mongodb",
"pymongo",
"pymongo-3.x",
"pymongo-2.x"
] |
Python - Project Euler #80, understanding the error | 37,707,042 | <p>Project Euler problem #80 seems straightforward:</p>
<p><a href="https://projecteuler.net/problem=80" rel="nofollow">https://projecteuler.net/problem=80</a></p>
<p>Using the decimal module to calculate the square root to a given precision:</p>
<pre><code>from decimal import Decimal, localcontext
def prob80():
... | 0 | 2016-06-08T15:38:07Z | 37,707,540 | <p><a href="http://blog.dreamshire.com/project-euler-80-solution/" rel="nofollow">http://blog.dreamshire.com/project-euler-80-solution/</a></p>
<blockquote>
<p>First, the 100 digits include digits to the right and left of the decimal.</p>
<p>Second, make sure to calculate more digits than are necessary to avoid... | 2 | 2016-06-08T16:03:05Z | [
"python",
"decimal",
"rounding",
"precision",
"square"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.