SQLAlchemy e pandas per la visualizzazione

Introduzione ai database in Python

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

SQLAlchemy e pandas

  • DataFrame può accettare un ResultSet di SQLAlchemy
  • Imposta le colonne del DataFrame alle chiavi del ResultSet
Introduzione ai database in Python

Esempio di DataFrame

import pandas as pd

df = pd.DataFrame(results)
df.columns = results[0].keys()
print(df)
    sex  pop2008_sum
0     F      2105442
1     F      2087705
2     F      2037280
3     F      2012742
4     F      2014825
5     F      1991082
Introduzione ai database in Python

Creare grafici

  • Possiamo fare grafici come al solito
Introduzione ai database in Python

Esempio di grafico

import matplotlib.pyplot as plt
df[10:20].plot.barh()
plt.show()

Grafico a barre orizzontali

Introduzione ai database in Python

Let's practice!

Introduzione ai database in Python

Preparing Video For Download...