Tag Archives: Python

Prototyping PL/Python functions

I’ve seen a variable called numerical intensity crop up in a couple of papers recently (one example is Lundholm, Rogo, and Zhang (2014)). I spent a little time coming up with a Python program to extract numbers from text. Once … Continue reading

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

Get “tone” from corporate disclosures: PostgreSQL, Python, and R.

The paper by Loughran and McDonald (2011) develops lists of words that are intended to reflect “tone” in financial text. The following code retrieves these lists and applies them to a large body of text (over a billion words) from … Continue reading

Posted in Uncategorized | Tagged , , , , , , , | 4 Comments

Using JSON to pass dictionaries from Python to PostgreSQL and back

To my (very untrained) eyes, JSON looks like Python dictionaries. I’d wondered if one could use JSON to pass around Python dictionaries. Turns out that it works quite well. Task Get the top N words from passages of text (conference … Continue reading

Posted in PostgreSQL, Python | Tagged , , , , | 1 Comment

Installing Python

I use MacPorts to install my basic python set-up as follows: Then it’s just a matter of typing:

Posted in Mac, Python | Tagged | Leave a comment

RPostgreSQL (R) versus psycopg (Python)

Here’s a rather simplistic comparison of the performance of R and Python in getting data from PostgreSQL. R: Time taken: 26-27 seconds. Python: Time taken: Around 6 seconds. I’m impressed. I’ve never really been bothered by performance in getting data … Continue reading

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