Skip to main content

Spark Column Analyzer

Overview

Spark Column Analyzer is a Python package that provides functions for analyzing columns in PySpark DataFrames. It calculates various statistics such as null count, null percentage, distinct count, distinct percentage, min_value, max_value, avg_value and historams for each column. It also create a plot and saves it to the directory you are running the code from.

Installation

You can install Spark Column Analyzer using pip:

pip install spark-column-analyzer


## Usage

### Analyzing Columns

To analyze columns in a PySpark DataFrame, you can use the `analyze_column` function provided by the package. Here's an example:

```python
from pyspark.sql import SparkSession
from spark_column_analyzer.column_analyzer import analyze_column

# Initialize SparkSession
spark = SparkSession.builder \
    .appName("ColumnAnalyzer") \
    .getOrCreate()

# Create a sample DataFrame
df = spark.createDataFrame([
    (1, "A", None),
    (2, "B", 100),
    (3, "C", 200),
    (4, "D", 300),
    (5, "E", None)
], ["ID", "Letter", "Value"])

# Analyze a specific column
result = analyze_column(df, "Value")
print(result)
Running Tests
To run tests for Spark Column Analyzer, follow these steps:

Clone the repository:
git clone https://github.com/michTalebzadeh/spark_column_analyzer.git
Navigate to the project directory:
cd spark_column_analyzer
Install the dependencies:
pip install -r requirements.txt
Run the tests:
python -m unittest discover tests
Contributing
If you'd like to contribute to Spark Column Analyzer, please open an issue or submit a pull request on GitHub.

License
This project is licensed under the MIT License - see the LICENSE file for details.

vbnet

Feel free to customize this template according to your project's specific details and require

Example

Doing analysis for column Postcode

Json formatted output

{
    "PricePaid": {
        "exists": true,
        "num_rows": 1819,
        "data_type": "int",
        "null_count": 0,
        "null_percentage": 0.0,
        "distinct_count": 1133,
        "distinct_percentage": 62.29,
        "min_value": 10000001,
        "max_value": 448500000,
        "avg_value": 32620476.65,
        "histogram": {
            "bins": [
                10000001.0,
                14216347.144230768,
               448500000.0,

            ],
            "counts": [
                468,
                286,
                258,

            ]
        }
    }
}

Metadata

Release files for spark-column-analyzer 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spark-column-analyzer 0.2.3
File Size Uploaded Provenance
spark-column-analyzer-0.2.3.tar.gz 5.9 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for spark-column-analyzer 0.2.3
File Interpreter ABI Platform
spark_column_analyzer-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 13.2 kB

Release files / spark-column-analyzer-0.2.3.tar.gz

Download URL spark-column-analyzer-0.2.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
2135071bc0cadb79703af0afe72fa6295b6c3b46714b5cff3ca175af839a30a4
BLAKE2b-256 checksum
How to use checksums
f810e529573c473ee6e805bfb353118238ad67ca7fea34d96f12962bac389450
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.16

Release files / spark_column_analyzer-0.2.3-py3-none-any.whl

Download URL spark_column_analyzer-0.2.3-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
51a093ef80194ca144d00ff07b6b0f61d7d8a8b7135ad49d3f8e2740873f835b
BLAKE2b-256 checksum
How to use checksums
bc58b0f851c7377678b7879d35c9e8bbff24cdf1e01d8a4d5093827a2761f229
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.0 CPython/3.9.16

Security for spark-column-analyzer 0.2.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page