title: Replace any string in columns with 1
body: <p>I'm working with pandas. My goal is to convert several columns within a dataframe from containing either NaN or string data, into more or less a dummy variable (0's for NaN; 1's for any string). I'd like to do this without using a complete list of strings and replacing them each, because there are typos and this would lead to errors. I've been able to replace all the NaN data with 0's using the fillna function, which works like a dream!</p>
  
  <p>I am hoping for something similar that will replace all string data with 1's, but leave the 0's in place. I've searched stackoverflow and elsewhere, to little avail.</p>
  
  <p>The data look roughly like this, where I only want this to apply to columns starting with T_:</p>
  
  <pre><code>    fol    T_opp    T_Dir    T_Enh   Activity
      1      0        0        vo      hf
      2      vr       0        0       hx
      2      0        0        0       fe
      3      0        bt       0       rn
  </code></pre>
  
  <p>I'd like the output to look the same, but with "vr" "bt" and "vo" each replaced with the integer 1. From what I can tell, the pd get_dummies function is not what I'm looking for. I also can't make this work with replace(). I tried something using a T/F mask and a list of zeros, but the outcome was so wrong I won't bother to post the code here. </p>
  
  <p>Edited: I've added an additional column in the toy data above. The 'Activity' column is some data, also strings, that I do not want to touch.</p>