Version 0.17.1 (November 21, 2015) — pandas 2.2.3 documentation (original) (raw)

Note

We are proud to announce that pandas has become a sponsored project of the (NumFOCUS organization). This will help ensure the success of development of pandas as a world-class open-source project.

This is a minor bug-fix release from 0.17.0 and includes a large number of bug fixes along several new features, enhancements, and performance improvements. We recommend that all users upgrade to this version.

Highlights include:

What’s new in v0.17.1

New features#

Conditional HTML formatting#

Warning

This is a new feature and is under active development. We’ll be adding features an possibly making breaking changes in future releases. Feedback is welcome in GH 11610

We’ve added experimental support for conditional HTML formatting: the visual styling of a DataFrame based on the data. The styling is accomplished with HTML and CSS. Accesses the styler class with the pandas.DataFrame.style, attribute, an instance of Styler with your data attached.

Here’s a quick example:

In [1]: np.random.seed(123)

In [2]: df = pd.DataFrame(np.random.randn(10, 5), columns=list("abcde"))

In [3]: html = df.style.background_gradient(cmap="viridis", low=0.5)

We can render the HTML to get the following table.

| | a | b | c | d | e | | | --- | ---------- | ---------- | ---------- | ---------- | ---------- | | 0 | -1.085631 | 0.997345 | 0.282978 | -1.506295 | -0.5786 | | 1 | 1.651437 | -2.426679 | -0.428913 | 1.265936 | -0.86674 | | 2 | -0.678886 | -0.094709 | 1.49139 | -0.638902 | -0.443982 | | 3 | -0.434351 | 2.20593 | 2.186786 | 1.004054 | 0.386186 | | 4 | 0.737369 | 1.490732 | -0.935834 | 1.175829 | -1.253881 | | 5 | -0.637752 | 0.907105 | -1.428681 | -0.140069 | -0.861755 | | 6 | -0.255619 | -2.798589 | -1.771533 | -0.699877 | 0.927462 | | 7 | -0.173636 | 0.002846 | 0.688223 | -0.879536 | 0.283627 | | 8 | -0.805367 | -1.727669 | -0.3909 | 0.573806 | 0.338589 | | 9 | -0.01183 | 2.392365 | 0.412912 | 0.978736 | 2.238143 |

Styler interacts nicely with the Jupyter Notebook. See the documentation for more.

Enhancements#

shows the '+' as we have object dtypes

In [6]: df.info()
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000 entries, 0 to 999
Data columns (total 2 columns):

Column Non-Null Count Dtype


0 A 1000 non-null object
1 B 1000 non-null category
dtypes: category(1), object(1)
memory usage: 9.0+ KB

we have an accurate memory assessment (but can be expensive to compute this)

In [7]: df.info(memory_usage="deep")
<class 'pandas.core.frame.DataFrame'>
RangeIndex: 1000 entries, 0 to 999
Data columns (total 2 columns):

Column Non-Null Count Dtype


0 A 1000 non-null object
1 B 1000 non-null category
dtypes: category(1), object(1)
memory usage: 59.9 KB

1 True
2 False
3 False
Length: 4, dtype: bool
In [12]: date = pd.Series(pd.date_range("1/1/2015", periods=5)).astype("category")
In [13]: date
Out[13]:
0 2015-01-01
1 2015-01-02
2 2015-01-03
3 2015-01-04
4 2015-01-05
Length: 5, dtype: category
Categories (5, datetime64[ns]): [2015-01-01, 2015-01-02, 2015-01-03, 2015-01-04, 2015-01-05]
In [14]: date.dt.day
Out[14]:
0 1
1 2
2 3
3 4
4 5
Length: 5, dtype: int32

API changes#

Deprecations#

Performance improvements#

Bug fixes#

Contributors#

A total of 63 people contributed patches to this release. People with a “+” by their names contributed a patch for the first time.