Visualizing dataΒΆ

matplotlib is able to produce meaningful data plots right in a notebook with little effort using Pandas DataFrames. This notebook covers a few of those capabilities.

# Load your dataframe
import pandas as pd
csv_url = "https://raw.githubusercontent.com/paiml/wine-ratings/main/wine-ratings.csv"
df = pd.read_csv(csv_url, index_col=0)
df.drop('grape', axis=1, inplace=True)
df = df.dropna()
df.head()

Setting up MatplotlibΒΆ

Import matplotlib and use the %matplotlib inline magic command (if needed) to render plots directly in the notebook. The Pandas .plot() method delegates to Matplotlib under the hood, so having it installed and configured is a prerequisite for any visualization.

!pip install matplotlib
df['rating'] = df['rating'].apply(lambda x: int(x))
df.plot()
df["variety"].plot()
df.plot.scatter(x="rating", y="variety", alpha=0.5)