You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/source/basics.rst
+11-7
Original file line number
Diff line number
Diff line change
@@ -1726,22 +1726,26 @@ then the more *general* one will be used as the result of the operation.
1726
1726
# conversion of dtypes
1727
1727
df3.astype('float32').dtypes
1728
1728
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.
1729
+
Convert a subset of columns to a specified type using :meth:`~DataFrame.astype`
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.
1737
1741
1738
-
To avoid this please take the following approach.
1742
+
: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. Therefore the following piece of code produces the unintended result.
0 commit comments