Skip to content

Instantly share code, notes, and snippets.

@jasonmellone
Last active September 8, 2020 15:09
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 jasonmellone/511d80886f85331326d8c3bb74b32a41 to your computer and use it in GitHub Desktop.
Save jasonmellone/511d80886f85331326d8c3bb74b32a41 to your computer and use it in GitHub Desktop.
A low memory dataframe native access point
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