<p dir="auto"><code class="notranslate">DataFrame.to_string()</code> has a formatters parameter for formatting columns individually, but <code class="notranslate">to_csv()</code> could benefit from that parameter as well. This is especially useful, for example, when formatting integers with missing values.</p>
<ul class="contains-task-list">
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> date formatting <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="9483904" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/2583" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/2583/hovercard" href="https://github.com/pandas-dev/pandas/issues/2583">#2583</a>, PR <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="17030986" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/4313" data-hovercard-type="pull_request" data-hovercard-url="/pandas-dev/pandas/pull/4313/hovercard" href="https://github.com/pandas-dev/pandas/pull/4313">#4313</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="30842365" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/6797" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/6797/hovercard" href="https://github.com/pandas-dev/pandas/issues/6797">#6797</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> string spacing (justification?) <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="16461392" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/4158" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/4158/hovercard" href="https://github.com/pandas-dev/pandas/issues/4158">#4158</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> float format <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="9210494" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/2502" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/2502/hovercard" href="https://github.com/pandas-dev/pandas/issues/2502">#2502</a>, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="7576982" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/2069" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/2069/hovercard" href="https://github.com/pandas-dev/pandas/issues/2069">#2069</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> int format, <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="28482434" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/6502" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/6502/hovercard" href="https://github.com/pandas-dev/pandas/issues/6502">#6502</a></li>
<li class="task-list-item"><input type="checkbox" id="" disabled="" class="task-list-item-checkbox"> timedelta fromat <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="30795768" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/6783" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/6783/hovercard" href="https://github.com/pandas-dev/pandas/issues/6783">#6783</a></li>
</ul>
<p dir="auto"><a href="http://stackoverflow.com/questions/18425400/printing-to-csv-file-with-automatic-width" rel="nofollow">SO question</a></p>
<p dir="auto">something like</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="df.to_csv(format='%10.4f', sep=' ')"><pre class="notranslate"><span class="pl-s1">df</span>.<span class="pl-en">to_csv</span>(<span class="pl-s1">format</span><span class="pl-c1">=</span><span class="pl-s">'%10.4f'</span>, <span class="pl-s1">sep</span><span class="pl-c1">=</span><span class="pl-s">' '</span>)</pre></div>