File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 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.
954954Indexing potentially changes underlying Series dtype
955955~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
956956
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`` .
958958
959959.. ipython:: python
960960
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
966966
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``
968975changes accordingly. This can cause some issues when using `` numpy`` `` ufuncs``
969976such as `` numpy.logical_and`` .
970977
You can’t perform that action at this time.
0 commit comments