-
Notifications
You must be signed in to change notification settings - Fork 56
-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect Precision Repr #154
Comments
Hey @mck-star-yar , thanks for reporting this. You're right, we convert formatted numbers back to numbers. The motive for doing so is to get the sorting right in One option would be to do the formatting in Javascript, but I am not so sure this will really work. For instance, this example uses Maybe a more pragmatic approach would be an option |
Actually the JS example might work! At least I see that we have a similar example in the docs and that one works: https://mwouts.github.io/itables/advanced_parameters.html#advanced-cell-formatting-with-js-callbacks |
Unfortunately, I'm not writing in JS. Can you please provide a code snippet for this JS function? I tried following the examples you shared, but those doesn't make much sense to me. Tried like this but it fails: from itables import show, JavascriptFunction
import pandas as pd
df = pd.Series([1.0, 1.123])
with pd.option_context("display.float_format", "{:.3f}".format):
show(
df,
columnDefs=[
{"targets": 0, "render": "DataTable.render.number(',', '.', 1, '')"}
],
) |
Indeed, you're right! The linked example uses JS code rather than a JS function. I did some experiment with a new
and then
This worked in Jupyter Lab, but it did not work in Jupyter Book (the JS errors are $.fn.dataTable is undefined and $.getQueryParameters is not a function). This is very experimental and I have the feeling that passing a function rather than JS code might work better. I see here that |
The code for it is here if you wanted to basically the same thing. |
@mwouts, the code works perfectly. Thanks a lot for such quick help! What is the ETA for this feature to get into the main branch? |
Thank you for your feedback! I just got the precious help of @fwouts and we were able to make this work for both the connected and the offline mode, so we're good to go... |
I am trying to align the precision representation for the column and it doesn't work. Assume the following exmaple:
It shows
But expected
The issue seems to be in
itables/datatables_format.py:: _format_column
.After formatted input is cast to numpy array, it looses the formatting:
removing this line preserves proper formatting.
itables version == '1.4.4'
The text was updated successfully, but these errors were encountered: