title: Setting a row value based on hour value of the index in pandas
body: <p>The indices to my DataFrame are datetimes, one row every 10 minutes. I want to <strong>set</strong> the value of a column based on the hour value of the index. Here is my code so far:</p>
  
  <pre><code>import pandas as pd
  
  df = pd.read_csv('Data.csv', sep='\t');
  df['DateTime'] = pd.to_datetime(df['DateTime'])
  df.set_index('DateTime', inplace=True)
  
  rng = df.index
  day_index = rng[(rng.hour &gt;= 8) &amp; (rng.hour &lt; 22)] 
  night_index = rng[(rng.hour &gt; 8 ) &amp; (rng.hour &lt;= 22)]
  </code></pre>
  
  <p>So far so good: the following give the expected parts of the DF:</p>
  
  <pre><code>df.loc[day_index].head()
  
                       LAeq
  DateTime                 
  2018-01-16 08:00:00  50.0
  2018-01-16 08:10:00  49.4
  2018-01-16 08:20:00  49.2
  2018-01-16 08:30:00  48.9
  2018-01-16 08:40:00  48.1
  </code></pre>
  
  <p>and </p>
  
  <pre><code>df.loc[night_index].head()
  
               LAeq
  DateTime                 
  2018-01-15 23:10:00  42.8
  2018-01-15 23:20:00  41.9
  2018-01-15 23:30:00  43.5
  2018-01-15 23:40:00  45.6
  2018-01-15 23:50:00  45.7
  </code></pre>
  
  <p>Shouldn't I be able to <strong>set</strong> a value for a column for these day and night periods, something like:</p>
  
  <pre><code>df.loc[day_index, 'Limit'] = 55
  df.loc[night_index, 'Limit'] = 45
  </code></pre>
  
  <p>Both give an <code>AttributeError: 'bool' object has no attribute 'any'</code> What is the simplest way of setting these? I'm making do with the terrible un-Pythonic (warning this code may hurt your eyes):</p>
  
  <pre><code>df['Hour'] = df.index.hour
  
  for i in range(len(df.index)):
  h = int(df.ix[i]['Hour'])
  if (8 &lt;= h &lt; 22):
      df.ix[i, 'Limit'] = 55
  else:
      df.ix[i,'Limit'] = 45
  </code></pre>
  
  <p>Which is ugly, but it works.</p>