Div in pandas



div function is used to divided the values.








Example-1
import pandas as pd

l = pd.Series([ 10, 9, 16, 25, 36], index = [ "A", "B", "C", "D", "E"])

m = pd.Series([ 2, 3, 4, 5, 6], index = [ "A", "B", "C", "D", "E"])

print(l.div(m,fill_value = 0))

print(l.div(m))



Output



A    5.0
B    3.0
C    4.0
D    5.0
E    6.0
dtype: float64
A    5.0
B    3.0
C    4.0
D    5.0
E    6.0
dtype: float64







Example-2
import pandas as pd

l = pd.Series([ 4, 9, 24, 50, 72], index = [ "A", "B", "C", "D", "E"])

m = pd.Series([ 2, 3, 4, 5, 6], index = [ "A", "B", "C", "D", "E"])

print(l.div(m,fill_value = 0))

print(l.div(m))   



Output



A     2.0
B     3.0
C     6.0
D    10.0
E    12.0
dtype: float64
A     2.0
B     3.0
C     6.0
D    10.0
E    12.0
dtype: float64