Divide each row of a pandas dataframe by index value

Hi, I try to divide each row of a pandas dataframe by its index. I know how to do it, but is there a more concise way?

import numpy as np
import pandas as pd
df = pd.DataFrame({'A': [3,4,5], 'B':[5,6,2], 'C': [7,9,3]}, index = [2,3,4])
df1 = df.copy()
df1.loc[:] = np.nan
for i in df.index:
    df1.loc[i, :] = df.loc[i, :]/i
df1 = df.divide(df.index, axis="rows")
1 Like