title: How to find number of decimal places in a number also counting trailing zero in python
body: <p>My question pertains to counting the number of digits after decimal point using python or pandas. Questions answered so far first convert float to string and then count the number of characters after decimal point. In converting decimal to str(), the trailing zero is lost. But in my case I need to count total number of digits after decimal point including trailing zero, if it exists. That is, for the number 7.80, the answer should be two digits after decimal point and not one digit and, of course, for 7.8, it would be 1 digit after decimal. Please let me know if this is possible.</p>
  
  <p>Actually my problem is this:
  Suppose I have a pandas Series something as follows:</p>
  
  <pre><code>0.123
  0.124
  0.123
  0.349
  0.349
  0.340
  </code></pre>
  
  <p>I want to generate two features. One simple value_counts() of existing data.
  So answer will be:</p>
  
  <pre><code>0.123   2
  0.124   1
  0.123   2
  0.349   2
  0.349   2
  0.340   1
  </code></pre>
  
  <p>Another feature generation will be value_counts() after removing the last digit. New features will be:</p>
  
  <pre><code>0.123   3
  0.124   3
  0.123   3
  0.349   3
  0.349   3
  0.340   3
  </code></pre>
  
  <p>Thanks for the trouble</p>