From a3098cd20602b8e0738fcec21cafd47da68fef68 Mon Sep 17 00:00:00 2001 From: "Natalia.Murycheva" Date: Fri, 22 Aug 2025 00:19:13 +0200 Subject: [PATCH] [PyTables] PY-81433 More cleanup; Added a new inspection (column with one value) GitOrigin-RevId: 47bbbd38a606a580b53beb3bf6d467ec2cd49070 --- .../_pydevd_bundle/tables/pydevd_pandas.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py index 20d3e3c8e802..e06defb78922 100644 --- a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py +++ b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py @@ -194,6 +194,7 @@ def get_inspection_outliers(table): result = {} try: result[InspectionResultsDict.KEY_STATUS] = InspectionResultsDict.VALUE_STATUS_SUCCESS + # TODO: old versions from pandas.api.types import is_numeric_dtype results_details_per_column = [] for col in table.columns: @@ -228,6 +229,32 @@ def get_inspection_outliers(table): return __serialize_in_json(result, "Outliers") +def get_inspection_constant_columns(table): + result = {} + try: + result[InspectionResultsDict.KEY_STATUS] = InspectionResultsDict.VALUE_STATUS_SUCCESS + results_details_per_column = [] + for col in table.columns: + if table[col].nunique(dropna=False) == 1: + results_details_per_column.append({ + "columnName": col, + "value": str(table[col].iloc[0]) + }) + if len(results_details_per_column) == 0: + result[InspectionResultsDict.KEY_IS_TRIGGERED] = InspectionResultsDict.VALUE_TRIGGERED_NO + else: + result[InspectionResultsDict.KEY_IS_TRIGGERED] = InspectionResultsDict.VALUE_TRIGGERED_YES + result[InspectionResultsDict.KEY_DETAILS] = { + InspectionResultsDict.KEY_DETAILS_TYPE: InspectionResultsDict.VALUE_DETAILS_TYPE_PER_COLUMN, + InspectionResultsDict.KEY_DETAILS_VALUE: results_details_per_column + } + + except: + result[InspectionResultsDict.KEY_STATUS] = InspectionResultsDict.VALUE_STATUS_FAILED + result[InspectionResultsDict.KEY_IS_TRIGGERED] = InspectionResultsDict.VALUE_TRIGGERED_NO + return __serialize_in_json(result, "Constant Columns") + + def __get_data_slice(table, start, end): return __convert_to_df(table).iloc[start:end]