title: Pandas: More efficient way to update a column in pandas dataframe without a for loop
body: <p>I have a pandas dataframe in which I want to update the value of a column based on another column in the dataframe. I was using the following code to update it before:</p>
  
  <pre><code>for i1, col1 in dfMod.iterrows():
  if col1['day'] == "MONDAY":
      dfMod.ix[i1,'weekIndex'] = 1
  elif col1['day'] == "TUESDAY":
      dfMod.ix[i1,'weekIndex'] = 2
  elif col1['day'] == "WEDNESDAY":
      dfMod.ix[i1,'weekIndex'] = 3
  elif col1['day'] == "THURSDAY":
      dfMod.ix[i1,'weekIndex'] = 4
  elif col1['day'] == "FRIDAY":
      dfMod.ix[i1,'weekIndex'] = 5
  elif col1['day'] == "SATURDAY":
      dfMod.ix[i1,'weekIndex'] = 6
  else:
      dfMod.ix[i1,'weekIndex'] = 7
  </code></pre>
  
  <p>However, the dataframe has 300,000 rows and takes forever to compile. Is there a better way to update the column?</p>