Pandas plots wrap Matplotlib: call df.plot() or series.plot() for quick line, bar, and histogram charts. The index becomes the x-axis by default.
Quick plots (conceptual)
import pandas as pd
import numpy as np
s = pd.Series([1, 3, 2, 5], index=['Jan','Feb','Mar','Apr'])
# s.plot(kind='bar') # requires matplotlib locally
print('Plot-ready Series:')
print(s)
Plot kinds
kind='line'— default time serieskind='bar'— categorical comparisonskind='hist'— distribution of one columnkind='scatter'— requires x and y columnsdf.plot.scatter(x='a', y='b')
Playground note
Matplotlib display may not render in the server runner—focus on preparing tidy Series/DataFrame inputs. Run plots locally with pip install matplotlib.
Important interview questions and answers
- Q: Why plot from Pandas?
A: Index labels auto-label axes; integrates with groupby results. - Q: Seaborn?
A: Statistical plots often accept DataFrames directly—built on Matplotlib.
Self-check
- What becomes the x-axis when plotting a Series?
- Name two plot kinds useful for EDA.
Tip: Tidy Series with meaningful index labels plot cleanly—run .plot() locally.
Interview prep
- Plot from Pandas?
Index auto-labels x-axis; quick EDA charts.
- Local matplotlib?
Install matplotlib locally—playground may not render plots.