File tree Expand file tree Collapse file tree 1 file changed +6
-16
lines changed Expand file tree Collapse file tree 1 file changed +6
-16
lines changed Original file line number Diff line number Diff line change @@ -4153,7 +4153,8 @@ def reindex(
41534153 preserve_names = not hasattr (target , "name" )
41544154
41554155 # GH7774: preserve dtype/tz if target is empty and not an Index.
4156- target = ensure_has_len (target ) # target may be an iterator
4156+ if is_iterator (target ):
4157+ target = list (target )
41574158
41584159 if not isinstance (target , Index ) and len (target ) == 0 :
41594160 if level is not None and self ._is_multi :
@@ -7564,21 +7565,9 @@ def ensure_index(index_like: Axes, copy: bool = False) -> Index:
75647565 return Index (index_like , copy = copy )
75657566
75667567
7567- def ensure_has_len (seq ):
7568- """
7569- If seq is an iterator, put its values into a list.
7570- """
7571- try :
7572- len (seq )
7573- except TypeError :
7574- return list (seq )
7575- else :
7576- return seq
7577-
7578-
75797568def trim_front (strings : list [str ]) -> list [str ]:
75807569 """
7581- Trims zeros and decimal points .
7570+ Trims leading spaces evenly among all strings .
75827571
75837572 Examples
75847573 --------
@@ -7590,8 +7579,9 @@ def trim_front(strings: list[str]) -> list[str]:
75907579 """
75917580 if not strings :
75927581 return strings
7593- while all (strings ) and all (x [0 ] == " " for x in strings ):
7594- strings = [x [1 :] for x in strings ]
7582+ smallest_leading_space = min (len (x ) - len (x .lstrip ()) for x in strings )
7583+ if smallest_leading_space > 0 :
7584+ strings = [x [smallest_leading_space :] for x in strings ]
75957585 return strings
75967586
75977587
You can’t perform that action at this time.
0 commit comments