Closed DorianCzichotzki closed 1 year ago
Hi @DorianCzichotzki , thank you for opening this issue, that's an interesting question! And yes it would be great to add support for these nullable types!
I do not know at the moment what is the best way to represent these NA
values, but a few trial and errors are likely to tell us. I would first try a float NaN
, and then None
if the NaN
does not work. We need to pass through the JSON encoding (both None
and NaN
should pass), and then we'll need to check that the JSON value makes sense for https://datatables.net (i.e. test that sorting works as expected).
It would be great if you could propose a PR that would add support for all the nullable types. Maybe the best way to make sure these new types work and keep working in the future will be to add examples with nullable types just after the int
and float
table examples? (these examples are then tested and shown in the documentation
https://github.com/mwouts/itables/blob/e04df1eca13ff32672861ffb44773c045428494b/itables/sample_dfs.py#L46-L56
Hi @DorianCzichotzki , I have added support and tests for nullable bool and int (I've just had to replace pd.NA
with None
before exporting the data to JSON) in itables==1.3.0
.
Missing values are represented by an empty cell, see for instance the sample dataframes in the documentation.
Thanks for reporting the issue!
Itables fails to display DataFrames that use nullable pandas types like
Int64
.To Reproduce
Running the following code results in the TypeError.
Maybe the issue is in
_formatted_values
. Nullable strings are handled there by callingastype('str')
on them. I can try to open a PR but am not sure what the best way to representpd.NA
values is (None
,"<NA>"
like for strings or something else?).