Getting Substring in Python

Python
I have a string fullstr = "my|name|is|will" , and i would like to extract the substring "name". I used string.find to find the first position of '|' l...
2 years ago

Getting value of specific key in a dictionary

Python
I have a dictionary like so: li = {'a': 'apple', 'b': 'benana', 'c': 'cherry'} So I have: >>> for key, value in li.items(): ... print...
2 years ago

Django csrf_token in ModelAdmin

Python
I want to add a form to the list display of my ModelAdmin, but can't get the csrf_token to render properly. I'm using django 1.6. My code looks like t...
2 years ago

What is the standard Python docstring format?

Python
I have seen a few different styles of writing docstrings in Python, is there an official or "agreed-upon" style?
2 years ago

Reading JSON file in Python and detecting specific keywords in field

Python
I just started this week to learn Python and I have the following question. I have a JSON file (Aberdeen2015.json) that contains 60 lines (each line c...
2 years ago

What does the yield keyword do in Python?

Python
What is the use of the yield keyword in Python? What does it do? For example, I'm trying to understand this code1: def node._get_child_candidates(se...
2 years ago

Working with Password Protected Excel Sheets in Python on Linux

Python
The problem is pretty simple. Every week I receive a bunch of password protected excel files. I have to parse through them and write certain parts to ...
2 years ago

Pandas groupby - apply different functions to half the records in each group

Python
I have something like the following dataframe, where I have non-unique combinations of street address ranges and street names. import pandas as pd df...
2 years ago

Numpy array indicing arrays

Python
I'm sure this question is Googleable, but I don't know what keywords to use. I'm curious about a specific case, but also about how to do it in general...
2 years ago

In python, how do I cast a class object to a dict

Python
Let's say I've got a simple class in python class Wharrgarbl(object): def __init__(self, a, b, c, sum, version='old'): self.a = a ...
2 years ago

Get Printer Status Code with win32print

Python
I have read the documentation of win32print which indicates that GetPrinter is the method which is used to obtain the status of the printer. However, ...
2 years ago

pandas: Is it possible to filter a dataframe with arbitrarily long boolean criteria?

Python
If you know exactly how you want to filter a dataframe, the solution is trivial: df[(df.A == 1) & (df.B == 1)] But what if you are accepting use...
2 years ago

How to plot the rolling mean of stock data?

Python
I was able to plot the data using the below code: import pandas as pd import numpy as np import matplotlib.pyplot as plt url = "http://real-chart.fi...
2 years ago

Python nested loop to identify characters in string of text

Python
I have a string of text that reads: 1x2xx1x2xx1x2xx1x2xxx I need to take apart the string of text, and if it is a number, i want to pass that numbe...
2 years ago

How to merge DataFrames with slightly different merge fields

Python
I'm trying to merge a set of DataFrames around a common timestamp for various assets. The data sets conatain hourly data, however the timestamp is sli...
2 years ago

How to pass a variablename to unix command in subprocess in python3

Python
I am trying to use unix diff command in subprocess , when I hardcode, it works fine, But I added it in a function where I need to pass these arguments...
2 years ago

Django Shell No module named settings

Python
I've deploy Django to Apache via mod_wsgi. Django is running fine when hosted from Apache. However, I'm trying to do some maintenance via manage.py, b...
2 years ago

How to recreate a sentence from the list of unique words and the position

Python
I am creating a program which recreates a sentence from it's unique words and the positions of them. So far I have managed to collect the unique wor...
2 years ago

Generate Python Class and SQLAlchemy code from XSD to store XML on Postgres

Python
I have some very complex XSD schemas to work with. By complex I mean that each of these XSD would correspont to about 20 classes / tables in a databas...
2 years ago

Python - Join Multiple Threads With Timeout

Python
I have multiple Process threads running and I'd like to join all of them together with a timeout parameter. I understand that if no timeout were neces...
2 years ago