Overview

Pandas 1.2, released on January 2, 2021, introduces the nullable FloatingDtype and improves the DataFrame styling system.

Main Features

Nullable FloatDtype

The new Float32Dtype / Float64Dtype stores floating-point values with explicit missing values (pd.NA) instead of NaN. This unifies missing-value handling with the nullable integer types already available.

python
import pandas as pd
import numpy as np

# Old behaviour: NaN forces float64
s_old = pd.Series([1.0, None, 3.0])
print(s_old.dtype)  # float64
print(s_old[1])    # nan

# New: FloatingDtype with pd.NA
s_new = pd.array([1.0, None, 3.0], dtype=pd.Float64Dtype())
print(s_new.dtype)  # Float64
print(s_new[1])    # <NA>
print(s_new.sum())  # 4.0 (NA properly ignored)

Improved Styler

The Styler system has been overhauled to produce cleaner HTML and support new formatting options: gradients, data bars, and LaTeX export.

python
import pandas as pd

df = pd.DataFrame({
    'product': ['A', 'B', 'C'],
    'sales': [120, 340, 210],
    'margin': [0.15, 0.32, 0.08],
})

# Conditional formatting
styled = (
    df.style
    .bar(subset=['sales'], color='#5fba7d')
    .format({'margin': '{:.0%}'})
    .set_caption('Sales summary')
)
# styled.to_html() for HTML export
# styled.to_latex() for LaTeX export (new)

Sources