Skip to main content

A Python package for validating data consistency

Project description

valdata README

valdata is a robust Python package developed to streamline data validation and consistency checks across various data structures and environments, particularly those used in financial and risk analysis. By providing structured data insights, comparisons, and file management capabilities, valdata simplifies data analysis and improves data quality assurance processes.

Features

  • Compatibility with Pandas and Spark DataFrames: Ensures easy integration with common data structures.
  • Detailed Data Insights: View unique values, data types, and column composition for better data understanding.
  • Data Consistency Checks: Compare multiple DataFrames for equality, validate variables, and analyze column-specific occurrences and concentrations.
  • Flexible File Management: Seamlessly work with directories and modules, allowing for more efficient data processing.
  • System Compatibility: Detects versions of relevant software, such as Hadoop, Spark, and PySpark, to help ensure compatibility in distributed computing environments.

Use Cases

  • Financial Analysis: Validate data from multiple sources, ensuring consistent and accurate datasets for risk assessments or portfolio analysis.
  • Data Audits: Identify and troubleshoot discrepancies in datasets, especially for large data teams.
  • Risk Management: Monitor data for anomalies, rare occurrences, or threshold-based concentrations in high-risk datasets.
  • Data Pipeline Debugging: Detect and correct schema mismatches or data quality issues within ETL (Extract, Transform, Load) processes.

Installation

All required dependencies are installed automatically when you install valdata using pip. You don’t need to worry about manually installing them, as pip will handle this for you. Simply run:

pip install valdata

Then to load the package you can use:

import valdata as vd

Requirements

Since Spark-based operations are part of the library functionality, you must have a pre-configured and working PySpark and Hadoop environment. While the pyspark library is included as a dependency, the actual setup of Spark and Hadoop (e.g., installing and configuring the Spark cluster) is not handled by valdata.

Resources and Documentation

Explore the following resources to learn more about valdata:

  • 📦 Package Installer: PyPI
    Find the package, installation instructions, and release history.

  • 📖 Documentation: Read the Docs
    Comprehensive guides and usage examples.

  • 📓 Jupyter Notebook Example: jupyter_testing.ipynb
    Interactive examples showcasing the main features and capabilities of the library.

Modules Overview

Auxiliary

This module provides utility functions for type checking, path correction, and timezone-aware datetime retrieval. These functions are particularly useful within the library, enabling seamless integration with other module components.

  • check_type(): Checks the type of an object.
  • now_timedelta(): Provides a timezone-aware current datetime.
  • path_correction(): Corrects file paths for compatibility across systems.

Utils

This module includes utility functions for managing directories, displaying system information, and integrating with Spark. It provides tools for checking and creating directories, listing contents, managing Python module paths, and retrieving version details for Hadoop, Spark, and PySpark.

  • add_module_path(): Adds a module path dynamically.
  • check_directory(): Verifies the existence of a directory and creates it if necessary.
  • get_directories(): Lists all directories in a given path.
  • get_hadoop_version(): Retrieves the current Hadoop version.
  • get_modules(): Lists Python modules in a specified directory.
  • read_file(): Reads the content of a file. (Todo!!!)
  • save_file(): Saves content to a file. (Todo!!!)

Validation

This module is designed for DataFrame analysis and comparison, supporting both Pandas and Spark DataFrames (in some functions, lists are supported). It includes functions to track execution time, print DataFrame summaries, compare DataFrames, and tabulate various statistics. Operations such as counting unique values, checking variable consistency, and comparing DataFrames element-wise or by structure are also supported.

  • check_variables(): Validates the consistency of variables in a DataFrame.
  • equal_df(): Compares two DataFrames for equality.
  • equal_df_mult(): Compares multiple DataFrames against a reference DataFrame.
  • get_overview(): Provides an overview of a DataFrame, including column statistics.
  • get_pandas_schemaStr(): Returns the schema of a Pandas DataFrame in a readable format.
  • now(): Returns the current timestamp.
  • show_pandas_as_table(): Displays a Pandas DataFrame as a formatted table.
  • tblt_concentrations(): Analyzes data concentrations above given thresholds.
  • tblt_ocurrences(): Counts occurrences of specific values in columns.
  • tms_0(): Tracks start time for operations.
  • tms_1(): Tracks end time for operations and calculates elapsed time.
  • unique_values(): Lists unique values for each column in a DataFrame.

Visuals

This module defines various utility functions and styles for text formatting and Jupyter Notebook customization. It includes a variety of text styles for better visual representation of outputs.

  • TextStyle: A class providing pre-defined text styles.
    • TextStyle.BLACK, TextStyle.BLUE, TextStyle.BOLD, TextStyle.CYAN, TextStyle.GREEN, TextStyle.ITALIC, TextStyle.MAGENTA, TextStyle.RED, TextStyle.RESET, TextStyle.UNDERLINE, TextStyle.WHITE, TextStyle.YELLOW.
  • b(): Formats text in bold.
  • b_bl(): Formats text in bold and blue.
  • b_gr(): Formats text in bold and green.
  • b_re(): Formats text in bold and red.
  • set_start(): Initializes a custom in-house Jupyter Notebook visuals template, displays a personalized message, and prints the current timestamp. This function is designed to streamline the setup process at the beginning of any Python notebook, providing a standardized and efficient starting point.

A detailed application of every function can be found in the ipynb file jupyter_testing.ipynb.

Known Issues

None at the moment. Please report any issues you find on the GitHub repository.

Release Notes

0.0.1

Initial Release: The first version of valdata introduces key functionality divided into four main modules:

  • Auxiliary: Offers essential utility functions for type checking, path correction, and timezone-aware datetime handling, ensuring smooth integration with other components.
  • Utils: Provides tools for managing directories, checking system configurations, and integrating with Spark, including directory creation, module path management, and version retrieval for Hadoop and Spark.
  • Validation: Delivers robust DataFrame analysis and comparison tools, supporting both Pandas and Spark DataFrames. Key features include data consistency checks, variable validation, summary statistics, and concentration analysis.
  • Visuals: Enhances output presentation with customizable text styles and templates for Jupyter Notebooks, enabling visually appealing and organized data representations.

Contact

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

valdata-0.0.2.tar.gz (15.7 kB view details)

Uploaded Source

Built Distribution

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

valdata-0.0.2-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file valdata-0.0.2.tar.gz.

File metadata

  • Download URL: valdata-0.0.2.tar.gz
  • Upload date:
  • Size: 15.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for valdata-0.0.2.tar.gz
Algorithm Hash digest
SHA256 1aecba6be704c05f7e8b06248f84dfb655b4a99aa4e99b05e903c9bbee60375a
MD5 07cf4c62a959111303977436fc1297a6
BLAKE2b-256 5f062bcf0b710f314e2f07807569f37b88d5b14737d0ed961546e3fa0620f3e0

See more details on using hashes here.

File details

Details for the file valdata-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: valdata-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.2

File hashes

Hashes for valdata-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8b4625c749cb952c1cfca4400f89b514f1aec2bfe4bb83b22baaa654ed499db8
MD5 e740493f29ede1cc3e51c1256309f529
BLAKE2b-256 a9c36468014d30266d3d4b44daf73f0fbad8fef8a318753074e4154e34d90954

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