File tree 1 file changed +14
-7
lines changed
1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -954,17 +954,24 @@ in the way that standard Python integer slicing works.
954
954
Indexing potentially changes underlying Series dtype
955
955
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
956
956
957
- The use of `` reindex_like `` can potentially change the dtype of a `` Series`` .
957
+ The different indexing operation can potentially change the dtype of a `` Series`` .
958
958
959
959
.. ipython:: python
960
960
961
- series = pd.Series([1 , 2 , 3 ])
962
- x = pd.Series([ True ])
963
- x.dtype
964
- x = pd.Series([ True ]).reindex_like(series)
965
- x.dtype
961
+ series1 = pd.Series([1 , 2 , 3 ])
962
+ series1.dtype
963
+ res = series1[[ 0 , 4 ]]
964
+ res.dtype
965
+ res
966
966
967
- This is because `` reindex_like`` silently inserts `` NaNs`` and the `` dtype``
967
+ .. ipython:: python
968
+ series2 = pd.Series([True ])
969
+ series2.dtype
970
+ res = series2.reindex_like(series1)
971
+ res.dtype
972
+ res
973
+
974
+ This is because the (re)indexing operations above silently inserts `` NaNs`` and the `` dtype``
968
975
changes accordingly. This can cause some issues when using `` numpy`` `` ufuncs``
969
976
such as `` numpy.logical_and`` .
970
977
You can’t perform that action at this time.
0 commit comments