{"id":26887,"library":"datashape","title":"DataShape","description":"A data description language for describing and validating the structure of tabular and array data. Current version is 0.5.2. The library is in maintenance mode; no active development expected.","status":"maintenance","version":"0.5.2","language":"python","source_language":"en","source_url":"https://github.com/blaze/datashape","tags":["data","shape","type","validation","numpy"],"install":[{"cmd":"pip install datashape==0.5.2","lang":"bash","label":"Install specific version"}],"dependencies":[{"reason":"Required for array type support.","package":"numpy","optional":false},{"reason":"Used for dispatch in type promotions.","package":"multipledispatch","optional":false}],"imports":[{"note":"DataShape is a class in the top-level module, not a submodule.","wrong":"import datashape.DataShape","symbol":"DataShape","correct":"from datashape import DataShape"},{"note":"dshape is a function in the top-level module, not in predicates.","wrong":"from datashape.predicates import dshape","symbol":"dshape","correct":"from datashape import dshape"}],"quickstart":{"code":"from datashape import dshape, DataShape\n# Define a simple shape\nds = dshape('3 * int32')\nprint(ds)\n# Validate data\nimport numpy as np\narr = np.array([1, 2, 3], dtype=np.int32)\nresult = ds.match(arr)\nprint(result)","lang":"python","description":"Define a data shape and validate a numpy array against it."},"warnings":[{"fix":"Update shape strings to use 'var * type', e.g., 'var * int32' instead of 'var int32'.","message":"The 'var' syntax for variable-length dimensions changed in 0.5.0. Previously 'var' was used directly, now it must be written as 'var * type'.","severity":"breaking","affected_versions":"<0.5.0"},{"fix":"Replace 'from datashape.predicates import isrecord' with 'from datashape import isrecord'.","message":"The 'datashape.predicates' module is deprecated and may be removed in a future version. Use top-level functions like 'isrecord', 'isscalar', etc., from 'datashape' directly.","severity":"deprecated","affected_versions":">=0.5.0"},{"fix":"Wrap match() in a try-except block for type validation, or use 'validate()' method if available (not in 0.5.2).","message":"DataShape's 'match()' method returns a boolean, not a validation report. It may raise TypeError if the data type is incompatible.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Ensure the numpy array's dtype and shape match the datashape string exactly, e.g., '3 * int32' requires an array of length 3 with dtype int32.","cause":"Using 'dshape' with incompatible numpy dtype or array.","error":"TypeError: expected shape ..."},{"fix":"Use 'from datashape import DataShape' (ensure version 0.5.x). If you have an older version, upgrade: pip install --upgrade datashape.","cause":"Trying to import DataShape after installing a newer version that moved it, or incorrect import path.","error":"ImportError: cannot import name 'DataShape' from 'datashape'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}