Skip to content
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

Invalid JSON being generated by save_json methods #387

Open
jlopezpena opened this issue Oct 13, 2022 · 1 comment
Open

Invalid JSON being generated by save_json methods #387

jlopezpena opened this issue Oct 13, 2022 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@jlopezpena
Copy link
Contributor

The JSON encoder used can output NaN and infinite values (see the most_common_value label in the example below).

This is valid javascript, but not valid JSON, and can create problems down the pipeline when another service tries to deserialize it.

The standard json.dumps method has an allow_nan parameter that can be used to control this behaviour, and it would be good to have access to it (with the default being left as it is right now for compatibility).

Generally speaking, it would be good to have access to all the parameters used by json.dumps, perhaps by adding some catch-all **kwargs to the .json() method in evidently and passing that along to the json.dumps call.

Example:

{
    "feature_type": "num",
    "count": 2492,
    "infinite_count": 0,
    "infinite_percentage": 0.0,
    "missing_count": 190,
    "missing_percentage": 7.08,
    "unique_count": 2482,
    "unique_percentage": 92.54,
    "percentile_25": -0.11,
    "percentile_50": 0.35,
    "percentile_75": 1.41,
    "max": 241887.34,
    "min": -1.0,
    "mean": 138.11,
    "most_common_value": NaN,
    "most_common_value_percentage": 7.08,
    "std": 4949.03,
    "most_common_not_null_value": 1.098466433173,
    "most_common_not_null_value_percentage": 0.07,
    "new_in_current_values_count": null,
    "unused_in_current_values_count": null
}
@emeli-dral emeli-dral assigned emeli-dral and Liraim and unassigned emeli-dral Oct 14, 2022
@emeli-dral emeli-dral added the enhancement New feature or request label Oct 14, 2022
@emeli-dral
Copy link
Contributor

Hi @jlopezpena, thanks for your suggestion, it is a great point. We were unable to fit in the current release as we focused on major refactoring. But we took it into work and will make the changes in the next release in November.

@Tapot Tapot self-assigned this Oct 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants