Django - multiple url routers, same url?

So i am trying to have a server control page in a django applications with a list of servers that links via uuid to starting, cloning and stopping each respective server. (think a really terrible openstack UI). This is the code that generates the url...
more »

2017-08-19 13:08 (1) Answers

Drop all columns where all values are zero

I have a simple question which relates to similar questions here, and here. I am trying to drop all columns from a pandas dataframe, which have only zeroes (vertically, axis=1). Let me give you an example: df = pd.DataFrame({'a':[0,0,0,0], 'b':[0,...
more »

2017-08-17 12:08 (3) Answers

Product of 2 fibonacci numbers

My assignment: Given a number, say prod (for product), we search two Fibonacci numbers F(n) and F(n+1) verifying F(n) * F(n+1) = prod if F(n) * F(n+1) = prod Your function productFib takes an integer (prod) and returns an array: [F(n), ...
more »

2017-08-17 00:08 (6) Answers

print mismatch items in two array

I want to compare two array(4 floating point)and print mismatched items. I used this code: >>> from numpy.testing import assert_allclose as np_assert_allclose >>> x=np.array([1,2,3]) >>> y=np.array([1,0,3]) >>> np...
more »

2017-08-16 14:08 (1) Answers

Django rest pagination next url is not correct

I have created a Django rest api using ModelViewSet. Deployed in staging and now in production.Production is working fine,but staging has some incorrect "next" url. See the key "next" in both images, first image is the staging response and second...
more »

2017-08-15 13:08 (0) Answers

Call two pandas columns in a function?

I have a bunch of URLs I am trying to write to files. I store the URLs in a pandas dataframe. The dataframe has two columns: url and id. I am trying to request each URL from url and write it to a file named id. Here is what I got so far: def get...
more »

2017-08-15 09:08 (2) Answers

Self made python class

I defined two class in a separated file (which name is from my main program and I am trying to include it. The class definition is as follows: class MyClass: Tn="" def _init_(self,TN): self.Tn=TN while my main pro...
more »

2017-08-15 08:08 (1) Answers

os.listdir() is giving larger lists than expected

My book states that: Calling os.listdir(path) will return a list of filename strings for each file in the path argument. I tried to get the files inside a folder which is placed on the desktop and it worked perfectly fine. Then I tried to get t...
more »

2017-08-14 02:08 (1) Answers

Namespaces inside class in Python3

I am new to Python and I wonder if there is any way to aggregate methods into 'subspaces'. I mean something similar to this syntax: smth = Something() smth.subspace.do_smth() smth.another_subspace.do_smth_else() I am writing an API wrapper and I'm...
more »

2017-08-13 19:08 (1) Answers

Rounding errors with PIL

I am having trouble writing to an image with my Mandelbrot program; it is to do with rounding errors with "(maxx-minx)/width" compared to "(maxy-miny)/width" line 31, which leads to a 501 by 500 picture rather than a 500 square picture. ((width+1) *...
more »

2017-08-12 20:08 (1) Answers