Data dodania Pytanie
2017-04-11 02:04 Vectorizing min and max of slices possible? »
Suppose that I have a NumPy array of integers. arr = np.random.randint(0, 1000, 1000) And I have two arrays lower and upper, which represent lower...
(3) odpowiedzi
2017-04-10 21:04 Multiple arguments with values to custom management command »
How do I pass multiple arguments with values, from command line, to a custom django management command? def add_arguments(self, parser): parser.a...
(1) odpowiedzi
2017-04-10 21:04 pandas apply using min/max executes slowly over variable rolling window »
I'm calculating values over a time series (represented through myvalues). The code below identifies the locations where an event happens (cross_indice...
(1) odpowiedzi
2017-04-10 20:04 Can the use of * to dump excess return in parallel assignment be made compatible in Python 2.x? »
Python 3.x allows dumping excess return in a parallel assignment with * >>> a, b, *args = range(4) >>> a 0 >>> b 1 >&gt...
(3) odpowiedzi
2017-04-10 19:04 Ordering queryset by filtered child objects »
I have the following (simplified) data model, see visual representation below the post: Articles, which have Attributes Attributes refer by PK to a ...
(0) odpowiedzi
2017-04-10 16:04 How to avoid import-time database access in Django? »
My Django app has a number of categories for things which I store in a Category model. I reference these frequently in code, and so I've found it usef...
(2) odpowiedzi
2017-04-10 15:04 Python matplotlib colorbar scientific notation base »
I am trying to customise a colorbar on my matpllotlib contourf plots. Whilst I am able to use scientific notation I am trying to change the base of th...
(2) odpowiedzi
2017-04-10 00:04 Performance is slow when replacing a string in a pandas dataframe using a dict »
The following code works but needs to run faster. The dict has ~25K keys and the dataframe is ~3M rows. Is there a way to produce the same results but...
(3) odpowiedzi
2017-04-10 00:04 Long pandas logic operation »
Is there a better way to write this long pandas logic operation? I only listed a few examples below but actually have a lot more checks. This does the...
(2) odpowiedzi
2017-04-09 23:04 Django objects.all() doesn`t display any content »
Hi everybody! Im just starting a way of django programming so sometimes really get confused. I`m trying to display all my objects from DB, but when o...
(1) odpowiedzi
2017-04-09 20:04 How do I use the django-cms Python api to create a page? »
I'm trying to write a CMS content migration script that will create our pages for django-cms. However even with the default install of Django-cms, Dj...
(2) odpowiedzi
2017-04-09 13:04 Django, serving static files with nGinx gives error 404 »
I can't serve static files through nGinx and I am getting 404 instead. I can see the error (shown in the error.log), I just can't see how to fix it. ...
(1) odpowiedzi
2017-04-09 12:04 How to convert nested dictionary to dataframe? »
I've got a nested dictionary. It's some Nasdaq kind of data. Like this: {'CLSN': Date Open High Low Close Volume Adj Close ...
(2) odpowiedzi
2017-04-09 09:04 Some characters stick to my colorized prompt in Python cmd »
I am using Python 2's cmd module to make a command line for a program. Everything works nicely as long as I don't add color to my prompt. Working co...
(1) odpowiedzi
2017-04-09 04:04 Using lambda functions to sum digits and count digits »
How can I convert these two functions to use lambda notation? def sum_digits(number): if number == 0: return 0 else: return (...
(3) odpowiedzi
2017-04-09 02:04 Comparing values of two dicts in Python »
I have 2 dictionaries: budgets = {'Engineering': 4500.0, 'Marketing': 5000.0, 'Operations': 3000.0, 'Sales': 2000.0} spending = {'Engineering': ...
(4) odpowiedzi
2017-04-09 01:04 longest time lazy flappy bird can survive - consecutive gap between 2 arrays »
given two arrays: import numpy as np L1 = np.array([3, 1, 4, 2, 3, 1]) L2 = np.array([4, 8, 9, 5, 6, 7]) I want to efficiently find the longest con...
(1) odpowiedzi
2017-04-08 18:04 Modifying timestamps in pandas to make index unique »
I'm working with financial data, which is recorded at irregular intervals. Some of the timestamps are duplicates, which is making analysis tricky. Thi...
(3) odpowiedzi
2017-04-08 15:04 Python , variable store in memory »
a=[1234,1234] #list a [1234, 1234] id(a[0]) 38032480 id(a[1]) 38032480 b=1234 #b is a variable of integer type id(b) 380...
(4) odpowiedzi
2017-04-08 15:04 Code optimization python »
I wrote the below function to estimate the orientation from a 3 axes accelerometer signal (X,Y,Z) X.shape Out[4]: (180000L,) Y.shape Out[4]: (180000L...
(1) odpowiedzi
2017-04-08 14:04 Django form is adding characters when I am editing details »
Here is how my form is set up (all the fields are the same): class AddColourForm(forms.Form): colour = forms.CharField( widget=TextInput...
(1) odpowiedzi
2017-04-08 13:04 Error calling BashOperator: Bash command failed »
Here are my dag file and BashOperator task: my_dag = { dag_id = 'my_dag', start_date = datetime(year=2017, month=3, day=28), schedule_interval='01**...
(1) odpowiedzi
2017-04-08 02:04 Need to extract the first letter of each item in a queryset and pass it to template »
I am passing the variable "first_letter" to a view and want to compare this letter to the first letter of each item returned from a query. I can't get...
(1) odpowiedzi
2017-04-08 00:04 Python: Dictionaries and how they are stored and accessed with iteritems() »
I wanted to clarify some points about dictionaries in Python, which may help some other Python enthusiasts in the future. Let's start with a simple d...
(2) odpowiedzi
2017-04-07 18:04 Python login script to CSRF protected web site »
I am trying to create simple login script to rol.redhat.com web site. Here is my example: import sys import requests URL = 'https://rol.redhat.com/r...
(0) odpowiedzi
2017-04-07 17:04 how to iterate on xml nodes (both elements and text nodes) in python2 etree »
I have a xml, in where an element contains multiple text nodes. Using python2 etree, I want to navigate the tree with the same order. So, for this in...
(1) odpowiedzi
2017-04-07 16:04 Sort multidimensional NumPy array by norm over a dimension »
I am working with a multidimensional NumPy array a which is a "vector" of say 2x2 matrices. I want to sort a such that the 2x2 matrices are sorted by ...
(2) odpowiedzi
2017-04-07 16:04 Distinct values from an ARRAY column »
I'm using PostgreSQL's ARRAY to store tags for images. How can I write an ORM query in SQLAlchemy, which returns the set of all tags found in the tab...
(1) odpowiedzi
2017-04-07 14:04 How do relative imports work? »
I have a directory structure like this project/ __init__.py greetings.py script.py greetings.py def hello(): print('He...
(2) odpowiedzi
2017-04-07 12:04 How to write multiple signature hints in PyCharm with Python3 »
I written a function with an argument on the left, just similar like the built-in range function The problem is, how to write type hints that can sho...
(1) odpowiedzi
2017-04-07 07:04 List of dict unique combination Python »
I have big data For the visualization purpose, This is the example list of dict as, Input : a = [{'e1': 'a','e2': 'b'}, {'e1': 'b','e2': 'a'}, {'e...
(2) odpowiedzi
2017-04-07 02:04 Unable to encode or decode the string properly »
I tried to look at bunch of stackoverflow examples. Python version used: Python 2.7.10 Output of the string s looked like u'bh\xfcghi' where \xfc=
(2) odpowiedzi
2017-04-06 22:04 PIL: DLL load failed: specified procedure could not be found »
I've been beginning to work with images in Python and I wanted to start using PIL (Pillow). To install it, I ran pip install Pillow. When installing, ...
(2) odpowiedzi
2017-04-06 12:04 Python joining list elements in a tricky way »
So, I have this list l = ['abc', 'retro', '', '', 'images', 'cool', '', 'end'] and, I want to join them in a way such as: l = ['abc retro', '', ''...
(5) odpowiedzi
2017-04-06 12:04 Django random sort list »
How I can sort rundom the list 'articles_list' when I get it from db? def article_theme(request, articleblock_id=2): return render_to_response('a...
(1) odpowiedzi