Tag Archives: python

Can I use unittest.mock in python?

A question I would like to answer. Perhaps this is the place to start: https://docs.python.org/3/library/unittest.mock.html

Comments Off on Can I use unittest.mock in python?

Filed under software engineering

Two ways to do categorical data in Python

Pandas has it: http://pandas-docs.github.io/pandas-docs-travis/categorical.html

Python has it, too: https://docs.python.org/3/library/enum.html

Will this make my life easier?

Comments Off on Two ways to do categorical data in Python

Filed under software engineering

Scientific Constants

A fun pointer I picked up at the eScience institute recently is where to find constants in python: scipy.constants http://docs.scipy.org/doc/scipy/reference/constants.html

or, if you fancy units, astropy.constants http://docs.astropy.org/en/stable/constants/index.html

Comments Off on Scientific Constants

Filed under disease modeling

What style should I use for my docstrings?

The numpy docstring style should be just fine: http://sphinxcontrib-napoleon.readthedocs.org/en/latest/example_numpy.html

Comments Off on What style should I use for my docstrings?

Filed under software engineering

SciPy2014 Plotting Contest

I helped judge a plotting contest for the Scientific Python conference last summer. Who won? I don’t know, and a short web searching binge didn’t find out. A lovely plot took 3rd place, and every entry is here (with sourcecode). Good stuff for seeing how different groups do different tricks, and for checking what still doesn’t work in mpld3.

Comments Off on SciPy2014 Plotting Contest

Filed under dataviz

Styling Excel with Pandas

I had a bunch of stylish tables to make once long ago, and I thought, “why don’t I do that automatically?” It would take longer the first time, but it would be faster in future iterations. Unfortunately, there never were any future iterations, but fortunately, it was more fun to research automatic generation of stylish tables than do what I needed to get done.

The seeds I planted have started to sprout a little bit, though, and the latest pandas now supports openpyxl2 which supports a lot of style. So here is a start on the stylish table writing feature.

Comments Off on Styling Excel with Pandas

Filed under software engineering

Python Pandas Intros

I’m going to give a Python Pandas guest lecture in the Python Science class next week, and I thought I’d take a look at the Pandas intros that are out there. There are a lot now! Here are some that I flipped through:



Its fun being a teacher in the age of information.


Filed under education