Divmod in pandas
divmod function is used to takes two values as an input and it will find the division and quotient values.It will print the output in an tuple format.
Example-1
import pandas as pd l = pd.Series([ 4, 5, 6, 7, 8], index = [ "A", "B", "C", "D", "E"]) m = pd.Series([ 1, 2, 3, 4, 2], index = [ "A", "B", "C", "D", "E"]) print(l.divmod(m))
Output
(A 4 B 2 C 2 D 1 E 4 dtype: int64, A 0 B 1 C 0 D 3 E 0 dtype: int64)
Example-2
import pandas as pd l = pd.Series([ 4, 7, 8, 9, 10], index = [ "A", "B", "C", "D", "E"]) m = pd.Series([ 2, 2, 3, 5, 4], index = [ "A", "B", "C", "D", "E"]) print(l.divmod(m))
Output
(A 2 B 3 C 2 D 1 E 2 dtype: int64, A 0 B 1 C 2 D 4 E 2 dtype: int64)