Esempio n. 1
0
def get_sea_frequencies(MyPyTable, col_name):
    """Gets the frequency and count of a column by name

    Args:
        MyPyTable(MyPyTable): self of MyPyTable
        col_name(str): name of the column

    Returns:
        values, counts (string, int): name of value and its frequency"""

    rain_col = MyPyTable.get_column(col_name)
    row_index_to_drop = []
    print("range:", len(rain_col), len(MyPyTable.data))
    for i in range(len(rain_col)):
        if rain_col[i] == "FALSE":
            row_index_to_drop.append(i)
    
    count = 0
    row_to_drop = []
    for i in range(len(MyPyTable.data)):
        if i in row_index_to_drop:
            row_to_drop.append(MyPyTable.data[i])

    MyPyTable.drop_rows(row_to_drop)
    months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
    month_col = MyPyTable.get_column('DATE')
    yes_col = []
    for month in months:
        yes = 0
        for i in range(len(month_col)):
            if month in month_col[i]:
                yes = yes + 1
        yes_col.append(yes)

    return months, yes_col
Esempio n. 2
0
def get_aus_frequencies(MyPyTable, col_name):
    """Gets the frequency and count of a column by name

    Args:
        MyPyTable(MyPyTable): self of MyPyTable
        col_name(str): name of the column

    Returns:
        values, counts (string, int): name of value and its frequency"""

    rain_col = MyPyTable.get_column("RainToday")
    row_index_to_drop = []
    for i in range(len(rain_col)):
        if rain_col[i] == "No":
            row_to_drop.append(i)
    row_to_drop = []
    for i in range(len(MyPyTable.data)):
        if i in row_index_to_drop:
            row_to_drop.append(i)

    table = MyPyTable.drop_rows(rows_to_drop)
    table.pretty_print()
    return table
    values = []
    counts = []
    '''for value in col: