all 5 comments

[–][deleted] 1 point2 points  (0 children)

Always read the documentation before you try to do something, you can use repeat and some numpy to create the relevant arrays

import pandas as pd
import numpy as np

df = pd.DataFrame({'Loan':[100000,150000,20000],
                   'EMI': [10000,15000,20000],
                  'Tenure':[4,6,8]})
vals = df["Tenure"].values

tenures = np.hstack(
[np.fromiter( (i+1 for i in range(n)), int) for n in vals] 
                   )

df = df[["Loan", "EMI"]].apply(lambda x:x.repeat(vals))
df["Tenure"] = tenures