Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automatic PR for 3fe98d38-a9f7-4882-87ea-42502d433c61 #84

Open
wants to merge 1 commit into
base: 3fe98d38-a9f7-4882-87ea-42502d433c61-base
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions pandas/core/internals/construction.py
Original file line number Diff line number Diff line change
Expand Up @@ -675,7 +675,8 @@ def reorder_arrays(
if columns is not None:
if not columns.equals(arr_columns):
# if they are equal, there is nothing to do
new_arrays: list[ArrayLike] = []
new_arrays: list[ArrayLike | None]
new_arrays = [None] * len(columns)
indexer = arr_columns.get_indexer(columns)
for i, k in enumerate(indexer):
if k == -1:
Expand All @@ -684,9 +685,12 @@ def reorder_arrays(
arr.fill(np.nan)
else:
arr = arrays[k]
new_arrays.append(arr)
new_arrays[i] = arr

arrays = new_arrays
# Incompatible types in assignment (expression has type
# "List[Union[ExtensionArray, ndarray[Any, Any], None]]", variable
# has type "List[Union[ExtensionArray, ndarray[Any, Any]]]")
arrays = new_arrays # type: ignore[assignment]
arr_columns = columns

return arrays, arr_columns
Expand Down Expand Up @@ -1038,4 +1042,4 @@ def convert(arr):

arrays = [convert(arr) for arr in content]

return arrays
return arrays