ktmud commented on a change in pull request #16450:
URL: https://github.com/apache/superset/pull/16450#discussion_r697651134
##########
File path: superset/common/query_context.py
##########
@@ -276,11 +278,19 @@ def get_query_result(self, query_object: QueryObject) ->
QueryResult:
@staticmethod
def df_metrics_to_num(df: pd.DataFrame, query_object: QueryObject) -> None:
"""Converting metrics to numeric when pandas.read_sql cannot"""
+ metric_names: List[str] = query_object.metric_names
for col, dtype in df.dtypes.items():
- if dtype.type == np.object_ and col in query_object.metric_names:
+ if dtype.type == np.object_ and col in metric_names:
# soft-convert a metric column to numeric
# will stay as strings if conversion fails
- df[col] = df[col].infer_objects()
+ df[col] = pd.to_numeric(
+ df[col]
+ .replace(INFINITY_LITERALS, np.inf)
+ .replace(NEGATIVE_INFINITY_LITERALS, -np.inf),
Review comment:
Good idea. I'll update.
--
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]