Fix Python – Django TemplateDoesNotExist?

My local machine is running Python 2.5 and Nginx on Ubuntu 8.10, with Django builded from latest development trunk.
For every URL I request, it throws:

TemplateDoesNotExist at /appname/path appname/template_name.html
Django tried loading these templates, in this order:
* Using loader django.template.loaders.filesystem.function:
* Using loader….

Fix Python – Python 3.x rounding behavior

I was just re-reading What’s New In Python 3.0 and it states:

The round() function rounding strategy and return type have changed.
Exact halfway cases are now rounded to the nearest even result instead
of away from zero. (For example, round(2.5) now returns 2 rather than

the documentation for round:

For the built-in types supporti….

Fix Python – Find column whose name contains a specific string

I have a dataframe with column names, and I want to find the one that contains a certain string, but does not exactly match it. I’m searching for ‘spike’ in column names like ‘spike-2’, ‘hey spike’, ‘spiked-in’ (the ‘spike’ part is always continuous).
I want the column name to be returned as a string or a variable, so I access the column later wi….

Fix Python – Anaconda export Environment file

How can I make anaconda environment file which could be use on other computers?
I exported my anaconda python environment to YML using conda env export > environment.yml. The exported environment.yml contains this line prefix: /home/superdev/miniconda3/envs/juicyenv which maps to my anaconda’s location which will be different on other’s pcs.

Fix Python – What is a good practice to check if an environmental variable exists or not?

I want to check my environment for the existence of a variable, say “FOO”, in Python. For this purpose, I am using the os standard library. After reading the library’s documentation, I have figured out 2 ways to achieve my goal:
Method 1:
if “FOO” in os.environ:

Method 2:
if os.getenv(“FOO”) is not None:

I would like to know ….

Fix Python – How to replace NaNs by preceding or next values in pandas DataFrame?

Suppose I have a DataFrame with some NaNs:
>>> import pandas as pd
>>> df = pd.DataFrame([[1, 2, 3], [4, None, None], [None, None, 9]])
>>> df
0 1 2
0 1 2 3
1 4 NaN NaN
2 NaN NaN 9

What I need to do is replace every NaN with the first non-NaN value in the same column above it. It is assumed that the first row will never contain ….