I think you need if is necessary convert MultiIndex to Index:

df.columns = df.columns.map(''.join)

Or if need remove level use droplevel:

df.columns = df.columns.droplevel(0)

If need access to values is possible use xs:

df = df.xs('CID', axis=1, level=1)

You can also check:

What is the difference between size and count in pandas?

EDIT:

For remove MultiIndex is another solution select by ['FID'].

df = df.groupby(by=['CID','FE'])['FID'].count().unstack().reset_index()

Samples (also added rename_axis for nicer output):

df = pd.DataFrame({'CID':[2,2,3],
                   'FE':[5,5,6],
                   'FID':[1,7,9]})

print (df)
   CID  FE  FID
0    2   5    1
1    2   5    7
2    3   6    9

df = df.groupby(by=['CID','FE'])['FID']
       .count()
       .unstack()
       .reset_index()
       .rename_axis(None, axis=1)

print (df)    
   CID    5    6
0    2  2.0  NaN
1    3  NaN  1.0
Answer from jezrael on Stack Overflow
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.drop.html
pandas.DataFrame.drop — pandas 3.0.3 documentation
Remove rows or columns by specifying label names and corresponding axis, or by directly specifying index or column names. When using a multi-index, labels on different levels can be removed by specifying the level.
🌐
Statology
statology.org › home › pandas: how to remove multiindex in pivot table
Pandas: How to Remove MultiIndex in Pivot Table
October 21, 2022 - To remove a multiIndex from a pandas pivot table, you can use the values argument along with the reset_index() function: pd.pivot_table(df, index='col1', columns='col2', values='col3').reset_index()
Discussions

python - Pandas: getting rid of the multiindex - Stack Overflow
The following works well for me: df.columns = df.columns.map(lambda x: x[1]) df = df.reset_index() Thanks! 2017-05-17T11:57:41.533Z+00:00 ... Find the answer to your question by asking. Ask question ... See similar questions with these tags. ... Domain expertise still wanted: the latest trends in AI-assisted knowledge for... ... I’m Jody, the Chief Product and Technology Officer at Stack Overflow. Let’s... 166 What is the difference between size and count in pandas? 5 Completely remove ... More on stackoverflow.com
🌐 stackoverflow.com
python - Pandas: drop a level from a multi-level column index? - Stack Overflow
3 Pandas DataFrame plot: specify column from MultiIndex for secondary_y More on stackoverflow.com
🌐 stackoverflow.com
pandas - How to remove multi index from dataframe in python? - Stack Overflow
I have a data frame purchase_count Scrips 1STCUS 20MICRONS 21STCENMGM 3MINDIA Client_id A100027 NaN NaN NaN NaN A100074 NaN Na... More on stackoverflow.com
🌐 stackoverflow.com
April 3, 2019
DF with MultiIndex: how to drop rows where at least one column is all null?
df.isna() will return a dataframe of booleans: True where df has a null value and False otherwise. Then df.isna().sum(axis=1) will return a series with the same index as df, counting the number of null values in each row (make sure you understand why!). Finally, df[df.isna().sum(axis=1) == 0] will return df, filtered to those rows with no null values. Again, make sure you understand why. More on reddit.com
🌐 r/learnpython
1
4
April 13, 2024
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.MultiIndex.droplevel.html
pandas.MultiIndex.droplevel — pandas 3.0.3 documentation
>>> mi.droplevel("z") MultiIndex([(1, 3), (2, 4)], names=['x', 'y']) >>> mi.droplevel(["x", "y"]) Index([5, 6], dtype='int64', name='z')
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.droplevel.html
pandas.DataFrame.droplevel — pandas 3.0.3 documentation
Series/DataFrame with requested index / column level(s) removed. ... Replace values given in to_replace with value. ... Return reshaped DataFrame organized by given index / column values. ... >>> df = ( ... pd.DataFrame([[1, 2, 3, 4], [5, 6, 7, 8], [9, 10, 11, 12]]) ... .set_index([0, 1]) ... .rename_axis(["a", "b"]) ... ) >>> df.columns = pd.MultiIndex.from_tuples( ...
🌐
w3resource
w3resource.com › python-exercises › pandas › index › pandas-indexing-exercise-21.php
Pandas: Drop a level from a multi-level column index - w3resource
September 6, 2025 - Construct a Dataframe using the ... a a 0 1 2 3 1 3 4 5 2 5 6 7 ... Write a Pandas program to drop a specified level from a MultiIndex in the columns and then display the resulting DataFrame....
Find elsewhere
🌐
DataScientYst
datascientyst.com › pandas-drop-multiindex-level
How to Drop a Level from a MultiIndex in Pandas DataFrame
November 12, 2021 - Method droplevel() will remove one, several or all levels from a MultiIndex. Let's check the default execution by next example: import pandas as pd cols = pd.MultiIndex.from_tuples([(0, 1), (0, 1)]) df = pd.DataFrame([[1,2], [3,4]], index=cols) ...
🌐
Arab Psychology
scales.arabpsychology.com › psychological scales › how to easily convert a multiindex pivot table in pandas to a regular dataframe
How To Easily Convert A MultiIndex Pivot Table In Pandas To A Regular DataFrame
November 22, 2025 - By specifying values, you narrow ... remove a MultiIndex from a Pandas pivot table, you must ensure that the aggregation fields are clearly defined using the values argument, and then apply the reset_index() function ......
🌐
Medium
medium.com › data-science › functions-that-generate-a-multiindex-in-pandas-and-how-to-remove-the-levels-7aa15ac7ca95
Functions That Generate a Multi-index in Pandas and How to Remove the Levels | by Susan Maina | TDS Archive | Medium
September 17, 2021 - Functions That Generate a Multi-index in Pandas and How to Remove the Levels How groupby and unstack operations create a multiindex and how to remove it without compromising the data’s …
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.DataFrame.reset_index.html
pandas.DataFrame.reset_index — pandas 3.0.3 documentation
We can use the drop parameter to avoid the old index being added as a column: >>> df.reset_index(drop=True) class max_speed 0 bird 389.0 1 bird 24.0 2 mammal 80.5 3 mammal NaN · You can also use reset_index with MultiIndex.
🌐
GeeksforGeeks
geeksforgeeks.org › drop-specific-rows-from-multiindex-pandas-dataframe
Drop specific rows from multiindex Pandas Dataframe - GeeksforGeeks
May 23, 2021 - Now, we have to drop some rows from the multi-indexed dataframe. So, we are using the drop() method provided by the pandas module. This function drop rows or columns in pandas dataframe.
🌐
Scaler
scaler.com › home › topics › pandas › pandas multiindex, transpose and stack
Pandas Multiindex, Transpose, and Stack - Scaler Topics
May 4, 2023 - The first argument can take int, ... from the multi-index. Code ... The Pandas stack() method reshapes a DataFrame into a Multi-Index dataframe with more inner levels in the Index....
🌐
GeeksforGeeks
geeksforgeeks.org › python › how-to-drop-a-level-from-a-multi-level-column-index-in-pandas-dataframe
How to drop a level from a multi-level column index in Pandas Dataframe ? - GeeksforGeeks
July 23, 2025 - Hence, we can observe that in the multi-level column index, we have successfully removed the level with index number 2. ... In this example, we will be implementing more concepts of the multi-level index. We will be deleting multiple levels at the same time. ... # importing all important libraries import pandas as pd # Creating a multilevel index index = pd.MultiIndex.from_tuples([("Company A", "Company B", "Company C"), ("Company A", "Company A", "Company B"), ("Company A", "Company B", "Company C")]) # Creating a pandas dataframe with # multilevel-column indexing df = pd.DataFrame([["Atreyi", "Digangana", "Sohom"], ["Sujit", "Bjon", "Rajshekhar"], ["Debosmita", "Shatabdi", ""]], columns=index) # Labelling the dataframe index.
🌐
Finxter
blog.finxter.com › 5-best-ways-to-drop-multiple-levels-from-a-multilevel-column-index-in-pandas-dataframes
5 Best Ways to Drop Multiple Levels from a MultiLevel Column Index in Pandas DataFrames – Be on the Right Side of Change
The droplevel() method allows you to remove one or several levels from a DataFrame’s MultiIndex by specifying the levels’ names. This method provides a convenient way to refine the DataFrame’s structure while keeping the pertinent data intact. ... import pandas as pd # Create a DataFrame ...
🌐
PYnative
pynative.com › home › python › pandas › drop columns in pandas dataframe
Drop columns in pandas DataFrame
March 9, 2023 - We can use DataFrame.iloc to select single or multiple columns from the DataFrame. We can use DataFrame.iloc in the columns parameter to specify the index position of the columns which need to drop.
🌐
Pandas
pandas.pydata.org › pandas-docs › stable › reference › api › pandas.MultiIndex.droplevel.html
pandas.MultiIndex.droplevel — pandas 3.0.2 documentation
>>> mi.droplevel("z") MultiIndex([(1, 3), (2, 4)], names=['x', 'y']) >>> mi.droplevel(["x", "y"]) Index([5, 6], dtype='int64', name='z')
🌐
Reddit
reddit.com › r/learnpython › df with multiindex: how to drop rows where at least one column is all null?
r/learnpython on Reddit: DF with MultiIndex: how to drop rows where at least one column is all null?
April 13, 2024 -

I have a MultiIndex where the outer level is an ID and the inner level is a timestamp. I have various columns denoted measurements per ID per timestamp. If any of these measurements (columns) are completely null (for that ID), all the records for that ID are useless. This is because I can't use the measurements from other timestamps to impute the missing values for that ID.

How do I go about checking if there's "at least one column for which all values are null for this ID", and discarding all rows of that ID?

EDIT:

Found a workaround by creating a grouped-by-ID version of the table and using that as a lookup table to see which rows to delete, but if there's a way to do this in a single step that's smarter lmk.