Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A delegate class for pandas dataframes .. an alternative to subclassing pandas dataframes
import pandas as pd
class DataFrameHolder:
def __init__(self, data: pd.DataFrame, title=''): = data
self.title = title
def __len__(self):
return len(
def __getitem__(self, item):
if isinstance(item, list):
def query(self, query_str: str):
result =
return DataFrameHolder(result, title=self.title)
def __repr__(self):
def _repr_html_(self):
html = f"<h3>{self.title}</h3>"
html = html +
return html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment