<commit_before>import pandas as pd

def parse_sheet_index(df, index):
    """Parse sheet index into df index"""
    if index and len(df.columns) > index:
        df = df.set_index(df.columns[index - 1])
        # if it was multi-index, the name is tuple;
        # choose last value in tuple since that is more common
        if type(df.index.name) == tuple:
            df.index.name = df.index.name[-1]
        # get rid of falsey index names
        df.index.name = df.index.name or None
    return df

def parse_df_col_names(df, include_index):
    """Parse column names from a df into sheet headers"""
    headers = df.columns.tolist()

    # handle multi-index headers
    if len(headers) > 0 and type(headers[0]) == tuple:
        headers = [list(row) for row in zip(*headers)]

        # Pandas sets index name as top level col name with reset_index
        # Switch to low level since that is more natural
        if include_index:
            headers[-1][0] = headers[0][0]
            headers[0][0] = ''
    # handle regular columns
    else:
        headers = [headers]

    return headers

def parse_sheet_headers(vals, header_rows):
    """Parse headers from a sheet into df columns"""
    col_names = None
    if header_rows:
        headers = vals[:header_rows]
        if header_rows > 1:
            _fix_sheet_header_level(headers)
            col_names = pd.MultiIndex.from_arrays(headers)
        elif header_rows == 1:
            col_names = pd.Index(headers[0])

    return col_names
<commit_msg>Fix parse_sheet_headers when sheet is empty<commit_after>import pandas as pd

def parse_sheet_index(df, index):
    """Parse sheet index into df index"""
    if index and len(df.columns) > index:
        df = df.set_index(df.columns[index - 1])
        # if it was multi-index, the name is tuple;
        # choose last value in tuple since that is more common
        if type(df.index.name) == tuple:
            df.index.name = df.index.name[-1]
        # get rid of falsey index names
        df.index.name = df.index.name or None
    return df

def parse_df_col_names(df, include_index):
    """Parse column names from a df into sheet headers"""
    headers = df.columns.tolist()

    # handle multi-index headers
    if len(headers) > 0 and type(headers[0]) == tuple:
        headers = [list(row) for row in zip(*headers)]

        # Pandas sets index name as top level col name with reset_index
        # Switch to low level since that is more natural
        if include_index:
            headers[-1][0] = headers[0][0]
            headers[0][0] = ''
    # handle regular columns
    else:
        headers = [headers]

    return headers

def parse_sheet_headers(vals, header_rows):
    """Parse headers from a sheet into df columns"""
    col_names = None
    if header_rows:
        headers = vals[:header_rows]
        if len(headers) > 0:
            if header_rows > 1:
                _fix_sheet_header_level(headers)
                col_names = pd.MultiIndex.from_arrays(headers)
            elif header_rows == 1:
                col_names = pd.Index(headers[0])

    return col_names

{'fraction_non_alphanumeric': 0.09490221224751523, 'fraction_numerical': 0.008656620711766592, 'mean_word_length': 2.3620689655172415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1642776', 'n_tokens_mistral': 926, 'n_tokens_neox': 901, 'n_words': 304}