Overview
Pandas 1.4, released on January 23, 2022, adds multi-column apply and improves the Styler system for DataFrame formatting.
Main Features
Multi-column apply
The apply method now supports functions returning multiple columns more intuitively with result_type='expand'.
python
import pandas as pd
df = pd.DataFrame({'text': ['hello world', 'foo bar baz']})
# Apply returning multiple columns
result = df['text'].str.split(' ', expand=True)
result.columns = ['word1', 'word2', 'word3']
print(result)
# word1 word2 word3
# 0 hello world None
# 1 foo bar baz
Improved Styler
The Styler now supports new options such as tooltips, improved HTML export, and style concatenation.
python
import pandas as pd
df = pd.DataFrame({
'A': [1, 2, 3],
'B': [4, 5, 6],
})
styled = (
df.style
.highlight_max(color='lightgreen')
.highlight_min(color='lightcoral')
.set_caption('Styler 1.4 example')
)
# styled.to_html()
