Say I have the following dictionaries:
multilevel_indices = {'foo': ['A', 'B', 'C'], 'bar': ['X', 'Y'], 'baz': []}
column_data_1 = {'foo': [2, 4, 5], 'bar': [2, 3], 'baz': []}
How can I create a multi-index DataFrame using these dictionaries?
It should be something like:
index_1 index_2 column_data_1
foo A 2
B 4
C 5
bar X 2
Y 3
baz np.NaN np.NaN
Note:
If NaN indices are not supported by Pandas, we can drop the empty entries in the dictionaries above.
Ideally, I would like the DataFrame to capture somehow the fact that those entries are missing if possible. However, the most important thing is being able to index the dataframe using the indices in multilevel_indices.