From 48cd6487ae1f1c675cafe46905d4f1e3fcf43402 Mon Sep 17 00:00:00 2001 From: "Natalia.Murycheva" Date: Thu, 17 Oct 2024 15:44:53 +0200 Subject: [PATCH] [PyCharm Tables] PY-76675 Fixed rendering Python None values in the csv case for pandas, polars frameworks (cherry picked from commit f823121ce4adc23d6e9b8e03b87b8b19a789a46b) (cherry picked from commit 93d7530c7ce0ba60fee5d1d0e909a39ce3b9dc65) IJ-CR-147319 GitOrigin-RevId: d6dd4a5f63f172685df3e1a1c0d3d6cbcb063071 --- python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py | 4 ++-- python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py | 4 ++-- python/helpers/pydev/_pydevd_bundle/tables/pydevd_polars.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py index 4cb7069a7d9a..c8da839fff96 100644 --- a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py +++ b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_dataset.py @@ -37,7 +37,7 @@ def get_data(table, use_csv_serialization, start_index=None, end_index=None, for # type: (datasets.arrow_dataset.Dataset, int, int) -> str def convert_data_to_csv(data): - return repr(data.to_csv()) + return repr(data.to_csv(na_rep = "NaN")) def convert_data_to_html(data): return repr(data.to_html(notebook=True)) @@ -55,7 +55,7 @@ def display_data_csv(table, start_index, end_index): # type: (datasets.arrow_dataset.Dataset, int, int) -> None def ipython_display(data): try: - data = data.to_csv() + data = data.to_csv(na_rep = "NaN") except AttributeError: pass print(data) diff --git a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py index 1e145c5b4185..755ecb9bb17b 100644 --- a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py +++ b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_pandas.py @@ -38,7 +38,7 @@ def get_data(table, use_csv_serialization, start_index=None, end_index=None, for # type: (Union[pd.DataFrame, pd.Series], int, int) -> str def convert_data_to_csv(data): - return repr(__convert_to_df(data).to_csv()) + return repr(__convert_to_df(data).to_csv(na_rep = "NaN")) def convert_data_to_html(data): return repr(__convert_to_df(data).to_html(notebook=True)) @@ -56,7 +56,7 @@ def display_data_csv(table, start_index, end_index): # type: (Union[pd.DataFrame, pd.Series], int, int) -> None def ipython_display(data): try: - data = data.to_csv() + data = data.to_csv(na_rep = "NaN") except AttributeError: pass print(__convert_to_df(data)) diff --git a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_polars.py b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_polars.py index 216268fa0888..9d37d67c54ab 100644 --- a/python/helpers/pydev/_pydevd_bundle/tables/pydevd_polars.py +++ b/python/helpers/pydev/_pydevd_bundle/tables/pydevd_polars.py @@ -37,7 +37,7 @@ def get_data(table, use_csv_serialization, start_index=None, end_index=None, for # type: (pl.DataFrame, int, int) -> str with __create_config(format): if use_csv_serialization: - return __get_df_slice(table, start_index, end_index).write_csv() + return __get_df_slice(table, start_index, end_index).write_csv(null_value = "null") return table[start_index:end_index]._repr_html_() @@ -51,7 +51,7 @@ def display_data_html(table, start, end): def display_data_csv(table, start, end): # type: (pl.DataFrame, int, int) -> None with __create_config(): - print(__get_df_slice(table, start, end).write_csv()) + print(__get_df_slice(table, start, end).write_csv(null_value = "null")) def __get_df_slice(table, start_index, end_index):