We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
pydeck_chart: Error (not a valid JSON) when data contains NaN
### Checklist

- [X] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.
- [X] I added a very descriptive title to this issue.
- [X] I have provided sufficient information below to help reproduce this issue.

### Summary

If the data used in pydeck contains NaN (even if it is not used), the application fails with 
![image](https://user-images.githubusercontent.com/25638902/205078988-992fdce1-a6b8-4183-9237-5cd4e358e2ff.png)


### Reproducible Code Example

```Python
import math, pandas, pydeck, streamlit

streamlit.set_page_config(layout="wide")
data = pandas.DataFrame({"lng": [-109.037673], "lat": [36.994672], "weight": [math.nan]})
layer = pydeck.Layer("ScatterplotLayer", data=data, get_position=["lng", "lat"], radius_min_pixels=4)
deck = pydeck.Deck(layers=[layer], map_style=pydeck.map_styles.CARTO_LIGHT, tooltip={"text": "weight: {weight}"})
deck.to_html("test.html")
streamlit.pydeck_chart(deck, use_container_width=True)
```


### Steps To Reproduce

Run the code as usual.

### Expected Behavior

No error, as in the file ```test.html``` generated

### Current Behavior

SyntaxError:
Unexpected token 'N', ...""weight": NaN "... is not valid JSON


### Is this a regression?

- [ ] Yes, this used to work in a previous version.

### Debug info

- Streamlit version: Streamlit v1.15.1
- Python version: 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]
- Operating System: Windows 10.0.19045.2251
- Browser: Chome, Opera, Edge, Firefox
- Virtual environment: poetry


### Additional Information

_No response_

### Are you willing to submit a PR?

- [ ] Yes, I am willing to submit a PR!

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `e2e/scripts/st_pydeck_chart.py`
Content:
```
1 # Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022)
2 #
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
6 #
7 #     http://www.apache.org/licenses/LICENSE-2.0
8 #
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
14 
15 from typing import Any, cast
16 
17 import numpy as np
18 import pandas as pd
19 import pydeck as pdk
20 
21 import streamlit as st
22 
23 # Empty chart.
24 
25 st.pydeck_chart()
26 
27 # Basic chart.
28 
29 np.random.seed(12345)
30 
31 df = pd.DataFrame(
32     cast(Any, np.random.randn(1000, 2) / [50, 50]) + [37.76, -122.4],
33     columns=["lat", "lon"],
34 )
35 
36 st.pydeck_chart(
37     pdk.Deck(
38         map_style="mapbox://styles/mapbox/light-v9",
39         initial_view_state=pdk.ViewState(
40             latitude=37.76,
41             longitude=-122.4,
42             zoom=11,
43             pitch=50,
44         ),
45         layers=[
46             pdk.Layer(
47                 "HexagonLayer",
48                 data=df,
49                 get_position="[lon, lat]",
50                 radius=200,
51                 elevation_scale=4,
52                 elevation_range=[0, 1000],
53                 pickable=True,
54                 extruded=True,
55             ),
56             pdk.Layer(
57                 "ScatterplotLayer",
58                 data=df,
59                 get_position="[lon, lat]",
60                 get_color="[200, 30, 0, 160]",
61                 get_radius=200,
62             ),
63         ],
64     )
65 )
66
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/e2e/scripts/st_pydeck_chart.py b/e2e/scripts/st_pydeck_chart.py
--- a/e2e/scripts/st_pydeck_chart.py
+++ b/e2e/scripts/st_pydeck_chart.py
@@ -12,6 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import math
 from typing import Any, cast
 
 import numpy as np
@@ -63,3 +64,15 @@
         ],
     )
 )
+
+# Chart w/ invalid JSON - issue #5799.
+data = pd.DataFrame({"lng": [-109.037673], "lat": [36.994672], "weight": [math.nan]})
+layer = pdk.Layer(
+    "ScatterplotLayer", data=data, get_position=["lng", "lat"], radius_min_pixels=4
+)
+deck = pdk.Deck(
+    layers=[layer],
+    map_style=pdk.map_styles.CARTO_LIGHT,
+    tooltip={"text": "weight: {weight}"},
+)
+st.pydeck_chart(deck, use_container_width=True)

{"golden_diff": "diff --git a/e2e/scripts/st_pydeck_chart.py b/e2e/scripts/st_pydeck_chart.py\n--- a/e2e/scripts/st_pydeck_chart.py\n+++ b/e2e/scripts/st_pydeck_chart.py\n@@ -12,6 +12,7 @@\n # See the License for the specific language governing permissions and\n # limitations under the License.\n \n+import math\n from typing import Any, cast\n \n import numpy as np\n@@ -63,3 +64,15 @@\n         ],\n     )\n )\n+\n+# Chart w/ invalid JSON - issue #5799.\n+data = pd.DataFrame({\"lng\": [-109.037673], \"lat\": [36.994672], \"weight\": [math.nan]})\n+layer = pdk.Layer(\n+    \"ScatterplotLayer\", data=data, get_position=[\"lng\", \"lat\"], radius_min_pixels=4\n+)\n+deck = pdk.Deck(\n+    layers=[layer],\n+    map_style=pdk.map_styles.CARTO_LIGHT,\n+    tooltip={\"text\": \"weight: {weight}\"},\n+)\n+st.pydeck_chart(deck, use_container_width=True)\n", "issue": "pydeck_chart: Error (not a valid JSON) when data contains NaN\n### Checklist\r\n\r\n- [X] I have searched the [existing issues](https://github.com/streamlit/streamlit/issues) for similar issues.\r\n- [X] I added a very descriptive title to this issue.\r\n- [X] I have provided sufficient information below to help reproduce this issue.\r\n\r\n### Summary\r\n\r\nIf the data used in pydeck contains NaN (even if it is not used), the application fails with \r\n![image](https://user-images.githubusercontent.com/25638902/205078988-992fdce1-a6b8-4183-9237-5cd4e358e2ff.png)\r\n\r\n\r\n### Reproducible Code Example\r\n\r\n```Python\r\nimport math, pandas, pydeck, streamlit\r\n\r\nstreamlit.set_page_config(layout=\"wide\")\r\ndata = pandas.DataFrame({\"lng\": [-109.037673], \"lat\": [36.994672], \"weight\": [math.nan]})\r\nlayer = pydeck.Layer(\"ScatterplotLayer\", data=data, get_position=[\"lng\", \"lat\"], radius_min_pixels=4)\r\ndeck = pydeck.Deck(layers=[layer], map_style=pydeck.map_styles.CARTO_LIGHT, tooltip={\"text\": \"weight: {weight}\"})\r\ndeck.to_html(\"test.html\")\r\nstreamlit.pydeck_chart(deck, use_container_width=True)\r\n```\r\n\r\n\r\n### Steps To Reproduce\r\n\r\nRun the code as usual.\r\n\r\n### Expected Behavior\r\n\r\nNo error, as in the file ```test.html``` generated\r\n\r\n### Current Behavior\r\n\r\nSyntaxError:\r\nUnexpected token 'N', ...\"\"weight\": NaN \"... is not valid JSON\r\n\r\n\r\n### Is this a regression?\r\n\r\n- [ ] Yes, this used to work in a previous version.\r\n\r\n### Debug info\r\n\r\n- Streamlit version: Streamlit v1.15.1\r\n- Python version: 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)]\r\n- Operating System: Windows 10.0.19045.2251\r\n- Browser: Chome, Opera, Edge, Firefox\r\n- Virtual environment: poetry\r\n\r\n\r\n### Additional Information\r\n\r\n_No response_\r\n\r\n### Are you willing to submit a PR?\r\n\r\n- [ ] Yes, I am willing to submit a PR!\n", "before_files": [{"content": "# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022)\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nfrom typing import Any, cast\n\nimport numpy as np\nimport pandas as pd\nimport pydeck as pdk\n\nimport streamlit as st\n\n# Empty chart.\n\nst.pydeck_chart()\n\n# Basic chart.\n\nnp.random.seed(12345)\n\ndf = pd.DataFrame(\n    cast(Any, np.random.randn(1000, 2) / [50, 50]) + [37.76, -122.4],\n    columns=[\"lat\", \"lon\"],\n)\n\nst.pydeck_chart(\n    pdk.Deck(\n        map_style=\"mapbox://styles/mapbox/light-v9\",\n        initial_view_state=pdk.ViewState(\n            latitude=37.76,\n            longitude=-122.4,\n            zoom=11,\n            pitch=50,\n        ),\n        layers=[\n            pdk.Layer(\n                \"HexagonLayer\",\n                data=df,\n                get_position=\"[lon, lat]\",\n                radius=200,\n                elevation_scale=4,\n                elevation_range=[0, 1000],\n                pickable=True,\n                extruded=True,\n            ),\n            pdk.Layer(\n                \"ScatterplotLayer\",\n                data=df,\n                get_position=\"[lon, lat]\",\n                get_color=\"[200, 30, 0, 160]\",\n                get_radius=200,\n            ),\n        ],\n    )\n)\n", "path": "e2e/scripts/st_pydeck_chart.py"}], "after_files": [{"content": "# Copyright (c) Streamlit Inc. (2018-2022) Snowflake Inc. (2022)\n#\n# Licensed under the Apache License, Version 2.0 (the \"License\");\n# you may not use this file except in compliance with the License.\n# You may obtain a copy of the License at\n#\n#     http://www.apache.org/licenses/LICENSE-2.0\n#\n# Unless required by applicable law or agreed to in writing, software\n# distributed under the License is distributed on an \"AS IS\" BASIS,\n# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n# See the License for the specific language governing permissions and\n# limitations under the License.\n\nimport math\nfrom typing import Any, cast\n\nimport numpy as np\nimport pandas as pd\nimport pydeck as pdk\n\nimport streamlit as st\n\n# Empty chart.\n\nst.pydeck_chart()\n\n# Basic chart.\n\nnp.random.seed(12345)\n\ndf = pd.DataFrame(\n    cast(Any, np.random.randn(1000, 2) / [50, 50]) + [37.76, -122.4],\n    columns=[\"lat\", \"lon\"],\n)\n\nst.pydeck_chart(\n    pdk.Deck(\n        map_style=\"mapbox://styles/mapbox/light-v9\",\n        initial_view_state=pdk.ViewState(\n            latitude=37.76,\n            longitude=-122.4,\n            zoom=11,\n            pitch=50,\n        ),\n        layers=[\n            pdk.Layer(\n                \"HexagonLayer\",\n                data=df,\n                get_position=\"[lon, lat]\",\n                radius=200,\n                elevation_scale=4,\n                elevation_range=[0, 1000],\n                pickable=True,\n                extruded=True,\n            ),\n            pdk.Layer(\n                \"ScatterplotLayer\",\n                data=df,\n                get_position=\"[lon, lat]\",\n                get_color=\"[200, 30, 0, 160]\",\n                get_radius=200,\n            ),\n        ],\n    )\n)\n\n# Chart w/ invalid JSON - issue #5799.\ndata = pd.DataFrame({\"lng\": [-109.037673], \"lat\": [36.994672], \"weight\": [math.nan]})\nlayer = pdk.Layer(\n    \"ScatterplotLayer\", data=data, get_position=[\"lng\", \"lat\"], radius_min_pixels=4\n)\ndeck = pdk.Deck(\n    layers=[layer],\n    map_style=pdk.map_styles.CARTO_LIGHT,\n    tooltip={\"text\": \"weight: {weight}\"},\n)\nst.pydeck_chart(deck, use_container_width=True)\n", "path": "e2e/scripts/st_pydeck_chart.py"}]}