There are a few things going on. You're both reassigning and reprinting the dataframe every time you go through the for loop.
To see what I mean, the following code (just taking the print statement out of the for loop) only prints the last data assigned to the dataframe.
for i in range (len('bus0')):
empty_df = pd.DataFrame(np.nan, index=[i], columns=['bus0', 'bus1'])
# print(empty_df)
'''
bus0 bus1
3 NaN NaN
'''
Instead of reassigning the whole dataframe, I would declare it before the for loop and just add each row in the for loop using .iloc. You can also use .iloc to assign different values to different rows while iterating through the for loop.
import pandas as pd
import numpy as np
empty_df = pd.DataFrame(columns=['bus0', 'bus1'])
for i in range (len('bus0')):
empty_df.loc[i] = np.nan
# print(empty_df)
'''
bus0 bus1
0 NaN NaN
1 NaN NaN
2 NaN NaN
3 NaN NaN
'''
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…