import json
import collections


def df_to_datatables(df, double_precision=5, indent=2):
    """
    Convert a pandas dataframe to a JSON object formatted for datatables input.
    """
    dump_str = df.to_json(orient='split', double_precision=double_precision)
    obj = json.loads(dump_str)
    del obj['index']
    obj = collections.OrderedDict(obj)
    obj.move_to_end('data')
    return obj