Home > database >  Dataframe creation from a multiindex
Dataframe creation from a multiindex

Time:11-20

I have a pandas series values, stored in variable s, which was formed using Multi Indexing. Code-

s = pd.Series(np.random.rand(50), index=idx)

Here is how s looks like-

enter image description here

What is the best way to create a dataframe of this?

CodePudding user response:

Instead of series you can use dataframe and input your own multi index list.

s = pd.DataFrame(np.random.rand(50), index=idx)
  • Related