jupyter-widgets / ipydatagrid

Fast Datagrid widget for the Jupyter Notebook and JupyterLab
BSD 3-Clause "New" or "Revised" License
575 stars 51 forks source link

NaT-datetime-values break ipydatagrid #522

Open m-rossi opened 4 months ago

m-rossi commented 4 months ago

Describe the bug It's me again with some datetime bug. If there is NA-data in a datetime column ipydatagrid crashes.

To Reproduce

import pandas as pd
from ipydatagrid import DataGrid

df = pd.DataFrame({'A': ['2024-01-01', pd.NA]}, dtype='datetime64[ns]')
df

renders as HTML-table like this: grafik but if I try to put that df in a Datagrid:

DataGrid(df)

I get this: grafik

[Open Browser Console for more detailed log - Double click to close this message]
Model class 'DataGridModel' from module 'ipydatagrid' is loaded but can not be instantiated
deserialize@http://localhost:8888/lab/extensions/ipydatagrid/static/787.b52e0074e2cbca59f4b7.js?v=b52e0074e2cbca59f4b7:1:59997
_deserialize_state@http://localhost:8888/lab/extensions/@jupyter-widgets/jupyterlab-manager/static/647.e39f528c8fee8adb9110.js?v=e39f528c8fee8adb9110:1:12381

Expected behavior To be able to render NaT-datetime-values

Workaround I have a workaround for anyone who may also have this issue until it is solved:

df['A'] = df['A'].astype(object).fillna('')

Environment (please complete the following information):