Skip to content

Commit 741edac

Browse files
committed
docs
1 parent 886fdc7 commit 741edac

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

doc/source/whatsnew/v0.24.0.txt

+48
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,54 @@ v0.24.0
88
New features
99
~~~~~~~~~~~~
1010

11+
Integer NA Support
12+
^^^^^^^^^^^^^^^^^^
13+
14+
TODO(update docs)
15+
Pandas has gained the ability to hold integer dtypes with missing values. This long requested feature is enable thru the use of ``ExtensionTypes`` . Here is an example of usage.
16+
17+
We can construct a ``Series`` with the specified dtype. The dtype string ``Int64`` is a pandas ``ExtensionDtype``. Specifying an list or array using the traditional missing value
18+
marker of ``np.nan`` will infer to integer dtype. The display of the ``Series`` will also use the ``NaN`` to indicate missing values in string outputs.
19+
20+
.. ipython:: python
21+
22+
s = pd.Series([1, 2, np.nan], dtype='Int64')
23+
s
24+
25+
26+
Operations on these dtypes will propagate ``NaN`` as other pandas operations.
27+
28+
.. ipython:: python
29+
30+
# arithmetic
31+
s + 1
32+
33+
# comparison
34+
s == 1
35+
36+
# indexing
37+
s.iloc[1:3]
38+
39+
# operate with other dtypes
40+
s + s.iloc[1:3]
41+
42+
These dtypes can operate as part of ``DataFrames`` as well.
43+
44+
.. ipython:: python
45+
46+
df = pd.DataFrame({'A': s, 'B': [1, 2, 3], 'C': list('aab')})
47+
df
48+
df.dtypes
49+
50+
51+
These dtypes can be merged & reshaped & casted as well.
52+
53+
.. ipython:: python
54+
55+
pd.concat([df[['A']], df[['B', 'C']]], axis=1).dtypes
56+
df['A'].astype(float)
57+
58+
1159
.. _whatsnew_0240.enhancements.other:
1260

1361
Other Enhancements

pandas/tests/extension/integer/test_integer.py

+9
Original file line numberDiff line numberDiff line change
@@ -412,3 +412,12 @@ def test_cross_type_arithmetic():
412412
result = df.A + df.B
413413
expected = pd.Series([2, np.nan, np.nan], dtype='Int64')
414414
tm.assert_series_equal(result, expected)
415+
416+
417+
# TODO(jreback) - these need testing / are broken
418+
419+
# groupby
420+
421+
# shift
422+
423+
# set_index (destroys type)

0 commit comments

Comments
 (0)