(table, split_texts_in_lines=False, **kwargs)
return pd.DataFrame(col_series)
Create a pandas dataframe using datatable <table> and joining all texts in the individual cells.
Create a pandas dataframe using datatable <table> and joining all texts in the individual cells.
Create a pandas dataframe using datatable <table > and joining all texts in the individual cells .
def datatable_to_dataframe(table, split_texts_in_lines=False, **kwargs):
    """
    Create a pandas dataframe using datatable <table> and joining all texts in the individual cells.
    """
    import pandas as pd
    
    n_rows = len(table)
    if n_rows == 0:
        raise ValueError('data table must contain rows')
    
    n_cols = len(table[0])
    if n_cols == 0:
        raise ValueError('data table must contain columns')
    
    col_series = OrderedDict()
    zfill_n = len(str(n_cols + 1))
    for i in range(n_cols):
        col_data = []
        for j in range(n_rows):
            if split_texts_in_lines:
                cell_str = create_text_from_lines(put_texts_in_lines(table[j][i]), **kwargs)
            else:
                cell_str = join_texts(table[j][i], **kwargs)
                
            col_data.append(cell_str)
        
        ser = pd.Series(col_data)
        ser.name = 'col' + str(i + 1).zfill(zfill_n)
        col_series[ser.name] = ser
    
    return pd.DataFrame(col_series)
def datatable_to_dataframe ( table , split_texts_in_lines = False , * * kwargs ) : import pandas as pd n_rows = len ( table ) if n_rows == 0 : raise ValueError ( 'data table must contain rows' ) n_cols = len ( table [ 0 ] ) if n_cols == 0 : raise ValueError ( 'data table must contain columns' ) col_series = OrderedDict ( ) zfill_n = len ( str ( n_cols + 1 ) ) for i in range ( n_cols ) : col_data = [ ] for j in range ( n_rows ) : if split_texts_in_lines : cell_str = create_text_from_lines ( put_texts_in_lines ( table [ j ] [ i ] ) , * * kwargs ) else : cell_str = join_texts ( table [ j ] [ i ] , * * kwargs ) col_data . append ( cell_str ) ser = pd . Series ( col_data ) ser . name = 'col' + str ( i + 1 ) . zfill ( zfill_n ) col_series [ ser . name ] = ser return pd . DataFrame ( col_series )