Last active
February 26, 2020 14:22
-
-
Save noskill/b5eb428e5632f093c8b57ec997c640c5 to your computer and use it in GitHub Desktop.
multiindex dataframe in pandas
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
from pandas.core.indexes.api import ensure_index_from_sequences | |
col_dict = {'FrameId':(0,), 'Id':(1,), 'X': (321.89,), 'Y': (381.81,), 'Width': (39.45,), 'Height': (49.45,), 'ClassId': (-1,), 'Visibility': (-1,), 'unused': (-1,)} | |
names = ['X', 'Y', 'Width', 'Height', 'Confidence', 'ClassId', 'Visibility', 'unused'] | |
arrays = col_dict['FrameId'], col_dict['Id'] | |
index = ensure_index_from_sequences(arrays, names=('FrameId', 'Id')) | |
dfnew = pd.DataFrame(col_dict, columns=names, index=index) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment