Data dodania Pytanie
2017-11-18 21:11 PCA on sklearn - how to interpret pca.components_ »
I ran PCA on a data frame with 10 features using this simple code: pca = PCA() fit = pca.fit(dfPca) The result of pca.explained_variance_ratio_ sho...
(2) odpowiedzi
2017-11-18 21:11 Django add a relation between the user and the selected articles »
I have a simple model Article. The model is: class Article(models.Model): title = models.CharField() text = models.TextField() likes = mo...
(2) odpowiedzi
2017-11-18 20:11 "Merging" numpy arrays together with a common dimension »
I have two matricies, corresponding to data points (x,y1) and (x,y2): x | y1 ------------ 0 | 0 1 | 1 2 | 2 3 | 3 4 | 4...
(4) odpowiedzi
2017-11-18 20:11 Ubuntu 17: Can't install mysqlclient »
Trying to follow a Django tutorial but I cannot install mysqlclient. The tutorial claims that I can do so with the following command: pip install my...
(2) odpowiedzi
2017-11-18 19:11 Removing extra output from "su - <username> sh -c '<command>'" in a shell script »
In my python script, I'm trying to get the output of a command that needs to be run as a different user. So I have this code: username = "<usernam...
(0) odpowiedzi
2017-11-18 14:11 How to use functional programming to iterate and find maximum product of five consecutive numbers in a list? »
I have to use functional programming to implement the following function takes in a list of numbers from 0 to 9. The goal is to find the five consecut...
(8) odpowiedzi
2017-11-18 14:11 faster evaluation calls of a function »
I have a function that needs to be evaluated at least 1e6 times. It only requires two arrays as input. import numpy as np np.random.seed(1) res = np...
(4) odpowiedzi
2017-11-18 14:11 bottle.py stalls when client disconnects »
I have a python server written with bottle. When I access the server from a website using Ajax, and then close the website before the server can send ...
(1) odpowiedzi
2017-11-18 12:11 I want to calculate slope and intercept of a linear fit using pykalman module »
Consider the linear regression of Y on X, where (xi, yi) = (2, 7), (0, 2), (5, 14) for i = 1, 2, 3. The solution is (a, b) = (2.395, 2.079), obtained ...
(1) odpowiedzi
2017-11-18 09:11 KeyError: 'locations' in Django app »
I'm working on a Django application which fetches JSON data from an API and stores it in PostgreSQL database. But while migrating the app I'm getting ...
(1) odpowiedzi
2017-11-18 00:11 How do I adjust the scale of axis in matplotlib to orders of magnitude »
I'm trying to change the scale of my axis on a 2D-plot that I made. I hid the 1e-7 at the end of either axis, so that I can write 'ylabel' in µm (10^...
(0) odpowiedzi
2017-11-17 20:11 How to remove superfluous characters from returned list result by print statement »
I have a small application connected to a DB. I can insert data with raw_input and then I have select query to return some results as a report. this ...
(2) odpowiedzi
2017-11-17 15:11 How to get random value of attribute of Enum on each iteration? »
I have created such Enum object: class Gender(Enum): FEMALE = 'female' MALE = 'male' RANDOM = random.choice([FEMALE, MALE]) and i want ...
(7) odpowiedzi
2017-11-17 15:11 Each subject has a subject code.When i select one subject its subject code should be displayed in the edit box »
I have a new QLineEdit(box) for the subject code.Each subject has a subject code(for eg Sentiment Analysis has code CS01,Data Cleansing has CS02,etc.)...
(1) odpowiedzi
2017-11-17 12:11 Function composition, tuples and unpacking »
(disclaimed: not a Python kid, so please be gentle) I am trying to compose functions using the following: def compose(*functions): return functool...
(2) odpowiedzi
2017-11-17 11:11 what happened when using the same variable in two layer loops in python? »
I test the following code: for i in range(3): for i in range(3,5): print "inner i: %d"%(i) print "outer i: %d"%(i) and the output i...
(6) odpowiedzi
2017-11-17 06:11 Explanation for a code needed : Appending the values to list in python »
Anyone explain this please...... def f(i,list1=[]): list1.append(i) return list1 f(1) f(2) print(f(3)) Output: [1,2,3]. I cannot u...
(1) odpowiedzi
2017-11-16 23:11 Python Social Auth authenticating users to wrong accounts »
For some reason users while using Facebook to oath, the user will auth as random users. When I looked into the UserSocialAuth table there was one use...
(0) odpowiedzi
2017-11-16 21:11 Pandas: append row to DataFrame with multiindex in columns »
I have a DataFrame with a multiindex in the columns and would like to use dictionaries to append new rows. Let's say that each row in the DataFrame i...
(4) odpowiedzi
2017-11-16 14:11 Changing '?' to '&' in address bar »
For example, in my web-app I have a link with url www.example.com/profile?name=name. When I click to that link, I'm getting a page, where I can change...
(1) odpowiedzi
2017-11-16 13:11 Converting Python 3 String of Bytes of Unicode - `str(utf8_encoded_str)` back to unicode »
Well, let me introduce the problem first. I've got some data via POST/GET requests. The data were UTF-8 encoded string. Little did I know that, and c...
(2) odpowiedzi
2017-11-16 13:11 Pandas, are there any faster ways to update values? »
Currently, my table has over 10000000 records, and there is a column named ID, and I want to update column named '3rd_col' with a new value if the ID ...
(1) odpowiedzi
2017-11-16 04:11 Function that turns sequence into list »
We know that list(map(f,[1,2],[3,4],[6,7])) is equivalent to [f(1,3,6),f(2,4,7)] I want to know if there is built-in function tolist that is e...
(0) odpowiedzi
2017-11-16 01:11 How to generate indexes for related fields on Django models? »
Say we're building a Django-based site that clones Medium.com's URL structure, where you have users and articles. We'd probably have this model: clas...
(1) odpowiedzi
2017-11-15 22:11 Django Isolated Subdomains »
Let's say we have a model called Event with a slug name. I'm looking to configure my Django app to basically isolate all my other models into separate...
(2) odpowiedzi
2017-11-15 15:11 Ordering a table »
I want in spark to order this data frame (the first row is the header) | A | BB| CC | DD | EE | LEVEL | |7 ...
(0) odpowiedzi
2017-11-15 15:11 Django-Rest-Framework APIView returning a model object and an image »
suppose that I want to return in a APIView.get a (non model) object conatining 2 properties, one of them is a model object, and the other is a binary ...
(3) odpowiedzi
2017-11-15 13:11 Which operator (+ vs +=) should be used for performance? (In-place Vs not-in-place) »
Let's say I have this two snippet of code in python : 1 -------------------------- import numpy as np x = np.array([1,2,3,4]) y = x x = x + np.array(...
(1) odpowiedzi
2017-11-15 11:11 Why does Gzip not work on Chrome? »
I am trying to see the effects of gzip on my website. Currently, I am using flask and I put a print statements to observe the effects of gzip: def c...
(0) odpowiedzi
2017-11-15 11:11 pandas.eval with a boolean series with missing data »
Description I am using pandas.eval on a boolean series with missing data. To do this I use an indexer to mark non-null values and .loc to only appl...
(1) odpowiedzi
2017-11-15 11:11 Python equivalent of ruby rspec's "skip" and "pending" »
I'm coming from ruby to python. With ruby's rspec, I am used to using skip and pending to denote tests which should be skipped / cannot currently be e...
(1) odpowiedzi
2017-11-15 08:11 What is "metrics" in keras libray in Python? »
It is not yet clear for me what metrics are (as given in the code below). What exactly are they evaluating? Why do we need to define them in the model...
(3) odpowiedzi
2017-11-15 07:11 python unicode convert to Japanese character »
I am trying to convert u'\u30c9\u30e9\u30b4\u30f3' to japanese character using python here is my sample code s = u'\u30c9\u30e9\u30b4\u30f3'.encode(...
(2) odpowiedzi
2017-11-14 19:11 Cython No Performance Increase with prange/parallel »
I'm using Cython version 0.27.3 to compile the following source for a simple primality testing module that contains both python and cython implementat...
(1) odpowiedzi
2017-11-14 19:11 Django - How can I prevent access to other users' objects? »
Let's assume that I have such URL users/{id}/objects and I am authenticated as a User with ID equals 1. At the moment I can access objects of users wi...
(2) odpowiedzi