<p dir="auto">Consider the following data frame:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; df = pd.DataFrame(1.0, index=pd.MultiIndex.from_product([[0, 1], [0, 1]]), columns=['a'])
&gt;&gt;&gt; df
       a
0 0  1.0
  1  1.0
1 0  1.0
  1  1.0"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; df = pd.DataFrame(1.0, index=pd.MultiIndex.from_product([[0, 1], [0, 1]]), columns=['a'])
&gt;&gt;&gt; df
       a
0 0  1.0
  1  1.0
1 0  1.0
  1  1.0
</code></pre></div>
<p dir="auto">Taking a slice of this and assigning it to itself should leave the data unchanged, but look what happens:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; df.loc[(0,), :] = df.loc[(0,), :]
&gt;&gt;&gt; df
       a
0 0  NaN
  1  NaN
1 0  1.0
  1  1.0"><pre class="notranslate"><code class="notranslate">&gt;&gt;&gt; df.loc[(0,), :] = df.loc[(0,), :]
&gt;&gt;&gt; df
       a
0 0  NaN
  1  NaN
1 0  1.0
  1  1.0
</code></pre></div>
<p dir="auto">I'm on pandas version 0.20.1</p>
<p dir="auto">Best shown with an example.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="import numpy as np, pandas as pd
timestamps = map(pd.Timestamp, ['2014-01-01', '2014-02-01'])
categories = ['A', 'B', 'C', 'D']
df = pd.DataFrame(index=pd.MultiIndex.from_product([timestamps, categories], names=['ts', 'cat']),
                  columns=['Col1', 'Col2'])

&gt;&gt;&gt; df
                Col1  Col2
ts         cat            
2014-01-01 A     NaN   NaN
           B     NaN   NaN
           C     NaN   NaN
           D     NaN   NaN
2014-02-01 A     NaN   NaN
           B     NaN   NaN
           C     NaN   NaN
           D     NaN   NaN"><pre class="notranslate"><span class="pl-k">import</span> <span class="pl-s1">numpy</span> <span class="pl-k">as</span> <span class="pl-s1">np</span>, <span class="pl-s1">pandas</span> <span class="pl-k">as</span> <span class="pl-s1">pd</span>
<span class="pl-s1">timestamps</span> <span class="pl-c1">=</span> <span class="pl-en">map</span>(<span class="pl-s1">pd</span>.<span class="pl-v">Timestamp</span>, [<span class="pl-s">'2014-01-01'</span>, <span class="pl-s">'2014-02-01'</span>])
<span class="pl-s1">categories</span> <span class="pl-c1">=</span> [<span class="pl-s">'A'</span>, <span class="pl-s">'B'</span>, <span class="pl-s">'C'</span>, <span class="pl-s">'D'</span>]
<span class="pl-s1">df</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">DataFrame</span>(<span class="pl-s1">index</span><span class="pl-c1">=</span><span class="pl-s1">pd</span>.<span class="pl-v">MultiIndex</span>.<span class="pl-en">from_product</span>([<span class="pl-s1">timestamps</span>, <span class="pl-s1">categories</span>], <span class="pl-s1">names</span><span class="pl-c1">=</span>[<span class="pl-s">'ts'</span>, <span class="pl-s">'cat'</span>]),
                  <span class="pl-s1">columns</span><span class="pl-c1">=</span>[<span class="pl-s">'Col1'</span>, <span class="pl-s">'Col2'</span>])

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>
                <span class="pl-v">Col1</span>  <span class="pl-v">Col2</span>
<span class="pl-s1">ts</span>         <span class="pl-s1">cat</span>            
<span class="pl-c1">2014</span><span class="pl-c1">-</span><span class="pl-c1">01</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-v">A</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span>
           <span class="pl-v">B</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span>
           <span class="pl-v">C</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span>
           <span class="pl-v">D</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span>
<span class="pl-c1">2014</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-v">A</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span>
           <span class="pl-v">B</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span>
           <span class="pl-v">C</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span>
           <span class="pl-v">D</span>     <span class="pl-v">NaN</span>   <span class="pl-v">NaN</span></pre></div>
<p dir="auto">I want to set the values for all categories in a single month. These examples work just fine.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="df.loc['2014-01-01', 'Col1'] = 5
df.loc['2014-01-01', 'Col2'] = [1,2,3,4]

&gt;&gt;&gt; df
               Col1 Col2
ts         cat          
2014-01-01 A      5    1
           B      5    2
           C      5    3
           D      5    4
2014-02-01 A    NaN  NaN
           B    NaN  NaN
           C    NaN  NaN
           D    NaN  NaN"><pre class="notranslate"><span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'2014-01-01'</span>, <span class="pl-s">'Col1'</span>] <span class="pl-c1">=</span> <span class="pl-c1">5</span>
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'2014-01-01'</span>, <span class="pl-s">'Col2'</span>] <span class="pl-c1">=</span> [<span class="pl-c1">1</span>,<span class="pl-c1">2</span>,<span class="pl-c1">3</span>,<span class="pl-c1">4</span>]

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>
               <span class="pl-v">Col1</span> <span class="pl-v">Col2</span>
<span class="pl-s1">ts</span>         <span class="pl-s1">cat</span>          
<span class="pl-c1">2014</span><span class="pl-c1">-</span><span class="pl-c1">01</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-v">A</span>      <span class="pl-c1">5</span>    <span class="pl-c1">1</span>
           <span class="pl-v">B</span>      <span class="pl-c1">5</span>    <span class="pl-c1">2</span>
           <span class="pl-v">C</span>      <span class="pl-c1">5</span>    <span class="pl-c1">3</span>
           <span class="pl-v">D</span>      <span class="pl-c1">5</span>    <span class="pl-c1">4</span>
<span class="pl-c1">2014</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-v">A</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span>
           <span class="pl-v">B</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span>
           <span class="pl-v">C</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span>
           <span class="pl-v">D</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span></pre></div>
<p dir="auto">These examples don't work.</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="df.loc['2014-01-01', 'Col1'] += 1
df.loc['2014-02-01', 'Col2'] = df.loc['2014-01-01', 'Col2']

&gt;&gt;&gt; df
               Col1 Col2
ts         cat          
2014-01-01 A    NaN    1
           B    NaN    2
           C    NaN    3
           D    NaN    4
2014-02-01 A    NaN  NaN
           B    NaN  NaN
           C    NaN  NaN
           D    NaN  NaN"><pre class="notranslate"><span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'2014-01-01'</span>, <span class="pl-s">'Col1'</span>] <span class="pl-c1">+=</span> <span class="pl-c1">1</span>
<span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'2014-02-01'</span>, <span class="pl-s">'Col2'</span>] <span class="pl-c1">=</span> <span class="pl-s1">df</span>.<span class="pl-s1">loc</span>[<span class="pl-s">'2014-01-01'</span>, <span class="pl-s">'Col2'</span>]

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">df</span>
               <span class="pl-v">Col1</span> <span class="pl-v">Col2</span>
<span class="pl-s1">ts</span>         <span class="pl-s1">cat</span>          
<span class="pl-c1">2014</span><span class="pl-c1">-</span><span class="pl-c1">01</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-v">A</span>    <span class="pl-v">NaN</span>    <span class="pl-c1">1</span>
           <span class="pl-v">B</span>    <span class="pl-v">NaN</span>    <span class="pl-c1">2</span>
           <span class="pl-v">C</span>    <span class="pl-v">NaN</span>    <span class="pl-c1">3</span>
           <span class="pl-v">D</span>    <span class="pl-v">NaN</span>    <span class="pl-c1">4</span>
<span class="pl-c1">2014</span><span class="pl-c1">-</span><span class="pl-c1">02</span><span class="pl-c1">-</span><span class="pl-c1">01</span> <span class="pl-v">A</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span>
           <span class="pl-v">B</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span>
           <span class="pl-v">C</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span>
           <span class="pl-v">D</span>    <span class="pl-v">NaN</span>  <span class="pl-v">NaN</span></pre></div>
<p dir="auto">It doesn't seem to be a "setting a value on a copy" issue. Instead, Pandas is writing the NaNs.</p>
<p dir="auto">My current workaround is to unstack each column into a DataFrame with simple indexes. This works, but I have lots of columns to work with. One dataframe is much easier to work with than a pile of dataframes.</p>
<p dir="auto">The computations for each month depend on the values computed in the previous month, hence why it can't be done fully vectorized on an entire column.</p>