Creating modules from data is different than software In practice, I really like to tidy up dataframes with specific features cleaned in each notebook. This approach avoids long and difficult to debug notebooks.
from pandas import util; df = util.testing.makeDataFrame()
All of the columns in the namespace
globals().update(dict(df.items()))
Add dataframe operations to our module
import IPython
Hosting attributes.
with IPython.utils.capture.capture_output(): globals().update({x: getattr(df, x) for x in dir(df)})
Ø = __name__ == '__main__'
if Ø: from deathbeds import __Dataframes_and_modules
if Ø: assert isinstance(__Dataframes_and_modules, __import__('types').ModuleType)
Ø and __Dataframes_and_modules.sample(2)
A | B | C | D | |
---|---|---|---|---|
QyXyHT1cgE | 2.395613 | 0.189797 | 0.247524 | 0.756322 |
CpKDTadz2K | -0.667076 | -1.609436 | 1.048942 | -0.031083 |