Skip to main content

Inspect nested JSON/dict structures in pandas DataFrame columns

Project description

dataframe-inspector

PyPI version Python 3.8+

Inspect nested JSON/dict structures in pandas DataFrame columns.

Installation

pip install dataframe-inspector

Usage

import pandas as pd
from dataframe_inspector import Inspector

# DataFrame with deeply nested structure (5 levels)
df = pd.DataFrame({
    'id': [1, 2],
    'response': [
        {
            'data': {
                'organization': {
                    'department': {
                        'team': {
                            'lead': {'name': 'Alice', 'id': 101},
                            'members': [
                                {'name': 'Bob', 'role': 'engineer'},
                                {'name': 'Carol', 'role': 'designer'}
                            ]
                        },
                        'name': 'Engineering',
                        'budget': 500000
                    },
                    'name': 'Tech Division'
                },
                'timestamp': '2024-01-01'
            }
        },
        {
            'data': {
                'organization': {
                    'department': {
                        'team': {
                            'lead': {'name': 'David', 'id': 102},
                            'members': [
                                {'name': 'Eve', 'role': 'analyst'}
                            ]
                        },
                        'name': 'Sales',
                        'budget': 300000
                    },
                    'name': 'Business Division'
                },
                'timestamp': '2024-01-02'
            }
        }
    ]
})

inspector = Inspector(df)

# Get overview - identifies nested vs simple columns
inspector.overview()

Output:

================================================================================
DATAFRAME OVERVIEW
================================================================================

📊 Dimensions:
  Rows: 2
  Columns: 2

🔍 Nested Columns (1):
  Use inspect_column() to explore these:
  - response (0.0% null)

📝 Simple Columns (1):
  - id (int64, 2 unique, 0.0% null)

================================================================================
# Deep dive into nested column with increased depth
inspector.inspect_column('response', max_depth=4, sample_size=1)

Output:

============================================================
Nested Column: 'response'
============================================================

Nested structure keys found (depth ≤ 4):
  - data
  - data.organization
  - data.organization.department
  - data.organization.department.budget
  - data.organization.department.name
  - data.organization.department.team
  - data.organization.name
  - data.timestamp

Sample values (first 1):

[Row 0]:
    data:
      organization:
        department:
          team:
            lead:
              name: Alice
              id: 101
            members:
              [0]:
                name: Bob
                role: engineer
              [1]:
                name: Carol
                role: designer
          name: Engineering
          budget: 500000
        name: Tech Division
      timestamp: 2024-01-01
============================================================

See more examples in the examples/ folder.

Contributing

Issues and pull requests are welcome on GitHub.

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

dataframe_inspector-0.1.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

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

dataframe_inspector-0.1.2-py3-none-any.whl (6.1 kB view details)

Uploaded Python 3

File details

Details for the file dataframe_inspector-0.1.2.tar.gz.

File metadata

  • Download URL: dataframe_inspector-0.1.2.tar.gz
  • Upload date:
  • Size: 6.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.11

File hashes

Hashes for dataframe_inspector-0.1.2.tar.gz
Algorithm Hash digest
SHA256 d4549c38d783e22c5359dbb99e94c1c4c158d3dccaaff43e0316f8c60db25682
MD5 7c76d735cae5b814d665eaea9e6908ff
BLAKE2b-256 e7caa461ba3376a085f5194d78b1217672eb77a326173482045e02da09ee9a7b

See more details on using hashes here.

File details

Details for the file dataframe_inspector-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for dataframe_inspector-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0b24b60df38814fa45263e7e681ff3495bc44cd14f0c01e0daeb6946b61a95a7
MD5 1493d9a6c033e88bd13b909db0ebabba
BLAKE2b-256 7e80fae22852c6c2a54321662e9d2e193765f7165f5bcff1912a14bf5ea6889a

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