SQLAlchemy a pandas pro vizualizaci

Introduction to Databases in Python

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

SQLAlchemy a pandas

  • DataFrame může přijmout ResultSet SQLAlchemy
  • Nastavte sloupce DataFrame na klíče ResultSet
Introduction to Databases in Python

Příklad 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
Introduction to Databases in Python

Tvorba grafů

  • Grafy lze vytvářet stejně jako obvykle
Introduction to Databases in Python

Příklad grafu

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

sloupcový graf

Introduction to Databases in Python

Pojďme si procvičit!

Introduction to Databases in Python

Preparing Video For Download...