title: Remove substring from multiple string columns in a pandas DataFrame
body: <p>I have a list of columns in a dataframe that I want to run through and perform an operation on them. the columns hold datetimes or nothing.  </p>
  
  <p>For each column in the list, I would like to trim every value in the column that contains "20" in it to the first 10 characters, otherwise leave it as is.</p>
  
  <p>I've tried this a few ways, but get a variety of errors or imperfect results.</p>
  
  <p>The following version throws an error of " 'str' object has no attribute 'apply'", but if I don't use ".astype(str)", then I get an error of " argument of type 'datetime.datetime' is not iterable". </p>
  
  <pre><code>df_combined[dateColumns] = df_combined[dateColumns].fillna(notFoundText).astype(str)
      print (dateColumns)
      for column in dateColumns:
          for row in range(len(column)):
              print(df_combined[column][row])
              if "20" in (df_combined[column][row]):
                  df_combined[column][row].apply(lambda x: x[:10], axis=1)
              print(df_combined[column][row])
  </code></pre>
  
  <p>Halp.  Thanks in advance.</p>