How to deal with "divide by zero" with pandas dataframes when manipulating columns?
<p>I'm working with hundreds of pandas dataframes. A typical dataframe is as follows:</p>

<pre><code>import pandas as pd
import numpy as np
data = 'filename.csv'
df = pd.DataFrame(data)
df 

        one       two     three  four   five
a  0.469112 -0.282863 -1.509059  bar   True
b  0.932424  1.224234  7.823421  bar  False
c -1.135632  1.212112 -0.173215  bar  False
d  0.232424  2.342112  0.982342  unbar True
e  0.119209 -1.044236 -0.861849  bar   True
f -2.104569 -0.494929  1.071804  bar  False
....
</code></pre>

<p>There are certain operations whereby I'm dividing between columns values, e.g. </p>

<pre><code>df['one']/df['two'] 
</code></pre>

<p>However, there are times where I am dividing by zero, or perhaps both    </p>

<pre><code>df['one'] = 0
df['two'] = 0
</code></pre>

<p>Naturally, this outputs the error: </p>

<pre><code>ZeroDivisionError: division by zero
</code></pre>

<p>I would prefer for 0/0 to actually mean "there's nothing here", as this is often what such a zero means in a dataframe.</p>

<p>(a) How would I code this to mean "divide by zero" is 0 ?</p>

<p>(b) How would I code this to "pass" if divide by zero is encountered? </p>