Tag Archives: python

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

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

Profiling Python with valgrind

1. Under Linux, install valgrind as follows (Fedora): sudo yum install valgrind kcachegrindsudo yum install valgrind kcachegrind and pyprof2calltree: pip install pyprof2calltreepip install pyprof2calltree 2. create a Python script (let us call it run.py) 3. Create the file containing the … Continue reading

Posted in Python | Tagged , | 1 Comment

Python: Error: new-line character – how to open the file in universal-newline mode ?

I was playing with the CSV module from the Python standard library. Typically using a code such as: import csv import zipfile zip = zipfile.ZipFile("file.zip") zipdata = zip.open("ExistingFile.csv") data_iter = csv.reader(zipdata, delimiter=",") data_iter.next() import csv import zipfile zip = zipfile.ZipFile("file.zip") … Continue reading

Posted in Python | Tagged | Leave a comment

Python: list of empty lists creates references not copy

In Python, you can create a list with an element repeated N times quite easily with the following syntax: >>> a = [1] * 5 >>> print(a) [1,1,1,1,1] >>> a = [1] * 5 >>> print(a) [1,1,1,1,1] Here we create … Continue reading

Posted in Python | Tagged | Leave a comment

Accessing Life Science Web Services from Python

In a previous post, I started to discuss about Web Services in Life Science and what a maze it is to navigate between them. Some Web Services provides Python code to access to their databases but not all of them. … Continue reading

Posted in biology, Life Science | Tagged , , , , | Leave a comment

Python: pip installation

References: http://www.pip-installer.org/en/latest/installing.html The installation of pip depends on your system. For instance under ubuntu it is as easy as sudo apt-get install python-pipsudo apt-get install python-pip Another way to install it if you are familiar with virtualenv tool consists in … Continue reading

Posted in Linux, Python | Tagged , | Leave a comment

Python header

This post is about what to put on top of your Python script. You may have seen Python script starting with something like: #!/usr/local/bin/python # coding: latin-1#!/usr/local/bin/python # coding: latin-1 and wonder what it is useful for or do you … Continue reading

Posted in Python | Tagged | Leave a comment

Raspberry pi: first steps

My first raspberry pi arrived !! I pluged in a USB mouse and keyboard, the SD card I bought at the same time (it has already a linux system on it), a hdmi cable to the first screen I found … Continue reading

Posted in raspberryPi | Tagged | Leave a comment

How use R to build permutation or combination

In a previous post, I used itertools in Python to create combination and permutation using the standard module itertools. What about using R language to perform the same task. The permutation function allows you to get permutation of N values … Continue reading

Posted in Python, R | Tagged , | Leave a comment