Last active
September 8, 2020 15:09
-
-
Save jasonmellone/511d80886f85331326d8c3bb74b32a41 to your computer and use it in GitHub Desktop.
A low memory dataframe native access point
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import pickle | |
class DynamoDataFrame: | |
def render_fhandle(self, mode='wb'): | |
return open(file=self.full_fpath, mode=mode) | |
def __init__(self, full_fpath=None, df=None): | |
self.full_fpath = full_fpath | |
if df is not None: | |
fhandle = self.render_fhandle() | |
pickle.dump(obj=df, file=fhandle) | |
fhandle.close() | |
def load_pickle(self): | |
return pickle.load(file=self.render_fhandle(mode='rb')) | |
def __getitem__(self, item): | |
return self.load_pickle()[item] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment