def df_memory_usage(df):
    """return the number of megabytes a dataframe/Series uses including index"""
    mem_in_bytes = df.memory_usage(index=True)
    while hasattr(mem_in_bytes, 'shape') and mem_in_bytes.shape:
        mem_in_bytes = mem_in_bytes.sum()
    return mem_in_bytes / 1024.0 / 1024.0
