title: Prevent trailing zero with pandas "to_csv"
body: <p>I'm trying to export a CSV string to a D3 web application, but the command <code>to_csv</code> insists on adding a trailing 0 to the data, which prevents a proper use by D3.</p>
  
  <p>Here's a minimal example to illustrate the problem.</p>
  
  <p>My (simplified) dataframe is:</p>
  
  <pre><code>&gt;&gt;&gt; df = pd.DataFrame([['Alex',20.0000, 50.650]],columns=['Name','Age', 'Weight'])
     Name   Age  Weight
  0  Alex  20.0   50.65
  </code></pre>
  
  <p><code>df['Age']</code> contains a <code>float</code>, as indicated by:</p>
  
  <pre><code>&gt;&gt;&gt; df['Age']
  0    20.0
  Name: Age, dtype: float64
  </code></pre>
  
  <p>Then based on this <a href="https://stackoverflow.com/a/47542713/3976696">answer</a> I run <code>.astype(object)</code> to get the format I would like:</p>
  
  <pre><code>&gt;&gt;&gt; df=df.astype(object)
     Name Age Weight
  0  Alex  20  50.65
  </code></pre>
  
  <p>Now, <code>df['Age']</code> contains an <code>object</code>, with no trailing zero:</p>
  
  <pre><code>&gt;&gt;&gt; df['Age']
  0    20
  Name: Age, dtype: object
  </code></pre>
  
  <p>That's what I would like to export with <code>to_csv</code>, but this command reappends a trailing 0 to the number, which I want to avoid:</p>
  
  <pre><code>&gt;&gt;&gt; df_csv = df.to_csv(sep=',', index = False)
  &gt;&gt;&gt; df_csv
  'Name,Age,Weight\nAlex,20.0,50.65\n'
  </code></pre>
  
  <p>I tried using <code>df_csv = df.to_csv(sep=',', index = False, float_format='%.0f')</code> based on <a href="https://stackoverflow.com/a/12882439/3976696">this answer</a>, but that doesn't work because there are other floats in my dataframe for which I wish to keep non-zero decimals.</p>
  
  <p>How could I prevent this trailing 0 to appear for numbers with no decimals?</p>