espin086 / espin086/jjutils

Create Pandas Data Explorer Class

Open
#11 0 comments 0 reactions 1 assignee Claimed by @espin086 View on GitHub
Dominant language
Python
Stars
2
Forks
0
Avg merge
1m
Merged PRs (30d)
1

Description

The current data exploration class is not good use pandas data profiler instead

import pandas as pd
from pandas_profiling import ProfileReport

class DataProfiler:
def __init__(self, dataframe):
"""
Initialize the DataProfiler with a Pandas DataFrame.

:param dataframe: Pandas DataFrame to profile.
"""
self.dataframe = dataframe

def generate_report(self, output_file=None):
"""
Generate a profile report of the DataFrame.

:param output_file: Optional file path to save the report as an HTML file.
:return: ProfileReport object.
"""
try:
profile = ProfileReport(self.dataframe, explorative=True)
if output_file:
profile.to_file(output_file)
return profile
except Exception as e:
print(f"Error generating report: {e}")

def set_dataframe(self, dataframe):
"""
Set a new DataFrame for profiling.

:param dataframe: Pandas DataFrame to profile.
"""
self.dataframe = dataframe

def get_dataframe(self):
"""
Get the current DataFrame being profiled.

:return: Pandas DataFrame.
"""
return self.dataframe

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.