Thomas' Plant-Related Blog

On plant science. Mostly.

Datat: Data tables for Python

leave a comment »

(A computery post today)

R is the up-and-coming thing for handling data. It’s a programming language, with a particular focus on statistics and graphs. For manipulating data before analysing it, however, I prefer Python. Code written in Python is (relatively) easy to read, and it can use a wide range of Python modules for all sorts of tasks, even for controlling R. But R has its strengths too, and one of them is the “data frame”, a table with columns of data that’s easy to use for statistics.

So, over the last few days, I’ve written Datat, a Python module for data tables. Although it’s quite different from R’s data frames, if you have the RPy2 module installed, a datat can be translated into a data frame. Using it works a bit like this:

from datat import Datat
temperaturerecords = Datat(["Date", "Min temp", "Max temp", "Notes"])
temperaturerecords.append({"Date":"9/10/11", "Min temp": 2.1, "Max temp": 13})
temperaturerecords.append({"Date":"10/10/11", "Min temp": -0.4,
                           "Notes":"Forgot some recordings"})
temp_rdataframe = temperaturerecords.translate_to_R()




Written by Thomas Kluyver

30 October, 2010 at 12:29 am

Posted in Computers

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: