ENH: Inconsistency when string refers both to index level and column label
While [groupby](https://pandas.pydata.org/pandas-docs/stable/user_guide/groupby.html#splitting-an-object-into-groups) throws a ValueError when the string parameter refers both to an index level and column name, [query](https://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html?highlight=query%20method#the-query-method) gives the column precedence in such a case:

```python
>>> df = pd.DataFrame({'a':[1,2,3,4,5], 'b':[3,3,3,3,3]})
>>> df.index.name = 'a'
>>> df.query('a < b')
   a  b
a
0  1  3
1  2  3
>>> df.groupby('a') 
Traceback (most recent call last):
ValueError: 'a' is both an index level and a column label, which is ambiguous.
```

I am sure there are many other places where a string can refer to both an index level and column name. #27652 and #8162 are somehow linked.

Even though those issues might *not* be solved, it would be desirable to handle the above ambiguity consistently in places where both index levels and column labels can be referenced by a string argument.