title: Pandas - Change values in output of dataframe.applymap(type)
body: <p>I am writing a code to compare the datatype of each value in an excel spreadsheet to a database definition spreadsheet which lists the required field/datatypes.</p>
  <p>I am using dataframe.applymap(type)  to check all of the values in the excel sheet which holds my data.</p>
  <pre><code>data_types = location_df.applymap(type)
  </code></pre>
  <p>The output of the above block is this:</p>
  <pre><code>  Location_ID    Location_Name      AltName          X_UTM            Y_UTM           Type_Code            QA_QC         Comments
    &lt;class 'int'&gt;  &lt;class 'str'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;    &lt;class 'str'&gt;
    &lt;class 'int'&gt;  &lt;class 'str'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;    &lt;class 'str'&gt;
    &lt;class 'int'&gt;  &lt;class 'str'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;    &lt;class 'str'&gt;
    &lt;class 'int'&gt;  &lt;class 'str'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;    &lt;class 'str'&gt;
    &lt;class 'int'&gt;  &lt;class 'str'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;
    &lt;class 'int'&gt;  &lt;class 'str'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;    &lt;class 'str'&gt;
  </code></pre>
  <p>I want to change the values in the output dataframe so that the value matches an analogous string value found in my database definition file. For example, I want to change all instances of &lt;class 'str'&gt;  to 'TEXT'.</p>
  <p>I've been trying to use pandas.replace to do the job, but it's not giving the desired results:</p>
  <pre><code>for col in data_types:
       data_types[col] = data_types[col].replace(&quot;&lt;class 'str'&gt;&quot;, &quot;TEXT&quot;, regex=True)
  </code></pre>
  <p>The print output does not have a changed value:</p>
  <pre><code>      Location_ID    Location_Name      AltName          X_UTM            Y_UTM           Type_Code            QA_QC         Comments
       &lt;class 'int'&gt;  &lt;class 'str'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;  &lt;class 'float'&gt;    &lt;class 'str'&gt;
  </code></pre>
  <p>I've been able to use the above .replace method to change values in a dataframe when the values are not in the &lt;class*&gt; format. Is anyone able to explain why the .replace method does not work in this case, as well as the 'correct' method to manipulate the values in the data_types dataframe?</p>