LambdaLab
Informatics Practices · Class 12 · Python Pandas · Series
PandasSeries⏱️ 7 min read

Data Types & Missing Data

Every Series has a single data type for all its values, and Pandas figures it out for you. Understanding that — and how a single missing value can change it — saves a lot of confusion later.

1The dtype of a Series

The dtype simply tells you what kind of data is inside. Pandas sets it automatically by looking at your values:

  • 🔢 Whole numbers → int64
  • 💧 Decimal numbers → float64
  • 🔤 Text (or a mix of types) → object
dtype detective

Pandas reads your data and picks the type automatically. Watch what a single missing value does.

010
125
230
345
Pandas infers
dtype: int64

All whole numbers → Pandas uses int64.

Note
A Series is homogeneous— one dtype for the whole column. That's different from a DataFrame, where each column can have its own dtype.

2NaN — how Pandas marks a missing number

NaN ("Not a Number") comes from the NumPy library and is the main way Pandas marks a missing value. Here's the twist you saw in the widget: put a NaN into a Series of whole numbers, and the entire Series becomes float64.

nan_cast.py
Watch Out
Any maths involving NaN also results in NaN — it "infects" the calculation. NaN is Pandas' way of saying "this value is unknown", and unknown + anything is still unknown.

3Using None instead of NaN

None is Python's general-purpose "nothing" value. When you drop None into a Series of numbers, Pandas helpfully converts it to NaN for you:

none_becomes_nan.py
Key Takeaway
Missing numbers show up as NaN. Whether you write np.nan or None, a numeric Series stores it as NaN and quietly upgrades itself to float64.
Quick Check

You create pd.Series([1, 2, np.nan, 4]). What is its dtype?

Quick Check

What happens to None inside a numeric Series?