Data dodania Pytanie
2017-04-22 21:04 Python regex module vs re module - pattern mismatch »
Update: This issue was resolved by the developer in commit be893e9 If you encounter the same problem, update your regex module. You need version 20...
(2) odpowiedzi
2017-04-22 19:04 How can I optimize the calculation over this function in numpy? »
I want to implement the following problem in numpy and here is my code. I've tried the following numpy code for this problem with one for loop. I am...
(1) odpowiedzi
2017-04-22 17:04 Django 1.9.13 complains SubfieldBase is deprecated, but I'm not using it. How to resolve? »
I am upgrading an old Django project from Django 1.8.3 to the current Django 1.11, but to be cautious, I am upgrading to each major release of Django ...
(1) odpowiedzi
2017-04-22 12:04 How to make future calls and wait until complete with Python? »
I have the following code where I have a list of usernames and I try and check if the users are in a specific Windows Usergroup using net user \domain...
(2) odpowiedzi
2017-04-22 04:04 How to pass a function result to a tuple? »
I am working on a Python/Django/Wagtail project, and at some point I have a class like this: class SuperClass(BaseClass): body = StreamField([ ...
(2) odpowiedzi
2017-04-21 19:04 How can I tell that the page has finished loading? »
I'm playing with Chromium's headless web browser API. Based on chrome_remote_shell source code, I came up with the following code: #!/usr/bin/env pyt...
(3) odpowiedzi
2017-04-21 16:04 Bar Chart with multiple labels »
The following code only shows the main category ['one', 'two', 'three', 'four', 'five', 'six'] as the x axis labels. Is there a way show subcategory [...
(2) odpowiedzi
2017-04-21 16:04 A confusion on type.__init__ in Python 2 »
Take a look at the following example class Base(type): def __init__(cls, name, bases, dict_): print 'Base.__init__() with cls %s, name %s...
(1) odpowiedzi
2017-04-21 13:04 Fast indexing and bit flipping of boolean data using Python »
Using Python, I'm running a simulation where a community of species goes through a sequential set of time steps ('scenes') in each of which extinction...
(3) odpowiedzi
2017-04-21 12:04 Do I need to make a migration if I change null and blank values on a Model field? »
I have the following model @python_2_unicode_compatible class Booking(models.Model): session = models.ForeignKey(verbose_name=_('Session'), to=Se...
(4) odpowiedzi
2017-04-21 11:04 Combining rows to 'others' in pandas »
I have a pandas dataframe like this: character count 0 a 104 1 b 30 2 c 210 3 d 40 4 e 18...
(1) odpowiedzi
2017-04-21 10:04 Python is reading past the end of the file. Is this a security risk? »
So I just noticed this, and after some experimentation, I managed to make it reproducible. I didn't see this posted anywhere. Python seems to be readi...
(0) odpowiedzi
2017-04-21 08:04 Error: object of type 'zip' has no len() after adding extra header by using zip »
I try to follow this link pandas dataframe with 2-rows header and export to csv in order for me to created extra header without remove the original...
(1) odpowiedzi
2017-04-21 00:04 How to write this code in a idiomatic/functional way? »
I'm trying to write this piece of python code in a more modular/reusable fashion and I'm having trouble writing it Consider this: lst = get_list_of_...
(1) odpowiedzi
2017-04-20 18:04 Unexpected 32-bit integer overflow in pandas/numpy int64 (python 3.6) »
Let me start with the example code: import numpy from pandas import DataFrame a = DataFrame({"nums": [2233, -23160, -43608]}) a.nums = numpy.int64(...
(1) odpowiedzi
2017-04-20 18:04 Difference between Linear Regression Coefficients between Python and R »
I'm trying to run a linear regression in Python that I have already done in R in order to find variables with 0 coefficients. The issue I'm running in...
(2) odpowiedzi
2017-04-20 13:04 Cumulative (running) sum with django orm and postgresql »
Is it possible to calculate the cumulative (running) sum using django's orm? Consider the following model: class AModel(models.Model): a_number =...
(3) odpowiedzi
2017-04-20 01:04 Pandas: Fill NaNs with next non-NaN / # consecutive NaNs »
I'm looking to take a pandas series and fill NaN with the average of the next numerical value where: average = next numerical value / (# consecutive N...
(1) odpowiedzi
2017-04-19 23:04 How to get source code of function that is wrapped by a decorator? »
I wanted to print the source code for my_func, that is wrapped by my_decorator, import inspect from functools import wraps def my_decorator(some_fun...
(2) odpowiedzi
2017-04-19 18:04 Python € in filename »
I need to be able to read or rename a file that contains the character: €. This character has a random position that I get with a. How can I do it? ...
(2) odpowiedzi
2017-04-19 16:04 Using multiple custom classes with Pipeline sklearn (Python) »
I try to do a tutorial on Pipeline for students but I block. I'm not an expert but I'm trying to improve. So thank you for your indulgence. In fact, I...
(1) odpowiedzi
2017-04-19 16:04 How to access pk in views (Django) »
I'm writing a small chat programm in Django but have problems getting any further. Here's the code: models.py from django.db import models from dat...
(2) odpowiedzi
2017-04-19 12:04 Django sum all related objects of a filtered QuerySet »
What I would like to do in psuedo code is: def import_transaction_deposit_crypto(Importer): logger = get_nexchange_logger(__name__, True, True) ...
(2) odpowiedzi
2017-04-19 11:04 Apply function to elements of dataframe »
Suppose I have the following dataframe df 1 3 Scenario1 0.001 0.05 Scenario2 0.003 0.01 Scenario3 0.001 0.042 Scenario4 ...
(2) odpowiedzi
2017-04-19 08:04 What is python .. ("dot dot") notation syntax? »
I recently came across a syntax I never seen before when I learned python nor in most tutorials, the .. notation, it looks something like this: f = 1...
(4) odpowiedzi
2017-04-19 00:04 format value that could be number and/or string in python 3 »
Is there a concise way of formatting a number, that on occasion can also be a string? The number would normally be a float, but occasionally it's als...
(3) odpowiedzi
2017-04-18 23:04 How to modify full text of some columns in pandas »
I got a fairly big dataframe from a csv in pandas. The problem is that on some columns I get strings of text which I would like to isolate the last c...
(2) odpowiedzi
2017-04-18 22:04 Using PrettyTable, Can I write a function that will take inputs and add them into a table so I don't have to continuously repeat myself? »
I made a multiplication table, but I had to manually type out the code to add to my table. I want to write a loop that does it for me so the multiplic...
(1) odpowiedzi
2017-04-18 21:04 Pandas: return number of occurrences by date »
Assume I have the following DataFrame dic = {"Date": ["04-Jan-16", "04-Jan-16", "04-Jan-16", "05-Jan-16", "05-Jan-16"], "Col": ['A', 'A', 'B'...
(2) odpowiedzi
2017-04-18 20:04 Two operations in accumulate »
I tried to convert the following loop into a accumulate() call but i despicably failed: total = 0 for h in heat_values: total += h total -= t...
(3) odpowiedzi
2017-04-18 18:04 Find common elements that are in the same order in two lists Python »
Just have a quick question about python. I was wondering if there was any simple pythonic way to take two list such as: a = ['t', 'o', 'a', 'c'] b = ...
(1) odpowiedzi
2017-04-18 14:04 Django project using python 2.7 even though interpretor points to python version 3.5 »
My project interpretor points to python version 3.5.2: (/Library/Frameworks/Python.framework/Versions/3.5/bin/python3.5) However when I go to the py...
(1) odpowiedzi
2017-04-18 11:04 Efficiently compute the mean bits of many bitstrings in python / numpy? »
I have a few thousand bitstrings stored as longs. Each bitstring is 1024 bits. I would like to create an array of the ratios each bit is 1. For examp...
(2) odpowiedzi
2017-04-18 09:04 Check if all elements are True in sliding windows across a 2D array - Python »
I have a multidimensional numpy array where the elements are either True or False values: import numpy as np #just making a toy array grid to show ...
(1) odpowiedzi
2017-04-18 09:04 optimized way of passing a form in all view functions django »
I have a form which is needed in all the view functions of my django project. I have a common template for printing the form but for this I have to ...
(2) odpowiedzi