Author Archives: Thomas Cokelaer

pandas.read_csv: how to skip empty lines

Let us suppose that we start with a CSV file that has empty rows: A, B, C   1, 2, 3A, B, C 1, 2, 3 If you read this file with Pandas library, and look at the content of … Continue reading

Posted in Python | Tagged | 2 Comments

ipython notebook and matplotlib

In order to have the plots to be shown within a ipython notebook, you should include the following code at the beginning. %pylab inline%pylab inline Images may be tiny. You can set the size by playing with the matplotlib configuration … Continue reading

Posted in Python | Tagged , | Leave a comment

Python : How to flush output of print

Using the sys module, just type: import sys sys.stdout.flush()import sys sys.stdout.flush()

Posted in Python | Tagged | Leave a comment

python argparse issues with the help argument (TypeError: %o format: a number is required, not dict)

Even though Python has a great documentation, once in a while you get stuck on a single problem more than expected. It happenned to me today with the argparse module, which I thought I knew enough to quickly code a … Continue reading

Posted in Python | Tagged | 36 Comments

Fourier transformation explained

I love the following image found in this blog.

Posted in Data analysis | Tagged | 1 Comment

Pandas dataframe: grouping column by name

Let us consider this data set in CSV format: DIG1, DIG1, DIG1, DIG2 1, 3, 5, 8 2, 4, 6, 9 3, 5, 7, 10DIG1, DIG1, DIG1, DIG2 1, 3, 5, 8 2, 4, 6, 9 3, 5, 7, 10 … Continue reading

Posted in Python | Tagged | 5 Comments

Starting to use Python Pandas library

Pandas is brilliant. If you are looking to manipulate data in Python, use it. I am refactoring most of my codes with this library. It provides many useful data structures to manipulate data in 2, 3, 4 dimensions and more. … Continue reading

Posted in Python | Tagged , | Leave a comment

Reading Nikkon Raw image with Gimp plugin UFRaw

I recently started to play with RAW images on a Nikkon camera. The first issue was that gimp could open the images but only in a kind of thumbnail version. Browsing around it looks like one tool to read the … Continue reading

Posted in photos | Tagged | Leave a comment

pandas import fails with ImportError: cannot import name hashtable

Import of pandas raises the following error: ImportError: cannot import name hashtableImportError: cannot import name hashtable Starting a python session, I typed from pandas import hastablefrom pandas import hastable and got this new message: ImportError: cannot import name hashtableImportError: cannot … Continue reading

Posted in Python | Tagged | Leave a comment

Line starting ‘ …’ is malformed! error

Playing with a Python wrapper of an R package, I suddenly got this error after a trivial change of the code: Line starting ‘<!DOCTYPE html> …’ is malformed!Line starting ‘<!DOCTYPE html> …’ is malformed! Wondering for a couple of minutes … Continue reading

Posted in R | Tagged , , | Leave a comment