Skip to content

Commit fddbb2e

Browse files
committed
Updates after review
DataFrame.astype now allows changing the dtype of a column by passing a dict mapping column name to dtype.
1 parent 49e3137 commit fddbb2e

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

doc/source/basics.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1779,6 +1779,18 @@ Convert a subset of columns to a specified type using :meth:`~DataFrame.astype`
17791779
dft.loc[:, ['a', 'b']] = dft.loc[:, ['a', 'b']].astype(np.uint8)
17801780
dft.dtypes
17811781
1782+
1783+
.. versionadded:: 0.19
1784+
1785+
Convert certain columns to a specific dtype by passing a dict to :meth:`~DataFrame.astype`
1786+
1787+
.. ipython:: python
1788+
1789+
dft1 = pd.DataFrame({'a': [1,0,1], 'b': [4,5,6], 'c': [7, 8, 9]})
1790+
dft1 = dft1.astype({'a': np.bool, 'c': np.float64})
1791+
dft1
1792+
dft1.dtypes
1793+
17821794
.. _basics.object_conversion:
17831795

17841796
object conversion

0 commit comments

Comments
 (0)