I have a dataframe like this:
ind,l1,l2 = [0,1,0],[1,1,0],[0,0,1] df = pd.DataFrame([ind,l1,l2],columns=[['C1','C2','C3']]) df.index=[['A','C','E']]
I want to use df.loc([[‘A’,’B’,’C’,’D’,’E’]]) so that the unavailable indexes B & D returns nan values.
Can anyone help me with this?
Change loc to reindex
loc
reindex
df.reindex([['A','B','C','D','E']], axis=0)