title: Is it possible to set the maximum string length with pandas (like SQL)
body: <p>It is easy to set a column to a string data type with pandas either when you read it in a dataframe or once it's made. I should note that a categorical won't work because nearly every row has a different value.</p>
  
  <p>Reading in:</p>
  
  <pre><code>df = pd.read_csv('data', dtype={'colA': string})
  </code></pre>
  
  <p>Afterwards:</p>
  
  <pre><code>df['colA'] = df['colA'].astype(str)
  </code></pre>
  
  <p>In SQL, you can set a limit on string length for a column, which will conserve memory. For example, I can set the max character length for a column by setting its data type to <code>varchar(100)</code>. I want to reduce the memory usage of a string column in a pandas dataframe. I can't read it in chunks because there are certain things that I need every value in it for, but I know there is a maximum string length (strings won't be more than 25 characters). Is there an equivalent to <code>varchar(100)</code> in pandas; something like <code>df.astype(string, maxlength=25)</code>?</p>
  
  <p>The purpose of this is to reduce the memory needed to read this column.</p>