@@ -1727,6 +1727,22 @@ You can assign a custom index to the ``index`` attribute:
1727
1727
Returning a view versus a copy
1728
1728
------------------------------
1729
1729
1730
+ .. warning ::
1731
+
1732
+ :ref: `Copy-on-Write <copy_on_write >`
1733
+ will become the new default in pandas 3.0. This means than chained indexing will
1734
+ never work. As a consequence, the ``SettingWithCopyWarning `` won't be necessary
1735
+ anymore.
1736
+ See :ref: `this section <copy_on_write_chained_assignment >`
1737
+ for more context.
1738
+ We recommend turning Copy-on-Write on to leverage the improvements with
1739
+
1740
+ ```
1741
+ pd.options.mode.copy_on_write = True
1742
+ ` ``
1743
+
1744
+ even before pandas 3.0 is available.
1745
+
1730
1746
When setting values in a pandas object, care must be taken to avoid what is called
1731
1747
``chained indexing ``. Here is an example.
1732
1748
@@ -1765,6 +1781,22 @@ faster, and allows one to index *both* axes if so desired.
1765
1781
Why does assignment fail when using chained indexing?
1766
1782
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1767
1783
1784
+ .. warning ::
1785
+
1786
+ :ref: `Copy-on-Write <copy_on_write >`
1787
+ will become the new default in pandas 3.0. This means than chained indexing will
1788
+ never work. As a consequence, the ``SettingWithCopyWarning `` won't be necessary
1789
+ anymore.
1790
+ See :ref: `this section <copy_on_write_chained_assignment >`
1791
+ for more context.
1792
+ We recommend turning Copy-on-Write on to leverage the improvements with
1793
+
1794
+ ```
1795
+ pd.options.mode.copy_on_write = True
1796
+ ` ``
1797
+
1798
+ even before pandas 3.0 is available.
1799
+
1768
1800
The problem in the previous section is just a performance issue. What's up with
1769
1801
the ``SettingWithCopy `` warning? We don't **usually ** throw warnings around when
1770
1802
you do something that might cost a few extra milliseconds!
@@ -1821,6 +1853,22 @@ Yikes!
1821
1853
Evaluation order matters
1822
1854
~~~~~~~~~~~~~~~~~~~~~~~~
1823
1855
1856
+ .. warning ::
1857
+
1858
+ :ref: `Copy-on-Write <copy_on_write >`
1859
+ will become the new default in pandas 3.0. This means than chained indexing will
1860
+ never work. As a consequence, the ``SettingWithCopyWarning `` won't be necessary
1861
+ anymore.
1862
+ See :ref: `this section <copy_on_write_chained_assignment >`
1863
+ for more context.
1864
+ We recommend turning Copy-on-Write on to leverage the improvements with
1865
+
1866
+ ```
1867
+ pd.options.mode.copy_on_write = True
1868
+ ` ``
1869
+
1870
+ even before pandas 3.0 is available.
1871
+
1824
1872
When you use chained indexing, the order and type of the indexing operation
1825
1873
partially determine whether the result is a slice into the original object, or
1826
1874
a copy of the slice.
0 commit comments