Viewing posts by christian

The world's nuclear reactors over time

The Python program given below generates this stacked area plot of the number of nuclear reactors in different countries over the last six decades or so.

The Duffing Oscillator

The previous blog post described the motion of a quartic oscillator: a particle moving in the potential $V(x) = \frac{1}{4}x^4 - \frac{1}{2}x^2$. In this case, the motion was always periodic (since the particle's energy is conserved).

A quartic oscillator

Quartic Oscillator animation

Scraping a Wikipedia table with Pandas

In my previous post I gave a short script for scraping a particular Wikipedia page for some string-based data in one table. Then the internet had some advice for me. Use pandas.read_html they said. It will be easy, they said; everything will be handled for you, they said. Just clean, analyse and report.

Scraping a Wikipedia table with Beautiful Soup

The Beautiful Soup Python library is an excellent way to scrape web pages for their content. I recently wanted a reasonably accurate list of official (ISO 3166-1) two-letter codes for countries, but didn't want to pay CHF 38 for the official ISO document. The ISO 3166-1 alpha-2 contains this information in an HTML table which can be scraped quite easily as follows.