dosubot[bot] commented on issue #30301: URL: https://github.com/apache/superset/issues/30301#issuecomment-2354199490
<!-- Answer --> I found a similar closed issue that might be relevant to your problem: [[Table Viz] "unsupported operant type errors" in percentage metrics](https://github.com/apache/superset/issues/15440) <sup>[[1]](https://github.com/apache/superset/issues/15440)</sup>. The error "The column 'start_rate' must be numeric" occurs because the Histogram chart in Superset requires the specified column to be numeric. The `histogram` function in the `superset/utils/pandas_postprocessing/histogram.py` file checks if the column is numeric and raises a `ValueError` if it is not. To ensure that the `start_rate` column is treated as numeric, you should verify that its datatype in the Postgres database is correctly set to a numeric type (e.g., `decimal`, `float`, `integer`). Additionally, ensure that the column is included in the `numeric_columns` list in the form data for the Histogram chart. Here is the relevant part of the `histogram` function: ```python def histogram( df: DataFrame, column: str, groupby: list[str] | None, bins: int = 5, cumulative: bool = False, normalize: bool = False, ) -> DataFrame: """ Generate a histogram DataFrame from a given DataFrame. Parameters: df (DataFrame): The input DataFrame. column (str): The column of the DataFrame to calculate the histogram on. groupby (list[str]): The columns to group by. If empty, no grouping is performed. bins (int): The number of bins to use for the histogram. Default is 5. cumulative (bool): Whether to calculate a cumulative histogram. Default is False. normalize (bool): Whether to normalize the histogram. Default is False. Returns: DataFrame: A DataFrame where each row corresponds to a group (or the entire DataFrame if no grouping is performed), and each column corresponds to a histogram bin. The values are the counts in each bin. """ if groupby is None: groupby = [] # check if the column is numeric if not np.issubdtype(df[column].dtype, np.number): raise ValueError(f"The column '{column}' must be numeric.") ``` Ensure that the `start_rate` column is included in the `numeric_columns` list in the form data. If it is not, you will need to update the form data to include it. Additionally, verify that the column's datatype in the Postgres database is correctly set to a numeric type <sup>[[2]](https://github.com/apache/superset/blob/master/superset/viz.py)</sup><sup>[[3]](https://github.com/apache/superset/blob/master/superset/utils/pandas_postprocessing/histogram.py)</sup>. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* -- 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]
