Charts

Maps are a great data visualization tool, but sometimes a bar chart will do the trick. In this section, you will learn how to chart your data using pandas.DataFrame

A DataFrame stores two-dimensional tabular data (think of a spreadsheet). Data frames can be loaded with data from many different sources and data structures, but what interests us is that it can load data from SQL queries. 

The following code loads an SQL query into a DataFrame:

import pandas as pdd=datetime.datetime.strptime('2017101','%Y%m%d').date()cursor.execute("SELECT date, count(date) from incidents where date > '{}' group by date".format(str(d)))df=pd.DataFrame(cursor.fetchall(),columns=["date","count"])df.head()

The previous code selects the date, and then counts ...

Get Mastering Geospatial Analysis with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.