Not caching view in Django LocMemCache

I am trying to cache a class based view like so urls.py from django.views.decorators.cache import cache_page from django.conf.urls import url urlpatterns = [ url(r'^/awesome-url$', cache_page(60 * 60)(TemplateView.as_view(template_name="awesom...
more »

2017-06-21 23:06 (1) Answers

How to sort a list, only sorting strings?

I have a list of strings and integers and want to sort the list, preserving the numbers like so ["Hello", 1, 2, "World", 6, "Foo", 3] would become ["Foo", 1, 2, "Hello", 6, "World", 3] In short, it only sorts the strings in the list, not the in...
more »

2017-06-21 22:06 (3) Answers

Using .sub() over a variable length dataframe?

I have a need to calculate the difference between one static column in a dataframe and some variable amount of columns that make up the rest of the dataframe. My data look like this: School District | 01-01-2017 | 01-02-2017 |...| 02-01-2017 | Base...
more »

2017-06-21 21:06 (2) Answers

Python objects aren't accepting arguments

I am trying to create a snake in python, I am doing this through an object that will be a snake. I am trying to call a createSnake function from inside my object but the arguments aren't being accepted. My IDE is returning: TypeError: createsnake()...
more »

2017-06-21 21:06 (2) Answers

Python Microsoft Exchange with Attachment

Can someone help me send an email from my exchange account and add attachments. SMTP doesnt work, i get immediate timeout issues. 0365 doesnt save a copy to my sent folder. The only other one i know is exchangelib Thanks from exchangelib import Ac...
more »

2017-06-21 21:06 (0) Answers

Numpy Array Subtraction

How would I go about comparing two different numpy arrays to create a third array? I want to write a loop that goes through two arrays and prints a new array "c" with only the values that are not in a or b For example say I have a = [1,2,3,4] b =...
more »

2017-06-21 18:06 (1) Answers

Ignoring NaN in a dataframe

I want to find the unique elements in a column of a dataframe which have missing values. i tried this: df[Column_name].unique() but it returns nan as one of the elements. what can i do to just ignore the missing values. dataframe look like this.click...
more »

2017-06-21 18:06 (1) Answers

Doesn't Django cache support Integers?

I am using PHP to populate my memcached, and Django to read the cache. I have made my custom make_key function in Django settings.py so that the key is same and Django doesn't modify it. def make_key(key, key_prefix, version): return key CACH...
more »

2017-06-21 15:06 (1) Answers

Creating an ordered matrix through indexing

I have a problem related to a detector that reads out the amount of photons that get fed into channels and the times they enter the detector, Lets say its channels 0 to 6 for simplicity sake. Array A will hold the channels, basically the index list, ...
more »

2017-06-21 05:06 (1) Answers

Python numpy unwrap function

I am hoping to convert a array of radians into range [0, 2*pi) and numpy unwrap function is exactly what I need However, when I run the following code to input a = [pi, 2*pi, 3*pi]: import numpy as np a = np.array([np.pi, 2*np.pi, 3*np.pi]) np....
more »

2017-06-21 00:06 (2) Answers

Python defining function outputs only first dir

when i def a function and try to use os.walk in it , the output is just the first file in the directory , i want to print out all there is in the C Drive. #os.chdir=("..") def dirslist(): for root, dirs, files in os.walk("c://", topdown=False): f...
more »

2017-06-20 21:06 (4) Answers

Using scipy kmeans for cluster analysis

I want to understand scipy.cluster.vq.kmeans. Having a number of points distributed in 2D space, the problem is to group them into clusters. This problem came to my attention reading this question and I was thinking that scipy.cluster.vq.kmeans wou...
more »

2017-06-20 20:06 (1) Answers

returning numpy arrays via pybind11

I have a C++ function computing a large tensor which I would like to return to Python as a NumPy array via pybind11. From the documentation of pybind11, it seems like using STL unique_ptr is desirable. In the following example, the commented out ...
more »

2017-06-20 19:06 (1) Answers

E-Mailing with Scrapy Basics

I have the following code, and I need the exported items to be emailed to me so I can see the news. I am aware of Scrapy - 1.4 - Email Docs and I just can't seem to find enough examples to be able to do the same with my code. What's a good way to s...
more »

2017-06-20 18:06 (1) Answers

Pandas column of lists to separate columns

Problem Incoming data is a list of 0+ categories: #input data frame df = pd.DataFrame({'categories':(list('ABC'), list('BC'), list('A'))}) categories 0 [A, B, C] 1 [B, C] 2 [A] I would like to convert this to a DataFrame with one c...
more »

2017-06-20 17:06 (2) Answers

python numpy array indexing

I think I understand the indexing of array in python/numpy correctly. But today I met a problem as follows: I have a 6-d array e.g. A and A.shape = (11,1,9,1,5,7). Then I use the indexing as follows: B = A[:,0,0,0,[3,4,2],0] and B.shape = (11,3...
more »

2017-06-20 17:06 (1) Answers

How to write DataFrame-friendly functions

Recently I've been making the switch from using numpy's ndarray to pandas' DataFrame for my data analysis needs. I've noticed that numpy functions seem to accept DataFrame objects in place of ndarray without issue. However, when I try to use many of ...
more »

2017-06-20 16:06 (1) Answers

Request.args as filters from several path levels

I would know if it's possible to get request.args from different path levels. Currently i can use request.args for only one level : my_ip:my_port/modules/?name=git or my_ip:my_port/modules/?id=0   @module_blueprint.route('/', methods=['GET'...
more »

2017-06-20 15:06 (1) Answers

modify flask url before routing

My Flask app has url routing defined as self.add_url_rule('/api/1/accounts/<id_>', view_func=self.accounts, methods=['GET']) Problem is one of the application making queries to this app adds additional / in url like /api/1//accounts/id. It's...
more »

2017-06-20 13:06 (1) Answers