ResultsSets and pandas DataFrames
We can feed a ResultSet directly into a pandas DataFrame, which is the workhorse of many Data Scientists in PythonLand. Jason demonstrated this in the video. In this exercise, you'll follow exactly the same approach to convert a ResultSet into a DataFrame.
Diese Übung ist Teil des Kurses
Introduction to Databases in Python
Anleitung zur Übung
- Import
pandasaspd. - Create a DataFrame
dfusingpd.DataFrame()on the ResultSetresults. - Set the columns of the DataFrame
df.columnsto be the columns from the first result objectresults[0].keys(). - Print the DataFrame.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
# import pandas
# Create a DataFrame from the results: df
df = ____
# Set column names
df.columns = ____
# Print the DataFrame
print(____)