|
3 | 3 | import pandas |
4 | 4 | import numpy as np |
5 | 5 | import json |
| 6 | +import warnings |
6 | 7 |
|
7 | 8 | from types import FunctionType |
8 | 9 | from IPython.display import display |
@@ -969,9 +970,11 @@ def should_be_stringified(col_series): |
969 | 970 | else: |
970 | 971 | self._row_styles = {} |
971 | 972 |
|
972 | | - df_json = df.to_json( |
973 | | - None, orient="table", date_format="iso", double_precision=self.precision |
974 | | - ) |
| 973 | + with warnings.catch_warnings(): |
| 974 | + warnings.simplefilter("ignore", category=UserWarning) |
| 975 | + df_json = df.to_json( |
| 976 | + None, orient="table", date_format="iso", double_precision=self.precision |
| 977 | + ) |
975 | 978 |
|
976 | 979 | if update_columns: |
977 | 980 | self._interval_columns = [] |
@@ -1046,9 +1049,14 @@ def should_be_stringified(col_series): |
1046 | 1049 | # and then call 'to_json' again to get a new version of the table |
1047 | 1050 | # json that has interval columns replaced with text columns |
1048 | 1051 | if len(self._interval_columns) > 0 or len(self._period_columns) > 0: |
1049 | | - df_json = df.to_json( |
1050 | | - None, orient="table", date_format="iso", double_precision=self.precision |
1051 | | - ) |
| 1052 | + with warnings.catch_warnings(): |
| 1053 | + warnings.simplefilter("ignore", category=UserWarning) |
| 1054 | + df_json = df.to_json( |
| 1055 | + None, |
| 1056 | + orient="table", |
| 1057 | + date_format="iso", |
| 1058 | + double_precision=self.precision, |
| 1059 | + ) |
1052 | 1060 |
|
1053 | 1061 | self._df_json = df_json |
1054 | 1062 |
|
@@ -1490,7 +1498,10 @@ def _handle_change_filter(self, content): |
1490 | 1498 |
|
1491 | 1499 | def _handle_view_msg(self, widget, content, buffers=None): |
1492 | 1500 | try: |
1493 | | - self._handle_view_msg_helper(content) |
| 1501 | + # Ignore UserWarnings in spreadsheet widget |
| 1502 | + with warnings.catch_warnings(): |
| 1503 | + warnings.simplefilter("ignore", category=UserWarning) |
| 1504 | + self._handle_view_msg_helper(content) |
1494 | 1505 | except Exception as e: |
1495 | 1506 | self.log.error(e) |
1496 | 1507 | self.log.exception("Unhandled exception while handling msg") |
|
0 commit comments