#!wget https://www.dropbox.com/s//PDataFrame.py -O PDataFrame.py
import PDataFrame as pdf
#help('PDataFrame')
#!cat PDataFrame.py

"""
Explanation: PDataFrame
End of explanation
"""


pdf.PDataFrame.create('PDataFrame.csv', ('key', 'description'))

"""
Explanation: The PDataFrame class provides a persistant data frame (it is saved to a csv file on the disk). This is useful to collect information in iPython notebooks without having to add it into the notebooks itself. Use cases


Bookmarks - a notebook might rely on a number of different URL's eg to download different data series; those URL's can be stored in the notebook, but if there are too many of them then it might be cleaner to save them in a separate (and transferable!) bookmarks file


Results - when running various analysis / simulations (eg by changing the initial conditions) one might want to keep track of the results; again a PDataFrame might be a good target for that


Example: Bookmarks
create a persistant data frame (run only once; will erase all data otherwise!)
End of explanation
"""


bm = pdf.PDataFrame('PDataFrame.csv')
bm.set('deposit', ('ILM.W.U2.C.L022.U2.EUR', 'current usage of the deposit facility'))
bm.set('lending', ('ILM.M.U2.C.A05B.U2.EUR', 'current aggregate usage of major lending facilities'))
bm.set('lending_marg', ('ILM.W.U2.C.A055.U2.EUR', 'current usage of the marginal lending facility'))
bm.set('another_one', ('NA.NA', 'lorem ipsum'))

"""
Explanation: enter data into the dataframe; this code only has to be run once, ie it can be removed afterwards; it can be run more than once without issue though, as long as the keys don't change the contents is simply overwritten
End of explanation
"""


bm.get('deposit')

bm.get('deposit', 'key')

"""
Explanation: the get method allows to retrieve the data
End of explanation
"""


bm = pdf.PDataFrame('PDataFrame.csv')
bm.df()

"""
Explanation: df() returns the underlying dataframe
End of explanation
"""


bm.delete('another_one')

bm = pdf.PDataFrame('PDataFrame.csv')
bm.df()

"""
Explanation: rows can be deleted using delete
End of explanation
"""


