Skip to content

Commit f394045

Browse files
committed
DOC: Cleaned up the documentation
1 parent 705e1a5 commit f394045

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

doc/source/basics.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -1726,13 +1726,13 @@ then the more *general* one will be used as the result of the operation.
17261726
# conversion of dtypes
17271727
df3.astype('float32').dtypes
17281728
1729-
When trying to convert a subset of columns to a specified type using :meth:`~DataFrame.astype` and :meth:`~numpy.ndarray.loc`, utilizing **:** as mask, upcasting occurs.
1730-
:meth:`~numpy.ndarray.loc` tries to fit in what we are assigning to the current dtypes, while [ ] will overwrite them taking the dtype from the right hand side.
1729+
When trying to convert a subset of columns to a specified type using :meth:`~DataFrame.astype` and :meth:`~DataFrame.loc`, utilizing **:** as mask, upcasting occurs.
1730+
:meth:`~DataFrame.loc` tries to fit in what we are assigning to the current dtypes, while [ ] will overwrite them taking the dtype from the right hand side.
17311731

17321732
.. ipython:: python
17331733
17341734
df = pd.DataFrame({'a': [1,2,3], 'b': [4,5,6], 'c': [7, 8, 9]})
1735-
print df.loc[:, ['a', 'b']].astype(np.uint8).dtypes
1735+
df.loc[:, ['a', 'b']].astype(np.uint8).dtypes
17361736
df.loc[:, ['a', 'b']] = df.loc[:, ['a', 'b']].astype(np.uint8)
17371737
17381738
To avoid this please take the following approach.
@@ -1743,6 +1743,7 @@ To avoid this please take the following approach.
17431743
df[['a','b']] = df[['a','b']].astype(np.uint8)
17441744
df
17451745
df.dtypes
1746+
17461747
object conversion
17471748
~~~~~~~~~~~~~~~~~
17481749

0 commit comments

Comments
 (0)