BUG: df.iloc not working with NamedTuple
- [x] closes #48188(Replace xxxx with the GitHub issue number)
- [x] [Tests added and passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#writing-tests) if fixing a bug or adding a new feature
- [ ] All [code checks passed](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#pre-commit).
- [ ] Added [type annotations](https://pandas.pydata.org/pandas-docs/dev/development/contributing_codebase.html#type-hints) to new arguments/methods/functions.
- [x] Added an entry in the latest `doc/source/whatsnew/vX.X.X.rst` file if fixing a bug or adding a new feature.

@rhshadrach I kept the `type(key) is tuple` since index can contain namedtuple, used as key in `df.loc[key]`, as shown in the test case below:
https://github.com/pandas-dev/pandas/blob/488f6bd5c08111603549d42effc6dbb7fec935f0/pandas/tests/indexing/test_loc.py#L1615-L1624
> I kept the type(key) is tuple since index can contain namedtuple, used as key in df.loc[key], as shown in the test case below:

Sorry, I don't understand. In particular, the test you highlighted passes with this patch applied and from your comment above I expected it not to. I mean if we only change `type(key) is tuple` to `isinstance(key, tuple)`, this particular test will fail.

Because in this test, namedtuples are elements of the index, and are used as labels in `df.loc`. It was handled by the else branch in the original code below.
https://github.com/pandas-dev/pandas/blob/72814750548b5ead5b08cd9b90d56a23c9a520ea/pandas/core/indexing.py#L1180-L1192 Thanks - makes sense. I think this might need further discussion in that case. I do not see a way to support tuple (and subclasses of tuple) in a flat Index (i.e. not a MultiIndex) and using tuples for accessing (row, column) pairs. Indeed, the following variant of that test using tuples fails on main:

```
idx1 = ("foo", "bar")
idx2 = ("baz", "bof")
index = Index([idx1, idx2], name="composite_index", tupleize_cols=False)
df = DataFrame([(1, 2), (3, 4)], index=index, columns=["A", "B"])
result = df.loc[("foo", "bar")]["A"]
assert result == 1
```

The only way I can see making it all work is to try one and if it fails try the other - which I think we want to avoid.

While we don't run into this problem with iloc, I wonder if we want to avoid supporting subclasses with iloc but not loc.

cc @jbrockmendel @phofl  This pull request is stale because it has been open for thirty days with no activity. Please [update](https://pandas.pydata.org/pandas-docs/stable/development/contributing.html#updating-your-pull-request) and respond to this comment if you're still interested in working on this.