Extending Plot on Pandas DataFrame

Viewed 158

I want to extend the plot function to use a custom plot function in conjunction with the existing pandas' plot functions. What is the best way to do this?

If I override plot() I lose the ability to get to the old functions correct? or is there some way I can still call the old plot functions?

Update

I can use super() to call the parent's class and it appears to be working quite well. If this is a poor solution, please post an answer!

import pandas as pd
class CustomDataFrame(pd.DataFrame):
    def plot(self, *args, **kwargs):
        if 'kind' in kwargs and \
           kwargs['kind'].lower() == 'dotmapplot':
           return _custom_plot(*args, **kwargs)
        else: 
          super(CustomDataFrame, self).plot(*args, **kwargs)

Thank you

0 Answers
Related