Skip to content

Server internal error in the Tabulator with a column partially filled with pd.NaT #7803

Description

@Zelfior

ALL software version info

Software Version Info
OS : Windows 10

Python version 3.10.0

PIP list info 

Package               Version
--------------------- -----------
annotated-types       0.7.0      
anyio                 4.8.0      
arabic-reshaper       3.0.0      
asn1crypto            1.5.1      
audiostretchy         1.3.5      
bleach                6.2.0      
bokeh                 3.6.3      
Brotli                1.1.0      
certifi               2025.1.31  
cffi                  1.17.1     
chardet               5.2.0      
charset-normalizer    3.4.1      
click                 8.1.8      
colorama              0.4.6      
contourpy             1.3.1      
cryptography          44.0.2     
cssselect2            0.8.0      
defusedxml            0.7.1      
docopt                0.6.2      
eval_type_backport    0.2.2      
exceptiongroup        1.2.2      
ffmpeg-python         0.2.0      
fire                  0.7.0      
fonttools             4.56.0     
future                1.0.0
h11                   0.14.0
html5lib              1.1
httpcore              1.0.7
httpx                 0.28.1
idna                  3.10
Jinja2                3.1.6
jsonpath-python       1.0.6
linkify-it-py         2.0.3
lxml                  5.3.1
Markdown              3.7
markdown-it-py        3.0.0
markdown-pdf          1.4
markdown2             2.5.3
MarkupSafe            3.0.2
md2pdf                1.0.1
mdit-py-plugins       0.4.2
mdurl                 0.1.2
mistralai             1.5.1
mypy-extensions       1.0.0
numpy                 2.2.3
oscrypto              1.3.0
packaging             24.2
pandas                2.2.3
pandoc                2.4
panel                 1.6.1
param                 2.2.0
pillow                11.1.0
pip                   21.2.3
plum-dispatch         1.7.4
plumbum               1.9.0
ply                   3.11
pycparser             2.22
pydantic              2.10.6
pydantic_core         2.27.2
pydub                 0.25.1
pydyf                 0.11.0
pyHanko               0.26.0
pyhanko-certvalidator 0.26.5
pymp3                 0.2.0
PyMuPDF               1.25.3
pypdf                 5.3.1
pyphen                0.17.2
pyrubberband          0.4.0
python-bidi           0.6.6
python-dateutil       2.9.0.post0
pytz                  2025.1
pyviz_comms           3.0.4
pywin32               309
PyYAML                6.0.2
qrcode                8.0
reportlab             4.3.1
requests              2.32.3
setuptools            57.4.0
six                   1.17.0
sniffio               1.3.1
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
PyMuPDF               1.25.3
pypdf                 5.3.1
pyphen                0.17.2
pyrubberband          0.4.0
python-bidi           0.6.6
python-dateutil       2.9.0.post0
pytz                  2025.1
pyviz_comms           3.0.4
pywin32               309
PyYAML                6.0.2
qrcode                8.0
reportlab             4.3.1
requests              2.32.3
setuptools            57.4.0
six                   1.17.0
sniffio               1.3.1
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
pyphen                0.17.2
pyrubberband          0.4.0
python-bidi           0.6.6
python-dateutil       2.9.0.post0
pytz                  2025.1
pyviz_comms           3.0.4
pywin32               309
PyYAML                6.0.2
qrcode                8.0
reportlab             4.3.1
requests              2.32.3
setuptools            57.4.0
six                   1.17.0
sniffio               1.3.1
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
python-dateutil       2.9.0.post0
pytz                  2025.1
pyviz_comms           3.0.4
pywin32               309
PyYAML                6.0.2
qrcode                8.0
reportlab             4.3.1
requests              2.32.3
setuptools            57.4.0
six                   1.17.0
sniffio               1.3.1
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
PyYAML                6.0.2
qrcode                8.0
reportlab             4.3.1
requests              2.32.3
setuptools            57.4.0
six                   1.17.0
sniffio               1.3.1
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
reportlab             4.3.1
requests              2.32.3
setuptools            57.4.0
six                   1.17.0
sniffio               1.3.1
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
six                   1.17.0
sniffio               1.3.1
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
Spire.Doc             13.1.0
svglib                1.5.1
termcolor             2.5.0
soundfile             0.13.1
soxr                  0.5.0.post1
spire                 0.4.2
Spire.Doc             13.1.0
svglib                1.5.1
termcolor             2.5.0
soxr                  0.5.0.post1
spire                 0.4.2
Spire.Doc             13.1.0
svglib                1.5.1
termcolor             2.5.0
tinycss2              1.4.0
tinyhtml5             2.0.0
tornado               6.4.2
tqdm                  4.67.1
Spire.Doc             13.1.0
svglib                1.5.1
termcolor             2.5.0
tinycss2              1.4.0
tinyhtml5             2.0.0
tornado               6.4.2
tqdm                  4.67.1
tinycss2              1.4.0
tinyhtml5             2.0.0
tornado               6.4.2
tqdm                  4.67.1
typing_extensions     4.12.2
typing-inspect        0.9.0
tzdata                2025.1
typing_extensions     4.12.2
typing-inspect        0.9.0
tzdata                2025.1
tzdata                2025.1
tzlocal               5.3.1
uc-micro-py           1.0.3
uritools              4.0.3
tzlocal               5.3.1
uc-micro-py           1.0.3
uritools              4.0.3
uritools              4.0.3
urllib3               2.3.0
weasyprint            64.1
urllib3               2.3.0
weasyprint            64.1
weasyprint            64.1
webencodings          0.5.1
webencodings          0.5.1
xhtml2pdf             0.2.17
xyzservices           2025.1.0
zopfli                0.2.3.post1

Description of expected behavior and the observed behavior

Creating a pn.widgets.Tabulator where a column

  • Is of datetime type
  • contains at least one but not all pd.NaT

raises the following error, not allowing to display the app:

ValueError: Out of range float values are not JSON compliant

ERROR:bokeh.server.views.ws:Bokeh Server internal error: server failed to handle a message, closing connection

If we edit a datetime from a full pd.NaT column (ending in the same situation as if we initialised from a non full of pd.NaT column), it works.

Complete, minimal, self-contained example code that reproduces the issue

# Code executed with : & C:\Python310\python.exe .\exemple_bug.py --show

import pandas as pd
import panel as pn

class DisplayPanel:
    def __init__(self):
        # Works
        # self.df = pd.DataFrame({"date":[pd.NaT, pd.NaT]})

        # Raises error
        self.df = pd.DataFrame({"date":[pd.NaT, 12]})

        # Works
        # self.df = pd.DataFrame({"date":[0, 12]})

        self.df["date"] = pd.to_datetime(self.df["date"]).dt.date

        self.tabulator = pn.widgets.Tabulator(
                                                self.df, 
                                            ) 
        
        # Create tabs
        self.tabs = pn.Tabs(
            ("Table données", pn.Column(
                                            self.tabulator
                                        )),

        )

    def get_tabs(self,):
        return self.tabs

if __name__ == "__main__":
    import argparse
    from argparse import ArgumentError

    # Parse command line arguments
    parser = argparse.ArgumentParser(description="Display DataFrame")
    parser.add_argument("--show", action='store_true', help="Opens the display in a browser")
    parser.add_argument("--server", action='store_true', help="Opens a display server")

    args = parser.parse_args()

    if args.show:
        DisplayPanel().get_tabs().show()
    elif args.server:
        pn.serve(DisplayPanel().get_tabs())
    else:
        raise ArgumentError("You must specify either --show or --server")

Stack traceback and/or browser JavaScript console output

ERROR:bokeh.server.views.ws:Handler or its work threw an exception: ValueError('Out of range float values are not JSON compliant'): Message 'PULL-DOC-REQ' content: {}
Traceback (most recent call last):
  File "C:\Python310\lib\site-packages\bokeh\server\views\ws.py", line 257, in on_message
    await self._schedule(work)
  File "C:\Python310\lib\site-packages\bokeh\server\views\ws.py", line 331, in _schedule
    await self.send_message(cast(Message[Any], work))
    await message.send(self)
  File "C:\Python310\lib\site-packages\bokeh\protocol\message.py", line 377, in content_json
    self._content_json = serialize_json(self.payload)
  File "C:\Python310\lib\site-packages\bokeh\core\json_encoder.py", line 171, in serialize_json
    return encoder.encode(content)
  File "C:\Python310\lib\json\encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "C:\Python310\lib\json\encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
ValueError: Out of range float values are not JSON compliant
ERROR:bokeh.server.views.ws:Bokeh Server internal error: server failed to handle a message, closing connection

Screenshots or screencasts of the bug in action

  • I may be interested in making a pull request to address this

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions