{"id":21752,"library":"pygrinder","title":"PyGrinder","description":"A Python toolkit for introducing missing values into datasets under various missingness mechanisms (MCAR, MAR, MNAR) and patterns (point, sequential, block). Current version: 0.7. Requires Python >=3.8. Released quarterly.","status":"active","version":"0.7","language":"python","source_language":"en","source_url":"https://github.com/WenjieDu/PyGrinder","tags":["missing-data","data-imputation","MCAR","MAR","MNAR","data-augmentation","time-series"],"install":[{"cmd":"pip install pygrinder","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core dependency for array operations","package":"numpy","optional":false},{"reason":"Used for random number generation and tensor operations","package":"torch","optional":false}],"imports":[{"note":"Earlier versions (pre-0.4) returned masks; now returns only corrupted data.","symbol":"mcar","correct":"from pygrinder import mcar"},{"note":"Renamed from mar_logistic (always existed).","symbol":"mar_logistic","correct":"from pygrinder import mar_logistic"},{"note":"Renamed from mnar_x (always existed).","symbol":"mnar_x","correct":"from pygrinder import mnar_x"},{"note":"Renamed from mnar_t (always existed).","symbol":"mnar_t","correct":"from pygrinder import mnar_t"},{"note":"Added in v0.7, replaces mnar_num.","symbol":"mnar_nonuniform","correct":"from pygrinder import mnar_nonuniform"},{"note":"Added in v0.6.","symbol":"seq_missing","correct":"from pygrinder import seq_missing"},{"note":"Added in v0.6.","symbol":"block_missing","correct":"from pygrinder import block_missing"},{"note":"Added in v0.5.","symbol":"rdo","correct":"from pygrinder import rdo"},{"note":"Added in v0.4.","symbol":"fill_and_get_mask","correct":"from pygrinder import fill_and_get_mask"},{"note":"Added in v0.2.","symbol":"little_mcar_test","correct":"from pygrinder import little_mcar_test"},{"note":"Typo in v0.6.1 used 'calc_misssing_rate' (extra 's'), corrected to 'calc_missing_rate' from v0.6.2 onwards.","wrong":"from pygrinder import calc_misssing_rate","symbol":"calc_missing_rate","correct":"from pygrinder import calc_missing_rate"}],"quickstart":{"code":"import numpy as np\nfrom pygrinder import mcar, fill_and_get_mask\n\nX = np.random.randn(100, 10)\ncorrupted_X = mcar(X, rate=0.2)\nX_filled, mask = fill_and_get_mask(corrupted_X, fill_value=0)\nprint(f\"Original shape: {X.shape}, missing rate: {1 - mask.mean():.2f}\")","lang":"python","description":"Basic usage: create MCAR missingness, then fill NaNs and get mask."},"warnings":[{"fix":"Update code: data = mcar(X, rate=0.2) instead of X_intact, data, mask = mcar(X, rate=0.2). Use fill_and_get_mask(data) to get mask.","message":"In v0.4, all missingness-creating functions (mcar, mar_logistic, mnar_x, mnar_t) changed to return only the corrupted data (with NaN), not a tuple (X_intact, X, mask). Use fill_and_get_mask to get the mask.","severity":"breaking","affected_versions":"<0.4"},{"fix":"Replace mnar_num with mnar_nonuniform.","message":"In v0.7, mnar_num has been renamed to mnar_nonuniform. The old name mnar_num is removed.","severity":"deprecated","affected_versions":"<=0.6.4"},{"fix":"Upgrade to >=0.6.4 or ensure seq_len < n_steps.","message":"Functions seq_missing and block_missing require seq_len argument; setting seq_len equal to n_steps can cause an empty step_idx list bug (fixed in v0.6.4). Verify that seq_len < n_steps to avoid errors.","severity":"gotcha","affected_versions":"<=0.6.3"},{"fix":"Upgrade to >=0.6.3.","message":"Mar_logistic had a bug in argument order (v0.6.2 and earlier) that could produce incorrect missingness. Fixed in v0.6.3.","severity":"gotcha","affected_versions":"<=0.6.2"},{"fix":"Switch to fill_and_get_mask to retrieve the mask.","message":"In v0.4, the parameter 'return_masks' was available to return masks alongside corrupted data; it was removed in later versions. Use fill_and_get_mask instead.","severity":"deprecated","affected_versions":"0.3-0.4"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Use from pygrinder import calc_missing_rate","cause":"Typo in function name; the correct name is calc_missing_rate (single 's' after 'miss').","error":"AttributeError: module 'pygrinder' has no attribute 'calc_misssing_rate'"},{"fix":"Call mcar(X, rate=0.2) with only one rate specification.","cause":"Passing both positional and keyword argument for 'rate', or duplicate keyword.","error":"TypeError: mcar() got multiple values for argument 'rate'"},{"fix":"Set seq_len < n_steps, or upgrade to pygrinder >=0.6.4 where this condition is handled.","cause":"In seq_missing, seq_len equals or exceeds the number of time steps, causing an empty index list.","error":"ValueError: seq_len must be less than n_steps"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}