title: How can I know the type of a pandas dataframe cell
body: <p>I have a dataframe, for example:</p>
  
  <pre><code>1
  1.3
  2,5
  4
  5
  </code></pre>
  
  <p>With the following code, I am trying to know what are the types of the different cells of my pandas dataframe:</p>
  
  <pre><code>for i in range (len(data.columns)) :
                  print (" lenth of  columns : " + str(len(data.columns)) )
                  for j in range (len(data[i])) :
                      data[i][j]=re.sub(r'(\d*)\.(\d*)',r'\1,\2',str(data[i][j]))
                      print(str(data[i][j]))
  
                      print(" est de type : "type(data[i][j]))
                      if str(data[i][j]).isdigit():
                          print(str(data[i][j]) + " contain a number  " )
  </code></pre>
  
  <p>The problem is when a cell of the dataframe contain a dot, pandas thinks it is a string. So I used regex, in order to change the dot into a comma.</p>
  
  <p>But after that, the types of all my dataframe cells changed to string. My question is: How can I know if a cell of the dataframe is an int or a float? I already tried <code>isinstance(x, int)</code></p>
  
  <p>edit : How can I count the number of int and float, with the output of the df.apply(type)  for example , I want to know <strong>how many cells of my column are int or float</strong></p>
  
  <p>My second question is, why when I have 2.5 , the dataframe give him the str type ? </p>
  
  <pre><code>    0       &lt;class 'int'&gt;
  1       &lt;class 'str'&gt;
  2     &lt;class 'float'&gt;
  3     &lt;class 'float'&gt;
  4       &lt;class 'int'&gt;
  5       &lt;class 'str'&gt;
  6       &lt;class 'str'&gt;
  </code></pre>
  
  <p>Thanks.</p>