BUG: .groupby on Series' values without reindexing
State: closed

 - [X] closes #15338
 - [X] tests added / passed
 - [X] passes ``git diff upstream/master | flake8 --diff``
 - [X] whatsnew entry


Labels:
name: Groupby

Comments:
see my comments on the issue.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15340?src=pr&el=h1) Report
> Merging [#15340](https://codecov.io/gh/pandas-dev/pandas/pull/15340?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/542c9166a6ceff4a4889caae3843c3a82a2301cd?src=pr&el=desc) will **not impact** coverage.


```diff
@@           Coverage Diff           @@
##           master   #15340   +/-   ##
=======================================
  Coverage   86.32%   86.32%           
=======================================
  Files         141      141           
  Lines       51165    51165           
=======================================
  Hits        44169    44169           
  Misses       6996     6996
```


| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/15340?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/groupby.py](https://codecov.io/gh/pandas-dev/pandas/compare/542c9166a6ceff4a4889caae3843c3a82a2301cd...87d617029950ab2e85f32dee8a0806703045ae31?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZ3JvdXBieS5weQ==) | `95.15% <100%> (ø)` | :white_check_mark: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/15340?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/15340?src=pr&el=footer). Last update [542c916...87d6170](https://codecov.io/gh/pandas-dev/pandas/compare/542c9166a6ceff4a4889caae3843c3a82a2301cd...87d617029950ab2e85f32dee8a0806703045ae31?src=pr&el=footer&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
so this changes the actual behavior. why is this warranted?
I don't know if it is. The docs say in case of series, the values will be used as grouping keys. I guess in this instance I don't see series as much different from any other series of values, like lists or numpy arrays. I don't know why aligning is necessary, particularly if the series of keys comes from another source (if not, why would it be passed as a series explicitly instead of by a column reference), in which case the index can be arbitrary and the result of alignment just as so.

In other words, if the grouping series is from the same source (i.e. the same frame) as the grouped object, then it already shares the same index, hence aligning is not necessary.
If the series is from a different source, then automatically aligning might be dangerous. I highly appreciate the fact that an indexed series makes a great random-access key-value store, but I assume most users don't treat it as such in preference to somewhat simpler _ordered array of values which happens to have an additional index_.

Ideally, I'd have `.groupby()` fail if the passed grouping is a Sequence and its length doesn't match. Otherwise, it should behave as it does when passed a list.

Of course, Series is not a Sequence?? :flushed: 
> so this changes the actual behavior. why is this warranted?

It's wholly compatible with the docs, and it doesn't break any previous tests. :laughing: 
@kernc this certainly changes behavior. The entire point is to align. This is actually very confusing what you changed. Virtually every operation in pandas aligns. Why would this not?
Thanks for treating me like a pandas expert I'm not. :heart: 

In that case, I agree a remark in the docs (docstring) would be welcome.
@kernc hahh, np.

if you'd like to do a PR for the doc-string would be great.