I am already able to code almost anything with Python and, thanks to Eclipse and PyDev, debug it. I have already done quite a few cool scripts for some data analysis projects I am working on – I like to work on and learn different things every once in a while so I take quick breaks from my pure wireless/communications work -. But every now and then I find something about Python that is… intriguing.

I have a love-hate feeling with the whole “list of lists” thing. It is very useful because I can have an “array” where one column is an int, another one a string, another one a foat, etc. So this is a clear improvement with respect to Matlab. However, having to address the 1th row – 2nd column a[0][1] is a bit annoying and a[0,1] would be more intuitive…

Anyhow, I just found out that (and, please, correct me if I am wrong), given that everything is a list of a list, I cannot extract one entire column of an array. For example:

a = [[1,2,3],[4,5,6],[7,8,9]]

a[0][:] returns [1,2,3], which makes sense.

a[:][0] returns [1,2,3], which does NOT make sense.

So, it seems there is no way to get one column of a matrix. Quite annoying. I am getting it done by doing this: column_o = [column_o for col in a] (but this is basically iterating the entire list and copying each 0th element to a new list).

Aaaaand this was my geeky post for the day. Have a good one!

Advertisements