What I'm trying to do is to create a dataframe based on a list as index and with a dataframe already determined:
df1:
index flag value
3 1 99
5 1 98
7 1 97
index list:
all_index = [1, 2, 3, 4, 5, 6, 7, 8, 9]
then get this output:
df2:
index flag
1 NaN
2 NaN
3 1
4 NaN
5 1
6 NaN
7 1
8 NaN
I was trying to do it in this way but doesn't works:
df2 = df1.loc[all_index]['flag']