Skip to main content

A data manipulation library for JSON and lists of dictionaries.

Project description

pyberry

DataDict Class

*Detailed docs to come shortly.

DataDict.select(*keys)

Selects specified keys from the data dictionary. If a key does not exist in all records, it will be omitted from those records.

Parameters:

  • *keys (Any): The keys to select. This can be any number of keys in the DataDict.

Returns:

  • DataDict: A DataDict containing only the selected keys.

DataDict.where(key: str, comparison: str, value: Any)

Filters the DataDict object based on the specified field and comparison. The DataDict object can be treated exactly like a list of dicts, but can also perform more complex queries.

Parameters:

  • key (Any): The key to filter by. This can be any key found in the DataDict.
  • comparison (str): The comparison operator to use. This can be any comparison operator found in the DataDict.
  • value (Any): The value to compare the field to.

Returns:

  • Datadict: A DataDict object containing the filtered dicts.

DataDict.to_float(key: Any)

Converts the values of the specified key to floats. If conversion is not possible, raises a ValueError.
Modifies the DataDict in place.

Parameters:

  • key (Any): The key whose values are to be converted to float.
    Modifies the DataDict in place.

DataDict.to_str(key: Any)

Converts the values of the specified key to strings.
Modifies the DataDict in place.

Parameters:

  • key (Any): The key whose values are to be converted to string.

DataDict.median(key: Any)

Calculates the median of the numerical values in the specified key. If the key contains non-numeric values, raises a ValueError.

Parameters:

  • key (Any): The key for which the median is to be calculated.

Returns:

  • int | float: The median of the key values.

DataDict.mean(key: Any)

Calculates the mean of the numerical values in the specified key. If the key contains non-numeric values, raises a ValueError.

Parameters:

  • key (Any): The key for which the mean is to be calculated.

Returns:

  • int | float: The mean of the key values.

DataDict.max(key: Any)

Calculates the maximum value out of all numerical values in the specified key. If the key contains non-numeric values, raises a ValueError.

Parameters:

  • key (Any): The key for which the maximum value is to be calculated.

Returns:

  • int | float: The maximum value of the key values.

DataDict.min(key: Any)

Calculates the minimum value out of all numerical values in the specified key. If the key contains non-numeric values, raises a ValueError.

Parameters:

  • key (Any): The key for which the minimum value is to be calculated.

Returns:

  • int | float: The minimum value of the key values.

DataDict.tail(n: int = 5)

Returns the last n elements of the data dictionary.

Parameters:

  • n (int): An integer specifying the number of elements to return from the end of the data dictionary (default is 5).

Returns:

  • DataDict: A DataDict representing the last n elements.

DataDict.head(n: int = 5)

Returns the first n elements of the data dictionary.

Parameters:

  • n (int): An integer specifying the number of elements to return from the end of the data dictionary (default is 5).

Returns:

  • DataDict: A DataDict representing the first n elements.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pymelon-0.4.0.tar.gz (5.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pymelon-0.4.0-py3-none-any.whl (8.1 kB view details)

Uploaded Python 3

File details

Details for the file pymelon-0.4.0.tar.gz.

File metadata

  • Download URL: pymelon-0.4.0.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.1

File hashes

Hashes for pymelon-0.4.0.tar.gz
Algorithm Hash digest
SHA256 086ed80a6d0a51b01197aacd11d48c31b342d1a078d56a432a3f99e9303af88b
MD5 2b7216e71acdea1767c4ee2f1361024b
BLAKE2b-256 4c4ec5a62d159678d5f530306a7d87faad1204824eede79cadcbd020f989621a

See more details on using hashes here.

File details

Details for the file pymelon-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: pymelon-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 8.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.11.1

File hashes

Hashes for pymelon-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b3f381243b8dc98e54853fd6e804d8a67c8af7999b173c9e6e2a1e0c6d7aaa4e
MD5 683e3eee0c74ca9190c3ce1280aacde7
BLAKE2b-256 c98eee061c262ccda30158c1e86473a96e1e098bf9d973eb660ede7d2803665b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page