Data dodania Pytanie
2017-03-18 23:03 celery not getting tasks from Django Admin Periodic Tasks »
Using celery 3.1.25 with Django 1.10 I can get celery to run tasks by manually getting into the shell and manually launching the tasks. However when ...
(0) odpowiedzi
2017-03-18 21:03 Storing names and grades in python »
I'm writing a program for A teacher. The teacher is suppose to ask the name of the student and then the grade of the student. And this for as many tha...
(2) odpowiedzi
2017-03-18 14:03 Python functions with multiple parameter brackets »
I've been having trouble understanding what h(a)(b) means. I'd never seen one of those before yesterday, and I couldn't declare a function this way: ...
(3) odpowiedzi
2017-03-18 08:03 Speed up NumPy loop on 2D arrays - removes rows that are similar »
I am trying to significantly speed up the following code but to no avail. The code takes in a 2D array and removes rows of the array that, when compar...
(3) odpowiedzi
2017-03-18 04:03 'UpdateView' object has no attribute 'object' »
So I've been trying to add a cancel button to my UpdateView that I've been using. Here's my code for it: views.py: class CountryEditView(generic.edi...
(1) odpowiedzi
2017-03-18 03:03 Fastest way to check whether a value exists more often than X in a list »
I have a long list (300 000 elements) and I want to check that each element in that list exists more than 5 times. So the simplest code is [x for x ...
(4) odpowiedzi
2017-03-18 02:03 Numpy version of "Exponential weighted moving average", equivalent to pandas.ewm().mean() »
How to get the exponential weighted moving average in numpy just like in pandas: import pandas as pd import pandas_datareader as pdr from datetim...
(4) odpowiedzi
2017-03-17 22:03 Does this truely generate a random foating point number? (Python) »
For an introduction to Python course, I'm looking at generating a random floating point number in Python, and I have seen a standard recommended code ...
(3) odpowiedzi
2017-03-17 21:03 Filter a pandas data frame by requiring presence of multiple items in a MultiIndex level »
I have a table of data with a multi-index. The first level of the multi-index is a name corresponding to a given sequence (DNA), the second level of t...
(2) odpowiedzi
2017-03-17 17:03 Numpy reductions over successive non-contiguous slices »
Say I have two numpy arrays, A of shape (d, f) and I of shape (d,) containing indices in 0..n, e.g. I = np.array([0, 0, 1, 0, 2, 1]) A = np.arange(12...
(3) odpowiedzi
2017-03-17 01:03 How to handle 2 versions of Python on same client? »
I use ArcGIS 10.3 at work and it comes with Python 2.7.8; so when I run any of the .py/.pyc/.pyw files, it defaults to the path leading that versions ...
(1) odpowiedzi
2017-03-16 17:03 Unable to capture result of ls -la with subprocess.Popen »
I am trying to capture the output when I execute a custom command using Popen: import subprocess def exec_command(): command = "ls -la" # will b...
(1) odpowiedzi
2017-03-16 11:03 How to split a numpy array in fixed size chunks with and without overlap? »
Lets say I have an array: >>> arr = np.array(range(9)).reshape(3, 3) >>> arr array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])...
(1) odpowiedzi
2017-03-16 09:03 Django cannot delete single object after rewriting model.Manager method »
I am trying to rewrite get_by_natural_key method on django manager (models.Manager). After adding model (NexchangeModel) I can delete all() objects bu...
(2) odpowiedzi
2017-03-16 05:03 Wow does six.with_metaclass() work? »
Hi Stackoverflow community I have been trying to understand how Django (and Wagtail's Stream-field) work under the hood. Doing that I learned about m...
(1) odpowiedzi
2017-03-16 00:03 How to exploit permutational symmetry in this loop? »
I have a scalar function f(a,b,c,d) that has the following permutational symmetry f(a,b,c,d) = f(c,d,a,b) = -f(b,a,d,c) = -f(d,c,b,a) I'm using it t...
(1) odpowiedzi
2017-03-16 00:03 Closing a file without knowing its handle »
I have a function (which I can't modify) that tries to open a file but throws an exception in the process (blackbox in my MWE, a function imported fro...
(0) odpowiedzi
2017-03-15 22:03 multiply every element in numpy.array a with every element in numpy.array b »
Given two numpy.arrays a and b, c = numpy.outer(a, b) returns an two-dimensional array where c[i, j] == a[i] * b[j]. Now, imagine a having k dimens...
(5) odpowiedzi
2017-03-15 22:03 Read transactions in Orange »
I want to use the Orang for association Rules here is my code: import Orange data = Orange.data.Table("trans.csv") rules = Orange.associate.Associ...
(0) odpowiedzi
2017-03-15 21:03 In Django how to pass JSON data to use for Ajax / jQuery? »
I'm trying to use JSON data in Django to provide user option to search and select. I can load and extend data to html but not sure how to use it in jQ...
(3) odpowiedzi
2017-03-15 19:03 get the i-th slice of the k-th dimension in a numpy array »
I have an n-dimensional numpy array, and I'd like to get the i-th slice of the k-th dimension. There must be something better than # ... elif k ==...
(5) odpowiedzi
2017-03-15 18:03 Python is slow when iterating over a cursor »
I have the following code that runs very slowly (6.5sec for iterating over 57,390 rows) : import mysql.connector cnx=mysql.connector.connect(host=*...
(0) odpowiedzi
2017-03-15 18:03 Counting occurrences of a foreign key in a related queryset »
I have a model Visit, which has a ForeignKey to a model Store. I have a filtered queryset of Visits, and I need to get the count of how many Stores oc...
(1) odpowiedzi
2017-03-15 17:03 FieldError: Cannot resolve 'publish_year' into field »
I am new to Django and I am currently using django by example by I am getting this error FieldError: Cannot resolve 'publish_year' into field Here is...
(1) odpowiedzi
2017-03-15 10:03 Generator Comprehension different output from list comprehension? »
I get different output when using a list comprehension versus a generator comprehension. Is this expected behavior or a bug? Consider the following s...
(4) odpowiedzi
2017-03-14 23:03 Is this Pythonic? Assigning class methods dynamically »
Depending on the input to a class, different methods need to be used under a common interface (called method here). Which of these is more Pythonic? ...
(1) odpowiedzi
2017-03-14 22:03 Filter list of objects by self.request.user in Django »
I cannot get this to work: class MyView(generic.ListView): context_object_name = 'my-model-list' template_name = 'my_models.html' def ge...
(2) odpowiedzi
2017-03-14 19:03 How to optimize a sklearn pipeline, using XGboost, for a different `eval_metric`? »
I'm trying to use XGBoost, and optimize the eval_metric as auc(as described here). This works fine when using the classifier directly, but fails whe...
(1) odpowiedzi
2017-03-14 17:03 use django's reverse function in req.path »
I was stumbling on invitation feature to understand how it works. I found the blog post on http://www.pythondiary.com/tutorials/create-invite-only-web...
(1) odpowiedzi
2017-03-14 16:03 How to apply a ScikitLearn classifier to tiles/windows in a large image »
Given is a trained classifer in scikit learn, e.g. a RandomForestClassifier. The classifier has been trained on samples of size e.g. 25x25. How can I...
(1) odpowiedzi
2017-03-14 14:03 Use Pool with apply_async or map_async? »
first time poster, please be patient with me. I'm using Python 2.7.12 and I want to use the multiprocessing module to speed up my code. My program g...
(0) odpowiedzi
2017-03-14 08:03 Is there any way to make a "for" loop in python double my index value after each iteration? »
In C++, I can easily write a for loop like below that achieves this purpose for(int i = 1; i < 100; i *= 2){} Is there any way to make a for lo...
(6) odpowiedzi
2017-03-13 21:03 Upload Image File to server »
Have a little problem with uploar file image to server That is JS code for ajax send file to server /** * * Init Crope Image * *...
(1) odpowiedzi
2017-03-13 20:03 Django sort records by calculated field »
I have a model: class Person(models.Model): score1 = models.FloatField(default=0) score2 = models.FloatField(default=0) score3 = models.F...
(1) odpowiedzi
2017-03-13 16:03 Change environment variables before importlib.reload »
I have a c-extension that loads environment variables during static initialization. I need to be able to change these values and reload the module (I...
(2) odpowiedzi