From cefb5228e1354653a8ea8ac16dd38547d427c006 Mon Sep 17 00:00:00 2001 From: "ekaterina.itsenko" Date: Wed, 2 Oct 2024 19:02:08 +0200 Subject: [PATCH] [pycharm] PY-72208 Tables(Jupyter, SciView): Refactoring, fix tiny errors GitOrigin-RevId: a936672fbdf51c9692150bd7c78721988abde3f7 --- .../_pydevd_bundle/tables/pydevd_dataset.py | 18 +++++++++++------- .../_pydevd_bundle/tables/pydevd_pandas.py | 18 +++++++++++------- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py index 97b586ec0b43..b78e0b4b76fb 100644 --- a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py +++ b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py @@ -49,23 +49,27 @@ def get_data(table, use_csv_serialization, start_index=None, end_index=None, for return computed_data -def __ipython_display(data): - from IPython.display import display - display(data) - - # used by DSTableCommands # noinspection PyUnresolvedReferences def display_data_csv(table, start_index, end_index): # type: (datasets.arrow_dataset.Dataset, int, int) -> None - _compute_sliced_data(table, __ipython_display, start_index, end_index) + def ipython_display(data): + try: + data = data.to_csv() + except AttributeError: + pass + print(data) + _compute_sliced_data(table, ipython_display, end_index) # used by DSTableCommands # noinspection PyUnresolvedReferences def display_data_html(table, start_index, end_index): # type: (datasets.arrow_dataset.Dataset, int, int) -> None - _compute_sliced_data(table, __ipython_display, start_index, end_index) + def ipython_display(data): + from IPython.display import display + display(data) + _compute_sliced_data(table, ipython_display, end_index) def __get_data_slice(table, start, end): diff --git a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py index 3b95497fd025..e24b567ce8c9 100644 --- a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py +++ b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py @@ -50,23 +50,27 @@ def get_data(table, use_csv_serialization, start_index=None, end_index=None, for return computed_data -def __ipython_display(data): - from IPython.display import display - display(__convert_to_df(data)) - - # used by DSTableCommands # noinspection PyUnresolvedReferences def display_data_csv(table, start_index, end_index): # type: (Union[pd.DataFrame, pd.Series], int, int) -> None - _compute_sliced_data(table, __ipython_display, start_index, end_index) + def ipython_display(data): + try: + data = data.to_csv() + except AttributeError: + pass + print(__convert_to_df(data)) + _compute_sliced_data(table, ipython_display, start_index, end_index) # used by DSTableCommands # noinspection PyUnresolvedReferences def display_data_html(table, start_index, end_index): # type: (Union[pd.DataFrame, pd.Series], int, int) -> None - _compute_sliced_data(table, __ipython_display, start_index, end_index) + def ipython_display(data): + from IPython.display import display + display(__convert_to_df(data)) + _compute_sliced_data(table, ipython_display, start_index, end_index) def __get_data_slice(table, start, end):