Skip to content

Commit 1545734

Browse files
committed
DOC: fixups
1 parent 6f175a7 commit 1545734

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

doc/source/io.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,8 @@ that column's ``dtype``.
485485
When using ``dtype=CategoricalDtype``, "unexpected" values outside of
486486
``dtype.categories`` are treated as missing values.
487487

488+
.. ipython:: python
489+
488490
dtype = CategoricalDtype(['a', 'b', 'd']) # No 'c'
489491
pd.read_csv(StringIO(data), dtype={'col1': dtype}).col1
490492

doc/source/whatsnew/v0.21.0.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -134,9 +134,12 @@ One place that deserves special mention is in :meth:`read_csv`. Previously, with
134134
be strings.
135135

136136
.. ipython:: python
137+
:suppress:
137138

138139
from pandas.compat import StringIO
139140

141+
.. ipython:: python
142+
140143
data = 'A,B\na,1\nb,2\nc,3'
141144
pd.read_csv(StringIO(data), dtype={'B': 'category'}).B.cat.categories
142145

@@ -151,11 +154,12 @@ timedeltas, we can automatically convert to the correct type
151154
The values have been correctly interpreted as integers.
152155

153156
The ``.dtype`` property of a ``Categorical``, ``CategoricalIndex`` or a
154-
``Series`` with categorical type will now return an instance of ``CategoricalDtype``.
155-
For the most part, this is backwards compatible, though the string repr has changed.
156-
If you were previously using ``str(s.dtype == 'category')`` to detect categorical data,
157-
switch to :func:`api.types.is_categorical_dtype`, which is compatible with the old and
158-
new ``CategoricalDtype``.
157+
``Series`` with categorical type will now return an instance of
158+
``CategoricalDtype``. For the most part, this is backwards compatible, though
159+
the string repr has changed. If you were previously using ``str(s.dtype) ==
160+
'category'`` to detect categorical data, switch to
161+
:func:`pandas.api.types.is_categorical_dtype`, which is compatible with the old
162+
and new ``CategoricalDtype``.
159163

160164
See the :ref:`CategoricalDtype docs <categorical.categoricaldtype>` for more.
161165

0 commit comments

Comments
 (0)