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
DOC: add addtl docs for FloatIndexing changes in 0.18.0
closes#12322
Author: Jeff Reback <[email protected]>
Closes#12330 from jreback/deprecate_docs and squashes the following commits:
5a9585c [Jeff Reback] DOC: add addtl docs for FloatIndexing changes in 0.18.0
FutureWarning: pd.rolling_mean is deprecated for Series and
@@ -884,11 +884,17 @@ Removal of deprecated float indexers
884
884
In :issue:`4892` indexing with floating point numbers on a non-``Float64Index`` was deprecated (in version 0.14.0).
885
885
In 0.18.0, this deprecation warning is removed and these will now raise a ``TypeError``. (:issue:`12165`)
886
886
887
+
.. ipython:: python
888
+
889
+
s = pd.Series([1,2,3])
890
+
s
891
+
s2 = pd.Series([1, 2, 3], index=list('abc'))
892
+
s2
893
+
887
894
Previous Behavior:
888
895
889
896
.. code-block:: python
890
897
891
-
In [1]: s = Series([1,2,3])
892
898
In [2]: s[1.0]
893
899
FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
894
900
Out[2]: 2
@@ -901,24 +907,46 @@ Previous Behavior:
901
907
FutureWarning: scalar indexers for index type Int64Index should be integers and not floating point
902
908
Out[4]: 2
903
909
910
+
# .ix would coerce 1.0 to the positional 1, and index
911
+
In [5]: s2.ix[1.0] = 10
912
+
FutureWarning: scalar indexers for index type Index should be integers and not floating point
913
+
914
+
In [6]: s2
915
+
Out[6]:
916
+
a 1
917
+
b 10
918
+
c 3
919
+
dtype: int64
920
+
904
921
New Behavior:
905
922
906
923
.. code-block:: python
907
924
908
-
In [4]: s[1.0]
925
+
In [2]: s[1.0]
909
926
TypeError: cannot do label indexing on <class 'pandas.indexes.range.RangeIndex'> with these indexers [1.0] of <type 'float'>
910
927
911
-
In [4]: s.iloc[1.0]
928
+
In [3]: s.iloc[1.0]
912
929
TypeError: cannot do label indexing on <class 'pandas.indexes.range.RangeIndex'> with these indexers [1.0] of <type 'float'>
913
930
914
931
In [4]: s.loc[1.0]
915
932
TypeError: cannot do label indexing on <class 'pandas.indexes.range.RangeIndex'> with these indexers [1.0] of <type 'float'>
916
933
934
+
# .ix will now cause this to be a label lookup and coerce to and Index
935
+
In [5]: s2.ix[1.0] = 10
936
+
937
+
In [6]: s2
938
+
Out[3]:
939
+
a 1
940
+
b 2
941
+
c 3
942
+
1.0 10
943
+
dtype: int64
944
+
917
945
Float indexing on a ``Float64Index`` is unchanged.
918
946
919
947
.. ipython:: python
920
948
921
-
s = Series([1,2,3],index=np.arange(3.))
949
+
s = pd.Series([1,2,3],index=np.arange(3.))
922
950
s[1.0]
923
951
s[1.0:2.5]
924
952
@@ -945,7 +973,7 @@ Performance Improvements
945
973
- Improved huge ``DatetimeIndex``, ``PeriodIndex`` and ``TimedeltaIndex``'s ops performance including ``NaT`` (:issue:`10277`)
946
974
- Improved performance of ``pandas.concat`` (:issue:`11958`)
947
975
- Improved performance of ``StataReader`` (:issue:`11591`)
948
-
- Improved performance in construction of ``Categoricals`` with Series of datetimes containing ``NaT`` (:issue:`12077`)
976
+
- Improved performance in construction of ``Categoricals`` with ``Series`` of datetimes containing ``NaT`` (:issue:`12077`)
949
977
950
978
951
979
- Improved performance of ISO 8601 date parsing for dates without separators (:issue:`11899`), leading zeros (:issue:`11871`) and with whitespace preceding the time zone (:issue:`9714`)
0 commit comments