def test_get_row():

    dictionary = {"column 1": [1, 2, 3, 4], "column 2": [5, 6, 7, 8]}

    df = dataframe(dictionary)

    answer = df.get_row(0)

    expected_answer = [1, 5]

    assert answer == expected_answer
Esempio n. 2
0
def test_sum_numbers_avoid_nonnumerical():

    dictionary = {"column 1": [1, 2, 3, 4], "column 2": ["a", "b", "c", "d"]}

    df = dataframe(dictionary)

    answer = df.sum()

    expected_answer = [10]

    assert answer == expected_answer
Esempio n. 3
0
def test_mean_numbers():

    dictionary = {"column 1": [1, 2, 3, 4], "column 2": [5, 6, 7, 8]}

    df = dataframe(dictionary)

    answer = df.mean()

    expected_answer = [2.5, 6.5]

    assert answer == expected_answer
Esempio n. 4
0
def test_sum_numbers():

    dictionary = {"column 1": [1, 2, 3, 4], "column 2": [5, 6, 7, 8]}

    df = dataframe(dictionary)

    answer = df.sum()

    expected_answer = [10, 26]

    assert answer == expected_answer
Esempio n. 5
0
def test_var_numbers():

    dictionary = {"column 1": [1, 2, 3, 4, 5], "column 2": [5, 6, 7, 8, 9]}

    df = dataframe(dictionary)

    answer = df.var()

    expected_answer = [2, 2]

    assert answer == expected_answer
Esempio n. 6
0
def test_range_numbers():

    dictionary = {"column 1": [1, 2, 3, 4], "column 2": [5, 6, 7, 8]}

    df = dataframe(dictionary)

    answer = df.range()

    expected_answer = [3, 3]

    assert answer == expected_answer
Esempio n. 7
0
def test_set_item():

    dictionary = {"c1": [1, 2, 3, 4],
                  "c2": ["a", "b", "c", "d"],
                  "c3": [5.5, 6.5, 7.5, 8.5],
                  "c4": [True, False, True, False]}

    df = dataframe(dictionary)
    df['c1'] = [1, 0, 0, 0]

    answer = df['c1']
    expected_answer = np.asarray([1, 0, 0, 0])

    assert np.all(answer == expected_answer)
Esempio n. 8
0
def test_mode_numbers():

    dictionary = {
        "column 1": [1, 2, 3, 4, 3, 5, 2, 3, 4, 5, 1, 2, 2, 2, 2],
        "column 2": [5, 6, 7, 8, 8, 8, 8, 5, 1, 8, 2, 1, 4, 8]
    }

    df = dataframe(dictionary)

    answer = df.mode()

    expected_answer = [2, 8]

    assert answer == expected_answer
Esempio n. 9
0
def test_std_numbers():

    dictionary = {"column 1": [1, 2, 3, 4, 5], "column 2": [5, 6, 7, 8, 9]}

    df = dataframe(dictionary)

    list = df.std()
    answer = []

    for i in range(0, len(list)):
        rounded_number = round(list[i], 2)
        answer.append(rounded_number)

    expected_answer = [1.41, 1.41]

    assert answer == expected_answer
Esempio n. 10
0
def test_del_item():

    dictionary = {
        "c1": [1, 2, 3, 4],
        "c2": ["a", "b", "c", "d"],
        "c3": [5.5, 6.5, 7.5, 8.5],
        "c4": [True, False, True, False]
    }

    df = dataframe(dictionary)

    del df['c1']
    try:
        df['c1']
    except Exception:
        answer = True

    expected_answer = True

    assert answer == expected_answer
from ie_pandas import dataframe

test_data = {
    "column 1": [1, 2, 3, 4, 5],
    "column 2": [True, False, True, False, False],
    "column 3": ['t1', 't2', 't3', 't4', 't5'],
    "column 4": [16, 17, 18, 19, 20]
}

df = dataframe(test_data)

print(df)