Question: I am trying to clear out the grids so that I can use the plot alone in a different process. I am trying to solve it using opencv. I have both actual and inverted image. I am not expert in python. Any help could be great.

Thanks in advance

Actual image

[![enter image description here](https://i.stack.imgur.com/7bpfq.png)](https://i.stack.imgur.com/7bpfq.png)

inverted image

[![enter image description here](https://i.stack.imgur.com/TRYTs.png)](https://i.stack.imgur.com/TRYTs.png)

Answer: 
Use [`GroupBy.first`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.first.html) by first and second level of `MultiIndex`:

```
s = df.groupby(level=[0,1])['value2'].first()
print (s)
File  no
A     0     34
      1     38
B     0     35
C     0     32
Name: value2, dtype: int64

```

If need one column `DataFrame` use one element `list`:

```
df1 = df.groupby(level=[0,1])[['value2']].first()
print (df1)
         value2
File no        
A    0       34
     1       38
B    0       35
C    0       32

```

Another idea is remove `3rd` level by [`DataFrame.reset_index`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.reset_index.html) and filter by [`Index.get_level_values`](http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.Index.get_level_values.html) with [`boolean indexing`](http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#boolean-indexing):

```
df2 = df.reset_index(level=2, drop=True)
s = df2.loc[~df2.index.duplicated(), 'value2']
print (s)
File  no
A     0     34
      1     38
B     0     35
C     0     32
Name: value2, dtype: int64

```
For the sake of completeness, I would like to add another method (which I would not have found without the answere by jezrael).

```
s = df.groupby(level=[0,1])['value2'].nth(0)

```

This can be generalized to finding any, not merely the first entry

```
t = df.groupby(level=[0,1])['value1'].nth(1)

```

Note that the selection was changed from `value2` to `value1` as for the former, the results of `nth(0)` and `nth(1)` would have been identical.

Pandas documentation link: <https://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.core.groupby.GroupBy.nth.html>