Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9270763
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:27:02+00:00 2026-06-18T15:27:02+00:00

Suppose I have a DataFrame with a MultiIndex, like so In [88]: topic_word Out[88]:

  • 0

Suppose I have a DataFrame with a MultiIndex, like so

In [88]: topic_word
Out[88]: 

                          n         p
topic_id token                       
0        functions        1  0.076923
         layer            7  0.538462
         layered          1  0.076923
         module           1  0.076923
         multi            1  0.076923
         perceptron       1  0.076923
         separable        1  0.076923
1        copy             1  0.200000
         electromyograph  1  0.200000
         physical         2  0.400000
         techniques       1  0.200000
2        aw               1  0.125000
         computed         1  0.125000
         region           3  0.375000
         regions          3  0.375000
3        autonomous       1  0.041667
         diverse          1  0.041667
         heterogeneity    1  0.041667
         heterogeneous    4  0.166667
         integrate        2  0.083333

How can I insert the contents of the MultiIndex back into regular columns, such that I can select them like any other column?

    topic_id token            n         p
0   0        functions        1  0.076923
1   0        layer            7  0.538462
2   0        layered          1  0.076923
3   0        module           1  0.076923
4   0        multi            1  0.076923
5   0        perceptron       1  0.076923
6   0        separable        1  0.076923
7   1        copy             1  0.200000
8   1        electromyograph  1  0.200000
9   1        physical         2  0.400000
10  1        techniques       1  0.200000
11  2        aw               1  0.125000
12  2        computed         1  0.125000
13  2        region           3  0.375000
14  2        regions          3  0.375000
15  3        autonomous       1  0.041667
16  3        diverse          1  0.041667
17  3        heterogeneity    1  0.041667
18  3        heterogeneous    4  0.166667
19  3        integrate        2  0.083333
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T15:27:03+00:00Added an answer on June 18, 2026 at 3:27 pm

    Doing an ordinary reset_index puts these columns back as columns:

    df.reset_index()
    

    For DataFrame with multi-level index, return new DataFrame with labeling information in the columns under the index names…

    Note: the drop argument argument (if set True) will not add the index columns:

    drop : boolean, default False
        Do not try to insert index into dataframe columns.
        This resets the index to the default integer index.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Suppose I have a dataframe like this one: df <- data.frame (id = c(a,
Suppose I have a dataframe 'H', like so C1 C2 a 1 b 1
Suppose I have a DataFrame which has a subindex structure like the following, with
Suppose I have an R dataframe that looks like this, where end.group signifies the
Suppose we have the name written in any none-latin letters - languages, like Arabic,
Suppose we have a dataframe or matrix with one column specifying an integer value
Suppose I have a DataFrame with 100k rows and a column name . I
Suppose I have a Pandas dataframe df has columns a,b,c,d...z . And I want
Suppose I have a date.frame like: df <- data.frame(a=1:5, b=sample(1:5, 5, replace=TRUE), c=5:1) df
Suppose I have the following DataFrame (timeseries, first column is a DateTimeIndex) atn file

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.