Data dodania Pytanie
2017-02-13 11:02 Order of operations in a dictionary comprehension »
I came across the following interesting construct: assuming you have a list of lists as follows: my_list = [['captain1', 'foo1', 'bar1', 'foobar1'],...
(4) odpowiedzi
2017-02-12 22:02 Impossible-to-find bug in a program that equalizes wealth in a group (UVA 10137, "The Trip") »
I wrote a solution for this competitive programming problem. It passed all the test cases, except it was off by one for the last case, and I can't fig...
(1) odpowiedzi
2017-02-12 19:02 Increasing performance of Python function using Cython »
Aim I'm trying to speed up my Python program with Cython. The code I'm writing is an attempt at the Forward algorithm, used to recursively and effici...
(1) odpowiedzi
2017-02-12 18:02 What does "three dots" in Python mean when indexing what looks like a number? »
What is the meaning of x[...] below? a = np.arange(6).reshape(2,3) for x in np.nditer(a, op_flags=['readwrite']): x[...] = 2 * x ...
(1) odpowiedzi
2017-02-12 16:02 Bootstrap form showing error messages in a different style »
I have two forms in my django app, and I'm using bootstrap3 to custom them, But the error messages to the form aren't equal. It all is in portuguese ...
(2) odpowiedzi
2017-02-12 15:02 How to append a new list to an existing CSV file? »
I already have a CSV file created from a list using CSV writer. I want to append another list created through a for loop columnwise to a CSV file. Th...
(2) odpowiedzi
2017-02-12 09:02 Django: move all previously uploaded media files to new location and rename »
So, I'm using Django (1.10) and I've got a few hundred uploaded (media) files. I want to move and rename all the files, because I want to slightly cha...
(1) odpowiedzi
2017-02-12 08:02 python class calls itself in __init__ using super »
i have a code like this: class sampleClass(object): def __init__(self): super(sampleClass, self).__init__() my question is that why it ...
(1) odpowiedzi
2017-02-12 06:02 When to use return (yield something)? »
For a long time I didn't know you can't put return in front of a yield statement. But actually you can: def gen(): return (yield 42) which is s...
(0) odpowiedzi
2017-02-12 00:02 Is creating an accounts app in Django a good practice? »
I am wondering if creating an accounts app in Django is a good practice. Say you have a Django project named mysite and you create inside two apps: c...
(1) odpowiedzi
2017-02-11 22:02 python function with a pass in it »
in many codes, i see classes with functions in them that they just used pass phrase with some comment upon them. like this native builtin function fro...
(2) odpowiedzi
2017-02-11 14:02 Advanced input in python »
I want to receive some information from a user in a next way: My score is of 10 - is already printed Between 'is' and 'of' there is an empty plac...
(2) odpowiedzi
2017-02-11 14:02 Doesn't work django-admin.py startproject mysite »
I want start a new django project, I use windows 10. If I write to console python -c "import django; print(django.get_version())" return 1.10.3 ...
(1) odpowiedzi
2017-02-11 05:02 Replace value in any column in pandas dataframe »
In the dataframe below: T2MN T2MX RH2M DFP2M RAIN 6.96 9.32 84.27 5.57 - 6.31 10.46 - 5.63 - - 10.66 79.38 3.63 ...
(4) odpowiedzi
2017-02-11 03:02 Concurrent futures submit task to process pool non-blockingly »
This question is Python 2-specific, using the community maintained backport of concurrent.futures. I'm trying to use a ProcessPoolExecutor (with maxW...
(0) odpowiedzi
2017-02-11 00:02 Does numpy provide a generalized inner product? »
Most array-oriented languages such as APL or J have some form of generalized inner product, which can act like standard matrix multiplication, but sup...
(2) odpowiedzi
2017-02-11 00:02 Django excel save_book_to_database() broken in latest version using Django 1.8 »
I've been going through the django excel documentation using Django 1.8, but haven't been able to get save_book_to_database(...) to work. It either ...
(0) odpowiedzi
2017-02-10 21:02 Does Python have an equivalent to Haskell's 'mask' or 'bracket' functions? »
In Haskell we have asynchronous exceptions; we can use throwTo to raise any exception in another thread: throwTo :: Exception e => ThreadId ->...
(1) odpowiedzi
2017-02-10 21:02 Given two strings, what is the fastest way to remove all positions at which they both match a given character? »
This is a speed question. I have two strings x and y of the same length. At certain positions (indices) they may have the same character (e.g., "A")....
(0) odpowiedzi
2017-02-10 15:02 How to interleave numpy.ndarrays? »
I am currently looking for method in which i can interleave 2 numpy.ndarray. such that >>> a = np.random.rand(5,5) >>> print a [[ ...
(2) odpowiedzi
2017-02-10 15:02 Why does the admin site not care about my custom user's permissions? »
I started a Django (1.10.3) project with a custom user model, inherited from AbstractBaseUser. A couple of weeks into developing the thing, I saw that...
(1) odpowiedzi
2017-02-10 14:02 Search within nested Django JSONField (either via Django ORM or raw sql) »
Edit: Added solution below. No-one was able to suggest a native Postgres, one-hit search-and-replace so I had to parse the log in Python and then do a...
(2) odpowiedzi
2017-02-10 09:02 python numpy: how to construct a big diagonal array(matrix) from two small array »
import numpy as np A = np.array([[1, 2], [3, 4]]) B = np.array([[5, 6], [7, 8]]) C = np.array([[1, 2, 0, 0], ...
(1) odpowiedzi
2017-02-10 09:02 SqlDeveloper - checking for NULL values without IS NULL clause - in a scripted query »
for circuit in allCircuit: # a cvs of 4 columns part = circuit.split(",") res = cur.execute("""SELECT col4 from ATable WHE...
(1) odpowiedzi
2017-02-10 04:02 Django QuerySet select related objects »
I have searched around but have not found a situation like mine. Assuming the use of Django's User Profile method to extend the default user features,...
(1) odpowiedzi
2017-02-10 00:02 Prevent type coercion when using string template formatting »
>>> b'potato {} potato'.format(u'potato') # return value matches the template 'potato potato potato' >>> b'potato %s potato' % u'p...
(1) odpowiedzi
2017-02-09 23:02 Pandas TimeGrouper and Pivot? »
This is what my dataframe looks like: Timestamp CAT 0 2016-12-02 23:35:28 200 1 2016-12-02 23:37:43 200 2 2016-12-02 23:40:49...
(3) odpowiedzi
2017-02-09 16:02 Debugging a Neural Network »
TLDR I have been trying to fit a simple neural network on MNIST, and it works for a small debugging setup, but when I bring it over to a subset of MN...
(1) odpowiedzi
2017-02-09 16:02 Django ajax 403 because of httponly cookie »
I have a strange issue with CSRF in Django. Here are the relevant portions: In my javascript file I have: function getCookie(name) { var cookieV...
(1) odpowiedzi
2017-02-09 09:02 Django JSON file to Pandas Dataframe »
I have a simple json in Django. I catch the file with this command data = request.body and i want to convert it to pandas datarame JSON: { "username...
(2) odpowiedzi
2017-02-09 08:02 Slow recursion in python »
I know this subject is well discussed but I've come around a case I don't really understand how the recursive method is "slower" than a method using "...
(1) odpowiedzi
2017-02-09 06:02 Can't get django-star-ratings to display to template »
New to Django, feel like I'm close to figuring out where I'm going wrong here. I have been trying to pass the context to my template to no avail. In...
(1) odpowiedzi
2017-02-09 03:02 Can there be an else block statement in python try-except? »
I'm trying to write a subscription list module. So, I have a statement that may, depending on the email id of the user, throw an index out of range er...
(1) odpowiedzi
2017-02-08 18:02 Find where f(x) changes in a list, with bisection (in Python) »
Reasoning: I'm trying to implement, in Python, something similar to git bisect, but with basically a list of directories. I have a (long) list of ve...
(3) odpowiedzi
2017-02-08 17:02 Loading mysql table into python takes a very long time compared to R »
I have a fairly large mysql table, about 30M rows, 6 columns, about 2gb when loaded into memory. I work with both python and R. In R, I can load the...
(2) odpowiedzi