Examples
import numpy as np
import pandas as pd
df = pd.DataFrame({'angles': [0, 3, 4],
'degrees': [360, 180, 360]},
index=['ellipse', 'triangle', 'rhombus'])
df
Divide by constant with reverse version.
df.div(10)
Add a scalar with operator version which return the same results.
df.rdiv(10)
Divide by a MultiIndex by level.
df_multindex = pd.DataFrame({'angles': [0, 3, 4, 4, 5, 6],
'degrees': [360, 180, 360, 360, 540, 720]},
index=[['X', 'X', 'X', 'Y', 'Y', 'Y'],
['ellipse', 'triangle', 'rhombus',
'rectangle', 'pentagon', 'hexagon']])
df_multindex
df.div(df_multindex, level=1, fill_value=0)