Skip to content

Tag: python

Save a list of dictionaries with numpy arrays

I have a dataset composed as: Each element of the list is a dictionary containing a key “sample” and its value is a numpy array that has shape (2048,3) and the category is the class of that sample. The dataset len is 8000. I tried to save in JSON but it said it can’t serialize numpy arrays. …

Using dynamic object name in YAML scheme

I want to validate YAML files in Python with my own scheme. A valid YAML shall look like this: While [windows, other] are dynamic, any name shall allowed there (i.e. “solaris”, “mac”, “templeOS”) I’m using validate from jsonschema like described here: Validating a yam…

How to concatanate 2 dictionaries in 2 json files

Iam trying to append a dictionary in one json file to a dictionary in another json file. here are json file r1 json file r2 The result Iam looking for is Expected result My code is not returning the expected results Answer As the ‘Adrian shum’ said your json having the lists. in that case you can …