DS-5198 Support enhanced tooltips for Polars tables

Added the Statistics tooltip for Polars DataFrames.

Merge-request: IJ-MR-110003
Merged-by: Natalia Murycheva <natalia.murycheva@jetbrains.com>

GitOrigin-RevId: ba829e711772837081f2eeadd00775542720086d
This commit is contained in:
Natalia.Murycheva
2023-07-07 12:40:50 +00:00
committed by intellij-monorepo-bot
parent f8bf234443
commit 3a158ffe44
2 changed files with 19 additions and 1 deletions
@@ -76,7 +76,7 @@ def display_data(table, max_cols, max_colwidth, start, end):
pd.set_option('display.max_colwidth', _jb_max_colwidth)
def get_column_desciptions(table, max_cols, max_colwidth):
def get_column_descriptions(table, max_cols, max_colwidth):
# type: (pd.DataFrame, int, int) -> str
described_df = __get_describe_df(table)
@@ -45,3 +45,21 @@ def display_data(table, max_cols, max_colwidth, start, end):
def __create_config():
# type: () -> pl.Config
return pl.Config(fmt_str_lengths=1000, set_tbl_cols=-1)
def get_column_descriptions(table, max_cols, max_colwidth):
# type: (pl.DataFrame, int, int) -> str
described_df = __get_describe_df(table)
return get_data(described_df, max_cols, max_colwidth, None, None)
# Polars compute NaN-s in describe. So, we don't need get_value_counts for Polars
def get_value_counts(table, max_cols, max_colwidth):
# type: (pl.DataFrame, int, int) -> str
return
def __get_describe_df(table):
# type: (pl.DataFrame) -> pl.DataFrame
return table.describe(percentiles=(0.05, 0.25, 0.5, 0.75, 0.95))