bito-code-review[bot] commented on PR #45018:
URL: https://github.com/apache/superset/pull/45018#issuecomment-6011486166
<!-- Bito Reply -->
The flagged issue is correct. When using `pd.concat` with `axis="columns"`,
pandas aligns dataframes by their index. If the input dataframes have different
indices (e.g., one has a `RangeIndex` and the other has a custom index),
`pd.concat` will perform an outer join, potentially introducing unintended rows
or `NaN` values where indices do not match.
To resolve this, you should ensure the indices are aligned before
concatenation, for example by resetting the index or ensuring both dataframes
share the same index:
```python
# Ensure indices match before concatenation
appended_df = append_df.loc[:, appended.keys()].rename(columns=appended)
appended_df.index = _base_df.index
return pd.concat([_base_df, appended_df], axis="columns")
```
Would you like me to fetch all other comments on this PR to validate and
implement fixes for them as well?
**superset/utils/pandas_postprocessing/utils.py**
```
# Ensure indices match before concatenation
appended_df = append_df.loc[:, appended.keys()].rename(columns=appended)
appended_df.index = _base_df.index
return pd.concat([_base_df, appended_df], axis="columns")
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]