SQLAlchemy și pandas pentru vizualizare

Introducere în baze de date în Python

Jason Myers

Co-Author of Essential SQLAlchemy and Software Engineer

SQLAlchemy și pandas

  • DataFrame poate accepta un ResultSet SQLAlchemy
  • Setați coloanele DataFrame la cheile ResultSet
Introducere în baze de date în Python

Exemplu 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
Introducere în baze de date în Python

Reprezentare grafică

  • Putem crea grafice ca de obicei
Introducere în baze de date în Python

Exemplu de reprezentare grafică

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

grafic cu bare.png

Introducere în baze de date în Python

Să exersăm!

Introducere în baze de date în Python

Preparing Video For Download...