@@ -1191,39 +1191,8 @@ The name, if set, will be shown in the console display:
11911191 df
11921192 df[' A' ]
11931193
1194-
1195- Set operations on Index objects
1196- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1197-
1198- .. _indexing.set_ops :
1199-
1200- The three main operations are ``union (|) ``, ``intersection (&) ``, and ``diff
1201- (-) ``. These can be directly called as instance methods or used via overloaded
1202- operators:
1203-
1204- .. ipython :: python
1205-
1206- a = Index([' c' , ' b' , ' a' ])
1207- b = Index([' c' , ' e' , ' d' ])
1208- a.union(b)
1209- a | b
1210- a & b
1211- a - b
1212-
1213- Also available is the ``sym_diff (^) `` operation, which returns elements
1214- that appear in either ``idx1 `` or ``idx2 `` but not both. This is
1215- equivalent to the Index created by ``(idx1 - idx2) + (idx2 - idx1) ``,
1216- with duplicates dropped.
1217-
1218- .. ipython :: python
1219-
1220- idx1 = Index([1 , 2 , 3 , 4 ])
1221- idx2 = Index([2 , 3 , 4 , 5 ])
1222- idx1.sym_diff(idx2)
1223- idx1 ^ idx2
1224-
1225- Setting index metadata (``name(s) ``, ``levels ``, ``labels ``)
1226- ------------------------------------------------------------
1194+ Setting metadata
1195+ ~~~~~~~~~~~~~~~~
12271196
12281197.. versionadded :: 0.13.0
12291198
@@ -1261,6 +1230,40 @@ See :ref:`Advanced Indexing <advanced>` for usage of MultiIndexes.
12611230 index.levels[1 ]
12621231 index.set_levels([" a" , " b" ], level = 1 )
12631232
1233+ Set operations on Index objects
1234+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1235+
1236+ .. _indexing.set_ops :
1237+
1238+ .. warning ::
1239+
1240+ In 0.15.0. the set operations ``+ `` and ``- `` were deprecated in order to provide these for numeric type operations on certain
1241+ index types. ``+ `` can be replace by ``.union() `` or ``| ``, and ``- `` by ``.difference() ``.
1242+
1243+ The two main operations are ``union (|) ``, ``intersection (&) ``
1244+ These can be directly called as instance methods or used via overloaded
1245+ operators. Difference is provided via the ``.difference() `` method.
1246+
1247+ .. ipython :: python
1248+
1249+ a = Index([' c' , ' b' , ' a' ])
1250+ b = Index([' c' , ' e' , ' d' ])
1251+ a | b
1252+ a & b
1253+ a.difference(b)
1254+
1255+ Also available is the ``sym_diff (^) `` operation, which returns elements
1256+ that appear in either ``idx1 `` or ``idx2 `` but not both. This is
1257+ equivalent to the Index created by ``idx1.difference(idx2).union(idx2.difference(idx1)) ``,
1258+ with duplicates dropped.
1259+
1260+ .. ipython :: python
1261+
1262+ idx1 = Index([1 , 2 , 3 , 4 ])
1263+ idx2 = Index([2 , 3 , 4 , 5 ])
1264+ idx1.sym_diff(idx2)
1265+ idx1 ^ idx2
1266+
12641267 Set / Reset Index
12651268-----------------
12661269
0 commit comments