Data dodania Pytanie
2017-06-11 09:06 Why isn't the following Python script installing libraries using pip? »
I am trying to automate creating a project in Django with the following script. import os, sys, pip, virtualenv directory = sys.argv[1] if not os.pa...
(1) odpowiedzi
2017-06-11 02:06 pandas rolling apply doesn't do anything »
I have a DataFrame like this: df2 = pd.DataFrame({'date': ['2015-01-01', '2015-01-02', '2015-01-03'], 'value': ['a', 'b', 'a']}) ...
(1) odpowiedzi
2017-06-10 22:06 Why does radix sort have a space complexity of O(k + n)? »
Consider an array with n numbers that has maximum k digits (See Edit). Consider the radix sort program here. The buckets basically is a 2d list of all...
(3) odpowiedzi
2017-06-10 20:06 Pandas DataFrame slow to show shape or dtypes »
I'm very new to python and pandas. Any guidance, comment, and suggestion are appreciated! Here is my issue: it takes couple minutes to return the res...
(0) odpowiedzi
2017-06-10 19:06 Django - POST method in relational database model - table doesn't exist »
I would like to create Object2 for defined user ID in url. GET method in the example shown below works fine, but I can't create POST method. I will be...
(1) odpowiedzi
2017-06-10 16:06 Django - How to map object from another API and send in GET response »
I would like to map object from another API and send in GET response. I'm going to change only id of received object. Let's assume I get data from ano...
(2) odpowiedzi
2017-06-10 13:06 How to write views.py for (status) check in models.py »
How do I select the choice parameter "published" in models from views.py? In models.py, I have given choices the options of [draft,published]. I'm us...
(1) odpowiedzi
2017-06-10 09:06 Python 3: Perfect Alphabetical Order »
The goal of the code attempts to find the longest alphabetical substring within a string. s = 'xyzbcdezzz' longest_string = '' current_string = ''...
(8) odpowiedzi
2017-06-10 04:06 In Python, How do I check whether a file exists starting or ending with a substring? »
I know about os.path.isfile(fname), but now I need to search if a file exists that is named FILEnTEST.txt where n could be any positive integer (so it...
(2) odpowiedzi
2017-06-09 20:06 CNN gives biased results »
I am using a binary classifier on CNN. I have two categories "me" and "others". I have around 250 images of myself and 500 of others ( random faces db...
(2) odpowiedzi
2017-06-09 19:06 How to retrieve objects simultaneously from database? »
I'm building a social analytics website with Django. Here is one of my use cases: "Users" of the site analyze social media "profiles" (from Snapcha...
(2) odpowiedzi
2017-06-09 15:06 How to make nested for loop more Pythonic »
I have to create a list of blocked users per key. Each user has multiple attributes and if any of these attributes are in keys, the user is blocked. ...
(4) odpowiedzi
2017-06-09 15:06 Permutations without repeating the output in Python »
I want to get all the possible permutations of two different elements grouped by four without repeating the output but repeating elements (obviously y...
(2) odpowiedzi
2017-06-09 14:06 Getting result grouped by month in Django »
I want to get all members from a Member model and get total calculations that they have done per month. My query is as follows: members_list = Membe...
(1) odpowiedzi
2017-06-09 06:06 How to json.dumps byte object in python3 »
In python2 import json a = {"text": u"你好".encode("gbk")} json.dumps(a, ensure_ascii=False) >>> Out: '{"text": "\xc4\xe3\xba\xc3"}' I ...
(1) odpowiedzi
2017-06-08 21:06 Numpy Matrix Syntax - Are there differences between python2 and python3 »
I have an algorithm that was written and tested with Python2.5. It is purely matrix operations. Did the numpy matrix operations syntax change going fr...
(0) odpowiedzi
2017-06-08 20:06 Function object called via class attribute fails »
I currently have a system of classes that register callbacks and then call them when certain conditions are met. However I am running into some proble...
(5) odpowiedzi
2017-06-08 17:06 Cost of calling str() on a string? »
What is the cost (if any) of calling the str function on an object that is already a string? The use case here is to normalize an array of objects of ...
(2) odpowiedzi
2017-06-08 10:06 python from 2D array to 3D coordinates array »
I have a mXn numpy array called a: I would like to write a function which returns an array with size (3, mxn) which contains for each couple (x,y) in...
(1) odpowiedzi
2017-06-08 09:06 Can't run django tests by tag »
I have problem because I wanted to tag some test in django but when I type in console from django.test import tag, TestCase @tag('fast', 'something...
(0) odpowiedzi
2017-06-08 00:06 Django logging custom attributes in formatter »
How can Django use logging to log using custom attributes in the formatter? I'm thinking of logging the logged in username for example. In the settin...
(2) odpowiedzi
2017-06-07 23:06 Why do some built-in constructors begin with a lower case letter? »
Why do some constructors like int(), list(), set() and many others starts with a lower case letter instead of upper case? Shouldn't this be written In...
(2) odpowiedzi
2017-06-07 23:06 is_even() and is_odd() indirect recursion confusion »
In this code: def is_even(x): if x == 0: return True else: return is_odd(x-1) def is_odd(x): return not is_even(x) print(is_even(2)) ...
(5) odpowiedzi
2017-06-07 22:06 Is_Integer returning incorrect result - Python 2.X »
dig = 16807 digcount = len(str(dig)) minroot = dig ** (1 / float(digcount)) print minroot print minroot.is_integer() minroot returns as 7.0 as a fl...
(3) odpowiedzi
2017-06-07 20:06 A dictionary with a unique possible value for each key? »
I need to create a map from twitter status IDs to their author ID. Obviously, each status has exactly one author. I expected Python collections to ha...
(0) odpowiedzi
2017-06-07 18:06 MySQL 'SHOW TABLES' Returns count instead of list (Python) »
I'm troubleshooting a script I am using to query the database. To make sure I had everything working right I stripped it down to a simple 'SHOW TABLES...
(1) odpowiedzi
2017-06-07 10:06 Remove model inheritance and keep id in newly created autofield »
I have a model which inherit from a non-abstract super model: class Person(models.Model): pass class User(Person): pass Because of a conce...
(1) odpowiedzi
2017-06-07 09:06 Why is it impossible to mix Python2 with Python3? »
Despite all that has been said and written on Python2 vs Python3, I have been unable to identify why the developers made it impossible to mix Python2 ...
(2) odpowiedzi
2017-06-06 23:06 Django Rest Framework: Unclear error message »
my views.py: class user_password(generics.UpdateAPIView): authentication_classes = ([JSONWebTokenAuthentication]) serializer_class = user_pas...
(1) odpowiedzi
2017-06-06 19:06 Vectorize or optimize an loop where each iteration depends on the state of the previous iteration »
I have an algorithm which I am implementing in python. The algorithm might be executed 1.000.000 times so I want to optimize it as much as possible. T...
(1) odpowiedzi
2017-06-06 15:06 Setting up django parallel test in setting.py »
Hello I know that it's possible to run tests in django in parallel via --parallel flag eg. python manage.py test --parallel 10. It really speeds up te...
(1) odpowiedzi
2017-06-06 14:06 Why does Python optimize out "if 0", but not "if None"? »
Why is it that if you compile a conditional expression like def f(): if None: print(222) if 0: print(333) the branches that...
(2) odpowiedzi
2017-06-06 13:06 Django - How to filter a ManyToMany model object? »
I have the following models which are linked via a foreign key and ManyToMany relationship. from django.db import models from django.contrib.auth.mod...
(1) odpowiedzi
2017-06-06 11:06 How to explain the reverse of a sequence by slice notation a[::-1] »
From the python.org tutorial Slice indices have useful defaults; an omitted first index defaults to zero, an omitted second index defaults to the ...
(5) odpowiedzi
2017-06-06 03:06 Pandas rolling regression: alternatives to looping »
I got good use out of pandas' MovingOLS class (source here) within the deprecated stats/ols module. Unfortunately, it was gutted completely with pand...
(1) odpowiedzi