BUG: Fix length 1 .loc slicing with datetime string GH16071
State: closed

I've written the test in pytest style since I read that you are moving to this style. If I misunderstood I can add the test to the class. 

- [x] closes #16071 
 - [x] tests added / passed
 - [x] passes ``git diff upstream/master --name-only -- '*.py' | flake8 --diff``
 - [x] whatsnew entry


Labels:
name: Bug
name: Datetime
description: Datetime data dtype
name: Indexing
description: Related to indexing on series/frames, not to indexes themselves

Comments:
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=h1) Report
> Merging [#16072](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ff00b55de28ed12fc37ebeabfc2a748821542227?src=pr&el=desc) will **not change** coverage.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16072/graphs/tree.svg?src=pr&token=eZ4WkYLtcO&width=650&height=150)](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=tree)

```diff
@@           Coverage Diff           @@
##           master   #16072   +/-   ##
=======================================
  Coverage   90.82%   90.82%           
=======================================
  Files         159      159           
  Lines       50791    50791           
=======================================
  Hits        46132    46132           
  Misses       4659     4659
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.6% <100%> (ø)` | :arrow_up: |
| #single | `40.36% <0%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.43% <100%> (ø)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=footer). Last update [ff00b55...527a5c0](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

Thank you for the feedback. I made the requested changes.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@8c7b973`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/16072/graphs/tree.svg?height=150&width=650&token=eZ4WkYLtcO&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=tree)

```diff
@@            Coverage Diff            @@
##             master   #16072   +/-   ##
=========================================
  Coverage          ?   90.85%           
=========================================
  Files             ?      159           
  Lines             ?    50791           
  Branches          ?        0           
=========================================
  Hits              ?    46144           
  Misses            ?     4647           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `88.63% <100%> (?)` | |
| #single | `40.36% <0%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/indexes/datetimes.py](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9kYXRldGltZXMucHk=) | `95.43% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=footer). Last update [8c7b973...9154732](https://codecov.io/gh/pandas-dev/pandas/pull/16072?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).