As your trace error says, you need to use int for loc. Now you use numpy.int64 which is not an pure int type in python. Please, try:
first_val = int(df[df.loc=="Density"].index)
As a result
But be careful, if your df is extremely large. Simple int range is between (0 to 4294967295) and np.uint64 has range between (0 to 18446744073709551615)
CLICK HERE to find out more related problems solutions.