<p dir="auto"><a href="http://stackoverflow.com/questions/18924908/remove-parentheses-from-complex-numbers-pandas/18925604#18925604" rel="nofollow">http://stackoverflow.com/questions/18924908/remove-parentheses-from-complex-numbers-pandas/18925604#18925604</a></p>
<p dir="auto">How can I read back in dataframes from CSV files which I export using <code class="notranslate">to_csv()</code> that have complex numbers?</p>
<p dir="auto">test case:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="data = pd.DataFrame([1+2j,2+3j,3+4j],columns=['a'])
print 'a='
print data['a']
print 'a*2='
print data['a']*2

filename = 'testcase1.csv'
data.to_csv(filename)

print &quot;\nReadback...&quot;
data2 = pd.read_csv(filename)
print data2['a']
print data2['a']*2"><pre class="notranslate"><code class="notranslate">data = pd.DataFrame([1+2j,2+3j,3+4j],columns=['a'])
print 'a='
print data['a']
print 'a*2='
print data['a']*2

filename = 'testcase1.csv'
data.to_csv(filename)

print "\nReadback..."
data2 = pd.read_csv(filename)
print data2['a']
print data2['a']*2
</code></pre></div>
<p dir="auto">output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="a=
0    (1+2j)
1    (2+3j)
2    (3+4j)
Name: a, dtype: complex128
a*2=
0    (2+4j)
1    (4+6j)
2    (6+8j)
Name: a, dtype: complex128

Readback...
0    (1+2j)
1    (2+3j)
2    (3+4j)
Name: a, dtype: object
0    (1+2j)(1+2j)
1    (2+3j)(2+3j)
2    (3+4j)(3+4j)
Name: a, dtype: object"><pre class="notranslate"><code class="notranslate">a=
0    (1+2j)
1    (2+3j)
2    (3+4j)
Name: a, dtype: complex128
a*2=
0    (2+4j)
1    (4+6j)
2    (6+8j)
Name: a, dtype: complex128

Readback...
0    (1+2j)
1    (2+3j)
2    (3+4j)
Name: a, dtype: object
0    (1+2j)(1+2j)
1    (2+3j)(2+3j)
2    (3+4j)(3+4j)
Name: a, dtype: object
</code></pre></div>