I have some dictionaries that I use in a package of mine that could easily be pandas.Series
s. However, I leave them as dicts
simply because of the .update
method, which both changes existing values and adds a new values to the dict in place. The pandas.Series.update
only changes values in place. So I am forced to use dicts (I think at least).
The drag is that dicts are hard to read when you print them with the print function, so I'd like to print them more nicely for the user. The only way I know how to do this is creating a function solely for printing dicts, which I'd like to avoid. Is there someway that I can inherently change dicts so that, after running some command, every dict is printed more nicely? Maybe even quickly convert them into a pandas Series just for printing, since my dicts are very small. Something like
def _print_dict(self):
print(pd.Series(self))
and then I could throw this somewhere such as
dict.__print_method__ = _print_dict
if __print_method__
were the method that the print function calls when printing dicts.