Create an empty data frame with index from another data frame
df2 = pd.DataFrame(index=df1.index)
This will create a DataFrame with no columns but just an index, and it will be the same index as in the df1.
It's better to set index as df1.index.copy()
df2 = pd.DataFrame(index=df1.index.copy())
You can use df1.index
is df2.index
to check whether they are the same object
You can also assign the index of a dataframe to another dataframe directly.
df2.index=df1.index
You can use this short code:
df2=df1[[]].copy()