title: Setting values with multiindex in pandas
body: <p>There are already a couple of questions on SO relating to this, most notably <a href="https://stackoverflow.com/questions/28002197/pandas-proper-way-to-set-values-based-on-condition-for-subset-of-multiindex-da">this one</a>, however none of the answers seem to work for me and quite a few links to docs (especially on lexsorting) are broken, so I'll ask another one. </p>
  
  <p>I'm trying do to something (seemingly) very simple. Consider the following MultiIndexed Dataframe:</p>
  
  <pre><code>import pandas as pd; import random
  arrays = [['bar', 'bar', 'baz', 'baz', 'foo', 'foo', 'qux', 'qux'],
        ['one', 'two', 'one', 'two', 'one', 'two', 'one', 'two']]
  
  tuples = list(zip(*arrays))
  index = pd.MultiIndex.from_tuples(tuples, names=['first', 'second'])
  df = pd.concat([pd.Series(np.random.randn(8), index=index), pd.Series(np.random.randn(8), index=index)], axis=1)
  </code></pre>
  
  <p>Now I want to set all values in column <code>0</code> to some value (say <code>np.NaN</code>) for the observations in category <code>one</code>. I've failed with:</p>
  
  <pre><code>df.loc(axis=0)[:, "one"][0] = 1 # setting with copy warning
  </code></pre>
  
  <p>and</p>
  
  <pre><code>df.loc(axis=0)[:, "one", 0] = 1
  </code></pre>
  
  <p>which either yields a warning about length of keys exceeding length of index, or one about a lack of lexsorting to sufficient depth.</p>
  
  <p>What is the correct way to do this?</p>