Skip to content

Commit

Permalink
avoid repeat where possible
Browse files Browse the repository at this point in the history
  • Loading branch information
samukweku committed Nov 5, 2023
1 parent aaeb485 commit 5d6ad68
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions janitor/functions/conditional_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -1119,13 +1119,17 @@ def _create_multiindex_column(df: pd.DataFrame, right: pd.DataFrame):
"""
Create a MultiIndex column for conditional_join.
"""
header = [np.array(["left"]).repeat(df.columns.size)]
header = np.empty(df.columns.size, dtype="U4")
header[:] = "left"
header = [header]
columns = [
df.columns.get_level_values(n) for n in range(df.columns.nlevels)
]
header.extend(columns)
df.columns = pd.MultiIndex.from_arrays(header)
header = [np.array(["right"]).repeat(right.columns.size)]
header = np.empty(right.columns.size, dtype="U5")
header[:] = "right"
header = [header]
columns = [
right.columns.get_level_values(n) for n in range(right.columns.nlevels)
]
Expand Down

0 comments on commit 5d6ad68

Please sign in to comment.