def structs2pandas(structs):
    """convert ctypes structure or structure array to pandas data frame"""
    try:
        import pandas
        records = list(structs2records(structs))
        df = pandas.DataFrame.from_records(records)
        # TODO: do this for string columns, for now just for id
        # How can we check for string columns, this is not nice:
        # df.columns[df.dtypes == object]
        if 'id' in df:
            df["id"] = df["id"].apply(str.rstrip)
        return df
    except ImportError:
        # pandas not found, that's ok        
        return structs
def structs2pandas ( structs ) : try : import pandas records = list ( structs2records ( structs ) ) df = pandas . DataFrame . from_records ( records ) if 'id' in df : df [ "id" ] = df [ "id" ] . apply ( str . rstrip ) return df except ImportError : return structs
convert ctypes structure or structure array to pandas data frame