codeant-ai-for-open-source[bot] commented on code in PR #45823:
URL: https://github.com/apache/superset/pull/45823#discussion_r4404144860
##########
superset/commands/dataset/importers/v1/utils.py:
##########
@@ -770,7 +770,7 @@ def _convert_temporal_columns(df: pd.DataFrame, dtype:
dict[str, Any]) -> None:
for column_name, sqla_type in dtype.items():
if isinstance(sqla_type, (Date, DateTime)):
try:
- df[column_name] = pd.to_datetime(df[column_name])
+ df[column_name] =
pd.to_datetime(df[column_name]).dt.as_unit("ns")
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `34048a8`.
The code checks that `pd.to_datetime` returned a datetime dtype before
calling `.dt.as_unit`. Other results fall through to per-value conversion
instead of raising on `.dt`.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/utils/pandas_postprocessing/pivot.py:
##########
@@ -404,8 +404,6 @@ def pivot( # pylint: disable=too-many-arguments # noqa:
C901
df = _apply_show_values_as(df, percent_mode)
if combine_value_with_metric:
- # dropna=False preserves restored all-NaN metric rows that would
otherwise
- # be silently dropped by stack's default dropna=True behavior.
- df = df.stack(level=0, dropna=False).unstack()
+ df = df.stack(level=0, future_stack=True).unstack()
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `34048a8`.
The columns are reshaped by reordering and sorting the MultiIndex levels,
rather than stacking and unstacking, which would recreate absent pairs.
<sub>If that's not right, unresolve this thread and CodeAnt will leave it
open.</sub>
<!-- codeant-auto-resolve-reply -->
##########
superset/utils/pandas_postprocessing/boxplot.py:
##########
@@ -135,7 +135,7 @@ def outliers(series: Series) -> set[float]:
# nanpercentile needs numeric values, otherwise the isnan function
# that's used in the underlying function will fail
for column in metrics:
- if is_object_dtype(df[column]):
- df.loc[:, column] = to_numeric(df[column], errors="coerce")
+ if is_object_dtype(df[column]) or is_string_dtype(df[column]):
+ df[column] = to_numeric(df[column], errors="coerce")
Review Comment:
✅ **CodeAnt verified this suggestion was addressed in subsequent commits and
marked this thread resolved** as of `34048a8`.
String/object metric columns are converted with
`to_numeric(errors="raise")`; malformed values now raise
`InvalidPostProcessingError` instead of being silently turned into NaN.
<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]