I mostly write about programming in Python (and sometimes, Julia) for Data Visualization and Data Science but occasionally I stray into other areas of science and technology.

If you’d like to know when I publish new articles, please consider subscribing to my free, occasional, newsletter here.

Data Visualization and Data Science


Using SQLite to store your Pandas dataframes gives you a persistent store and a way of easily selecting and filtering your data

Photo by Markus Winkler on Unsplash

The SQLite database is a built-in feature of Python and a very useful one, at that. It is not a complete implementation of SQL but it has all the features that you need for a personal database or even a backend for a data-driven web site.

Using it with Pandas is simple and really useful. You can permanently store your dataframes in a table and read them directly into a new dataframe as you need them.

But it isn’t just the storage aspect that is so useful. …

Data Visualization

Why use Dash when Plotly plus Flask is easy and more flexible

A multi-page web app using Plotly and Flask — image by author

Why would you want to write HTML in Python? It baffles me. But that is what you need to do if you want to write a Dash app.

While I understand that there is a certain amount of satisfaction in having all your code in a single file, it seems to me that if you know enough about HTML to code it in a different language then you certainly know enough to write it in HTML!

I’d love for Dash to be the solution to writing web visualization apps but I’m not convinced.

Consider the following:

This is a brief introduction to creating and running a Flask app, the use of HTML templates and how to create multi-page web apps using Flask routes.

The Flask logo — Copyright 2010 Pallets, used with permission

Flask is a web application micro-framework which means it is a very lightweight library for developing web apps. Creating your first Flask app is easy but first you will need to install it with pip or conda, for example:

pip3 install flask

Next, open a new directory and create a file app.py with the following code:

from flask import Flaskapp = Flask(__name__)@app.route(‘/’)
def root():
return “Hello”

The code is pretty straightforward. The first line imports the Flask library; the second creates a Flask object (that will be run); and the rest of it defines a route. A route…

Citizen Science

There may be an asteroid heading our way — you could help find it. There may be potential treatments for Aids, Covid-19 or cancer — you could help identify them.

NASA’s OSIRIS-REx spacecraft studies asteroids — image courtesy of NASA

When Buzz Aldrin guided himself, and Neil Armstrong, to the surface of the moon on July, 20th, 1969, he was aided by a computer that was the first such device built with integrated circuits and, unsurprisingly, was the state of the art at the time.

That was over 50 years ago, so of course, you would expect computers to have got better. But how much? Ten times more powerful, 100 times, a 1000 times, perhaps. Maybe you’d be surprised to know that the smartphone in your pocket is 100,000 times more powerful than Aldrin’s computer.

Having a phone that is…

The AI that famously created an image of AOC in a bikini was behaving inappropriately but rationally

If you believe the AI that created male and female images from pictures of their heads, men typically wear suits, while women prefer low-cut tops and bikinis.

It’s been reported in the press that this is evidence that the future of AI is sexist. The argument being that because the internet is awash with pictures of scantily-clad females, AI will assume that this is normal.

A fair point? Not necessarily — the whole point of this research was to demonstrate the danger of inheriting biases from data that has been collected from human activity.

The experiment used the ImageNet library…

Customize your Pandas plots with off-the shelf style sheets - or design your own

mathplotlib styles — image by author

Web sites, publications and news sources all have their own styles. Take a look at the financial data published by, say, the BBC or The NewYork Times. Or polling data on Nate Silver’s FiveThirtyEight web site. They each have a clear and consistent look.

We are going to look at how we can achieve something similar with our Pandas charts and plots. First, by using the built-in styles that are available to us and then by looking at how we can create our own customizations.

The default style renders a line graph like the image, below. It’s a clean looking…

Don’t throw away that computer that’s too old to run Windows

The Raspberry Pi desktop — image by author

I hate throwing things away — especially if they still work. There are ways to dispose of old technology in an environmentally friendly way, but giving it a new lease on life is more fun.

Chances are that you have at least one old laptop or PC lying around, unused, in a cupboard or drawer. Maybe they used to run Windows Vista or even XP, and they don’t have the oomph for a modern operating system like Windows 10 or Unbuntu. They probably even struggle with running the original software they came packaged with.

So why don’t we fix them…

Data Visualization

Google Charts lets you create pleasing interactive plots but cannot read a Pandas dataframe directly. Here we create a simple Python Web App to combine the two technologies.

Image by author

Google Charts have been around for more years than I care to remember, so I think we can safely assume that it is a mature and stable technology.

It can also be used to create attractive charts and graphs.

How to analyse the sentiment of tweets using the VADER Python library

Photo by Chris Liverani on Unsplash

Sentiment Analysis, or Opinion Mining, is often used by marketing departments to monitor customer satisfaction with a service, product or brand when a large volume of feedback is obtained through social media.

Gone are the days of reading individual letters sent by post. Today’s customers produce vast numbers of comments on Twitter or other social media.

Such a large amount of data cannot be reasonably analysed individually, so what is produced electronically has to be analysed electronically.

There are two fundamental Sentiment Analysis solutions: first, there are rule based systems that use a lexicon of words and rules to classify…

Alan Jones

Technology, science and programming. Subscribe to my newsletter here: https://technofile.substack.com/ . Web page: https://alanjones.pythonanywhere.com/

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store