From SQLAlchemy results to a plot
We can also take advantage of pandas and Matplotlib to build figures of our data. Remember that data visualization is essential for both exploratory data analysis and communication of your data!
Questo esercizio fa parte del corso
Introduction to Databases in Python
Istruzioni dell'esercizio
- Import
matplotlib.pyplotasplt. - Create a DataFrame
dfusingpd.DataFrame()on the providedresults. - Set the columns of the DataFrame
df.columnsto be the columns from the first result objectresults[0].keys(). - Print the DataFrame
df. - Use the
plot.bar()method ondfto create a bar plot of the results. - Display the plot with
plt.show().
Esercizio pratico interattivo
Prova a risolvere questo esercizio completando il codice di esempio.
# Import pyplot as plt from matplotlib
# Create a DataFrame from the results: df
df = ____
# Set Column names
df.columns = ____
# Print the DataFrame
# Plot the DataFrame