0
import pandas as pd

df = pd.DataFrame({'Age': [30, 40, 30, 40, 30, 30, 20, 25],
                   'Height': [120, 162, 120, 120, 120, 72, 120, 81]})
modDfObj = df.append({'Age' : 25, 'Height':172,} , ignore_index=True) 

modDfObj

"""Is it possible to add one row between two rows, can we add one more index between two index"""

1 Answers1

0
import pandas as pd

df = pd.DataFrame({'Age': [30, 40, 30, 40, 30, 30, 20, 25],
                   'Height': [120, 162, 120, 120, 120, 72, 120, 81]},
                  index=['Jane', 'Jane', 'Aaron', 'Penelope', 'Jaane', 'Nicky',
                         'Armour', 'Ponting'])
line = pd.DataFrame({"Age": 33, "Height": 130}, index=[2])
df2 = pd.concat([df.iloc[:2], line, df.iloc[2:]]).reset_index(drop=True)
df2

"""Got the expected ouput"""