Skip to content

Instantly share code, notes, and snippets.

@rpicatoste
Created October 19, 2018 09:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rpicatoste/0d97488bcc247556ef1ccb9ccae497eb to your computer and use it in GitHub Desktop.
Save rpicatoste/0d97488bcc247556ef1ccb9ccae497eb to your computer and use it in GitHub Desktop.
Testing dataframe with extra attributes
import pandas as pd
class MyDF(pd.DataFrame):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.definition = 'my_definition'
my_df = MyDF()
my_df.__dict__ = df.__dict__.copy()
print(len(my_df))
print(my_df.definition)
save_variables_to_pickle(my_df, 'my_df.pkl')
my_df2 = load_variables_from_pickle('my_df.pkl')
print(len(my_df2))
print(my_df2.definition)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment