diff --git a/bqplot/traits.py b/bqplot/traits.py index 95f4efb3f..dafaddfbb 100644 --- a/bqplot/traits.py +++ b/bqplot/traits.py @@ -239,7 +239,9 @@ def dataframe_to_json(df, obj): if df is None: return None else: - return df.to_dict(orient='records') + # Replacing NaNs with None as it's not valid JSON + cleandf = df.fillna(np.nan).replace([np.nan], [None]) + return cleandf.to_dict(orient='records') dataframe_serialization = dict(to_json=dataframe_to_json, from_json=dataframe_from_json) diff --git a/js/src/Map.ts b/js/src/Map.ts index d0b109461..4ff9164f0 100644 --- a/js/src/Map.ts +++ b/js/src/Map.ts @@ -454,7 +454,6 @@ export class Map extends Mark { } else if ( color_data[d.id] === undefined || color_data[d.id] === null || - color_data[d.id] === 'nan' || color_scale === undefined ) { return colors.default_color; diff --git a/js/src/MarketMap.ts b/js/src/MarketMap.ts index 724c3380d..96d526c9b 100644 --- a/js/src/MarketMap.ts +++ b/js/src/MarketMap.ts @@ -791,9 +791,15 @@ export class MarketMap extends Figure { .append('td') .attr('class', 'tooltiptext') .text((datum, index) => { - return ref_data === null || ref_data === undefined - ? null - : that.tooltip_formats[index](ref_data[datum]); + if (ref_data === null || ref_data === undefined) { + return null; + } + + if (ref_data[datum] === null || ref_data[datum] === undefined) { + return 'N/A'; + } + + return that.tooltip_formats[index](ref_data[datum]); }); } this.popper.enableEventListeners(); diff --git a/test-environment.yml b/test-environment.yml index be28aa524..c953b056f 100644 --- a/test-environment.yml +++ b/test-environment.yml @@ -11,7 +11,6 @@ dependencies: - numpy >=1.10.4,<2.0.0 - pandas >=1.0.0,<2.0.0 - scipy - - jupyter - jupyterlab=3.0.11 # to build the lab federated bundle - jupyter-packaging # to build the wheel - pytest