Customized method for dataframe in my analysis module Please download the file and save in home directory and extract it:

https://www.dropbox.com/s/swtw8bk35zr1i6d/analyse.7z?dl=0

I can get some warrants info.

import analyse
df = analyse.warrants.get('0788')


Now we got 0788's warrants info. It output df with better format:

analyse.tabulate.tabulate(df)


I want to simply the expression as df.tabulate(). How do I refactor the code in analyse directory?

Show content in tabulate.py:

import pandas as pd
from terminaltables import AsciiTable   

def tabulate(df):
    rows = len(df)
    head = [df.columns.tolist()]
    nr = df.values.tolist()
    content = head + nr
    table = AsciiTable(content)
    data_str = table.table.split('\n')
    sep_line = data_str[0]
    transformed_str = []
    for ind in range(0,len(data_str)-1):
        if ind &lt; 3 :
            transformed_str.append(data_str[ind])
        else:
            transformed_str.append(data_str[ind])
            transformed_str.append(sep_line)
    new_str = "\n".join(transformed_str) + '\n' + '\n'  + '[ {} records ]'.format(rows-1)
    print(new_str)


I want to refactor analyse.tabulate.tabulate(df) as df.tabulate(). It is the simplest way to use df.tabulate() to get well-formatted dataframe.
This if statement

    if ind &lt; 3 :
        transformed_str.append(data_str[ind])
    else:
        transformed_str.append(data_str[ind])
        transformed_str.append(sep_line)


Can be rewritten as

    transformed_str.append(data_str[ind])
    if ind &gt;= 3:
        transformed_str.append(sep_line)