import pandas as pd
import numpy as np
b = {"b":[2,46,2,0],"a":[1,23,0,5]}
b = pd.DataFrame(b)
print(b)
b a
0 2 1
1 46 23
2 2 0
3 0 5
b['c'] = b['b']/b['a']
print(b)
b a c
0 2 1 2.0
1 46 23 2.0
2 2 0 inf
3 0 5 0.0
b['c'] = (round(b['b']/b['a'],2)).replace(np.inf,0)
print(b)
b a c
0 2 1 2.0
1 46 23 2.0
2 2 0 0.0
3 0 5 0.0