codeant-ai-for-open-source[bot] commented on code in PR #45441:
URL: https://github.com/apache/superset/pull/45441#discussion_r4354944589
##########
superset/utils/csv.py:
##########
@@ -102,18 +102,14 @@ def escape_values(v: Any) -> Union[str, Any]:
# Escape csv headers
df = df.rename(columns=escape_values)
- # Escape csv values. Iterate by index label (via ``items``) rather than by
- # positional offset so the escaped value is written back to the correct row
- # even when the DataFrame has a non-default index (e.g. the flattened
- # MultiIndex produced by pivot_table_v2 post-processing). Pairing
positional
- # indices with the label-based ``.at`` accessor would otherwise create
- # phantom rows and corrupt the output. Only string cells are reassigned, so
- # the dtype of mixed object columns (e.g. nullable integers) is preserved.
- for name, column in df.items():
+ # Address cells by position: row and column labels need not be unique, and
+ # escaping column names can turn distinct labels into duplicates. Only
+ # string cells are reassigned to preserve numeric and nullable dtypes.
+ for column_index, (_, column) in enumerate(df.items()):
if pd.api.types.is_string_dtype(column.dtype):
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `15547a0`.
Added a `CategoricalDtype` branch that maps `escape_values` over the column
before CSV export, escaping string-valued categorical cells.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
--
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]