Data dodania Pytanie
2017-05-08 14:05 Cannot import models from another app in Django »
so I have 2 apps running in the same project. My files are structured as follows: /project_codebase /project __init.py settings....
(5) odpowiedzi
2017-05-08 01:05 Efficient Algorithm to compose valid expressions with specific target »
The problem is stated as: Given a string that contains only digits 0-9 and a target value, return all expressions that are created by adding some bina...
(2) odpowiedzi
2017-05-07 23:05 Python start line with a letter, combining two for loops? »
I'm trying to have my program output: a. am {1: '2'} b. at {1: '2'} c. far {1: '1'} ... ff. glad {1: '2'} gg. i {1: '2'} hh. it {1: '1'} ... ooo. le...
(1) odpowiedzi
2017-05-07 16:05 Pandas vs. Numpy Dataframes »
Look at these few lines of code: df2 = df.copy() df2[1:] = df[1:]/df[:-1].values -1 df2.ix[0, :] = 0 Our instructor said we need to use the .values...
(1) odpowiedzi
2017-05-07 16:05 expanding a dataframe based on start and end columns (speed) »
I have a pandas.DataFrame containing start and end columns, plus a couple of additional columns. I would like to expand this dataframe into a time ser...
(4) odpowiedzi
2017-05-07 15:05 Django, view email fetched by imaplib on my webpage »
I'm trying to create a mail client using Django. I am fetching the body of the emails from my inbox this way using imaplib: def get_email_body(usern...
(0) odpowiedzi
2017-05-07 13:05 Why is the str() used in this situation? »
These are the codes from django.db.models.fields __all__ = [str(x) for x in ( 'AutoField', 'BLANK_CHOICE_DASH', 'BigAutoField', 'BigIntegerField'...
(1) odpowiedzi
2017-05-07 09:05 Getting no output after running python program »
I am supposed to write a class named Employee that holds the data of name, salary, and years of service. It calculates the monthly pension payout the ...
(2) odpowiedzi
2017-05-07 09:05 Django Forms:Post request is got but data is not saved »
So I'm trying to build a Django site that collects Mod Applications to learn Django Forms. Except that I'm an idiot and I don't know what am I doing. ...
(2) odpowiedzi
2017-05-07 04:05 Python loop optimization »
I am currently working with a file with more than 2 million lines. I've separated the lines into lists of elements (ex: [a,b,c,d] = 1 line, words sepa...
(1) odpowiedzi
2017-05-06 20:05 Why does using arguments make this function so much slower? »
I have recently been working on creating a prime-number finding program. However, I came to notice that one function was much slower when it used argu...
(2) odpowiedzi
2017-05-06 19:05 Performance in different vectorization method in numpy »
I wanted to test the performance of vectorizing code in python: import timeit import numpy as np def func1(): x = np.arange(1000) sum = np.sum(x...
(3) odpowiedzi
2017-05-06 15:05 How to elegantly check if a dictionary has a given structure? »
I have a dictionary with the following structure: D = { 'rows': 11, 'cols': 13, (i, j): { 'meta': 'random string', ...
(5) odpowiedzi
2017-05-06 00:05 Stringing together a series of foreign keys to return a table value in Django »
How do I select the ctype knowing the user? models.py: from django.contrib.auth.models import User class CompanyType(models.Model): ctype = mod...
(1) odpowiedzi
2017-05-05 22:05 Is it safe to name field as 'id' in Django model? »
class MyModel(models.Model): id = models.IntegerField(primary_key=True) or class MyModel(models.Model): id_ = models.IntegerField(primary_k...
(2) odpowiedzi
2017-05-05 21:05 is there a way to refactor this? **kwarg - django »
I have been calling the same model over and over again but somethings with different field but there would be a few that would always be the same. I ...
(4) odpowiedzi
2017-05-05 19:05 What is the most efficient way to copy an externally provided buffer to bytes »
I am interfacing to an external library using ctypes. This library returns to me a binary buffer. The interface looks like this: int getBuff(unsigned...
(1) odpowiedzi
2017-05-05 13:05 Python - Better way for looping multidimensional dictionary »
how I can change my code to use just one loop. I try to use .iteritems(), iterkeys() etc... for user in data: for item in data[user]: st...
(1) odpowiedzi
2017-05-05 10:05 pandas: filter group by multiple conditions? »
I have a data frame that looks like this: df = pd.DataFrame([ {'id': 123, 'date': '2016-01-01', 'is_local': True }, {'id': 123, 'date': '2017-01-...
(3) odpowiedzi
2017-05-05 10:05 Dynamic Facebook Like »
I have a news app on my website. I added a Facebook like button on every news/post page but i can’t get it working correctly. When I click on the l...
(1) odpowiedzi
2017-05-04 23:05 Sending different errors depending on url Django »
I am working in Django and I have a situation where I have written a custom validator that lives in the model.py This validator should return a valid...
(1) odpowiedzi
2017-05-04 18:05 Convert a list of numbers to ranges »
I have a bunch of numbers, say the following: 1 2 3 4 6 7 8 20 24 28 32 The information presented there could be represented in Python as ranges:...
(4) odpowiedzi
2017-05-04 17:05 Use a metric after a classifier in a Pipeline »
I continue to investigate about pipeline. My aim is to execute each step of machine learning only with pipeline. It will be more flexible and easier t...
(1) odpowiedzi
2017-05-04 17:05 Python built-in max(), when 2 values are the same which one gets picked? »
I have a code that processes data based on some dates. Lets say: case1: values1 with date1 = '2002-02-01' values2 with date2 = '2004-02-01' case2:...
(2) odpowiedzi
2017-05-04 15:05 Scikit K-means clustering performance measure »
I'm trying to do a clustering with K-means method but I would like to measure the performance of my clustering. I'm not an expert but I am eager to le...
(0) odpowiedzi
2017-05-04 11:05 Create two dictionnaries from one single iterator »
I need to create two dictionnaries while reading input from one generator. I am concerned with the fact that both dict and the data only need to be sc...
(1) odpowiedzi
2017-05-04 09:05 Django French Translation - how to handle single quotes in translation strings? »
I am using Python 3.5.2 and Django 1.10. I have received the French translation .po file and can run the compilemessages command without receiving an...
(1) odpowiedzi
2017-05-04 05:05 Split text to csv by other delimiter but maintaining the comma in each column »
I have a txt file containing pipe | delimited values, but unfortunately, I have encountered some errors , the csv DictReader assumed that the comma in...
(1) odpowiedzi
2017-05-04 01:05 Django __istartswith does't work. Python 2.7, Django 1.8 »
I am working with cyrillic text. There is parser written in python2.7 which saves strings from another site into database, which are saved as unicode ...
(0) odpowiedzi
2017-05-03 23:05 Sorting a list in python from the second element on »
I want to sort a list but I want it to be sorted excluding the first element. For example: a = ['T', 4, 2, 1, 3] Now I want the list to be sorted ...
(2) odpowiedzi
2017-05-03 23:05 Make a dataframe with grouped questions from three columns »
I have the following dataframe: A B C I am motivated Agree 4 I am motivated Strongly...
(2) odpowiedzi
2017-05-03 13:05 Can `weakref` callbacks replace `__del__`? »
Is there any obstacle that prevents weakref from doing everything that __del__ does but with much stronger guarantees (e.g., finalize guarantees that ...
(1) odpowiedzi
2017-05-03 10:05 Rebase csv file by merging a base csv file with another new csv file »
I am currently working with two csv files, base.csv and another csv file, output_20170503.csv which will be produced everyday, so my aim here is to re...
(2) odpowiedzi
2017-05-03 09:05 Unknown spaces in output of python script after postgresql database query »
I am trying to execute a query from postgresql database using the psycopg2, but my problem here is the output I get contains unknown spaces, Here is ...
(1) odpowiedzi
2017-05-03 02:05 Big O Notation of a module nested in a built-in method in Python »
I'm wondering about a rationale for determining the big O values behind built-in methods in Python. Given the following operation: i_arr = ['1','2','...
(3) odpowiedzi