Follow-up #20347: incorporate review about _get_series_list
State: closed

Closes #20922

recap of #20347 :
Enabling alignment on top of the (v.0.22-)legal list of lists was relatively complex. The allowed argument types implemented in #20347 are as follows:

```
Type of (element of) "others"        | alone | within list-like
---------------------------------------------------------------------
pd.Series                            |  yes  | yes
pd.Index                             |  yes  | yes
np.ndarray (1-dim)                   |  yes  | yes
DataFrame                            |  yes  | no
np.ndarray (2-dim)                   |  yes  | no
iterators, dict-views, etc.          |  yes  | **
anything else w/ is_list_like = True |  yes  | **
```

** to be permitted, list-likes (say `nxt`) within a list-like `others` must pass (essentially)
```all(not is_list_like(x) for x in nxt)```
and not be a DF.

Open review points from #20347 from @jreback (and my responses) reproduced in review comments.

PS. Managed to have a brainfart and there's a bug in the RC docs - very sorry. Fixed in this PR.

Labels:
name: Strings
description: String extension data type and string data
name: Clean

Comments:
@TomAugspurger from #20922 
> Some requests for simplification. Most of the complexity seems to be in the code inferring what kind of regime we're in (one or more alignable objects vs. one or more unalignable objects vs. mix). Being strict here (after deprecating) or requiring additional user input may be worthwhile from a maintenance perspective.

What do you mean by being strict. Could you maybe edit the table from above to reflect what you think should be allowed?

@TomAugspurger 
Since I saw you're doing an RC2 due to #20924, would you consider merging this PR (or a separate one) for fixing the embarassing (for me) doc-error?

This PR will (almost certainly) be fully green in ~1h.
Nope, just doing build stuff right now.
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20923?src=pr&el=h1) Report
> Merging [#20923](https://codecov.io/gh/pandas-dev/pandas/pull/20923?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/ce4ab828d882a0c50f2f63921621ccae0d14b5ae?src=pr&el=desc) will **decrease** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master   #20923      +/-   ##
==========================================
- Coverage   91.81%   91.81%   -0.01%     
==========================================
  Files         153      153              
  Lines       49471    49470       -1     
==========================================
- Hits        45422    45421       -1     
  Misses       4049     4049
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.21% <100%> (-0.01%)` | :arrow_down: |
| #single | `41.84% <0%> (ø)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/20923?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/strings.py](https://codecov.io/gh/pandas-dev/pandas/pull/20923/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc3RyaW5ncy5weQ==) | `98.62% <100%> (-0.01%)` | :arrow_down: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/20923?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/20923?src=pr&el=footer). Last update [ce4ab82...3bf38a0](https://codecov.io/gh/pandas-dev/pandas/pull/20923?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

other than my comment above the cleanup looks good.
> a dict is treated consistently here how we handle list-likes else where, we effectively call list on it

In that case, I think this PR is good to go.
@jreback @TomAugspurger @jorisvandenbossche 
re: treatment of dicts:
FWIW, `concat` does a very similar kind of operation to `str.cat`, and does treat dicts differently (than calling list on them):
```
d = {'a' : pd.Series([0, 1]), 'b': pd.Series(['c', 'd'])}
pd.concat(d, axis=1)
#    a  b
# 0  0  c
# 1  1  d
pd.concat(d.values(), axis=1)
#    0  1
# 0  0  c
# 1  1  d
pd.concat(list(d), axis=1)
# TypeError
```

OTOH, I'm honestly fine to leave this PR as it is. Special treatment for dicts should be a separate issue, IMHO.
thanks @h-vetinari good followup!

as far as dicts go, certainly welcome clarification if needed (PR / issue all ok), or can just wait and see if that usecase is seen in real life
@jreback 
Glad this PR is done, TBH. Thanks for all the reviews and feedback!