Beispiel #1
0
def test_input_int_in_np_mean():
    obj = np.array([30, 53, 31, 47, 32])
    df = DataFrame(obj, colindex=["AGE"], rowindex=["A", "B", "C", "D", "E"])

    expected_output = [38.6]

    actual_output = df.mean()

    assert actual_output == expected_output
Beispiel #2
0
def test_input_mixed_in_np_mean():
    obj = np.array([30, 53.0, "31", True, 32])
    df = DataFrame(obj, colindex=["AGE"], rowindex=["A", "B", "C", "D", "E"])

    expected_output = []

    actual_output = df.mean()

    assert actual_output == expected_output
def test_input_int_in_dict_of_lists_mean():
    obj = {"age": [30, 53, 31, 47, 32], "albums": [4, 10, 2, 5, 4]}
    df = DataFrame(
        obj, colindex=["AGE", "ALBUMS"], rowindex=["A", "B", "C", "D", "E"]
    )

    expected_output = [38.6, 5.0]

    actual_output = df.mean()

    assert actual_output == expected_output
Beispiel #4
0
def test_mean_df():
    data = {
        "value1": [1, 2, 3, 4, 5, 6],
        "value2": [2, 4, 6, 2, 10, 0],
        "value3": [1.1, 2.2, 3.3, 4.4, 5.5, 6.6],
        "value4": ["a", "b", "c", "d", "e", "f"],
    }
    expected_output = np.array([3.5, 4, 3.85, None])
    df = DataFrame(data)
    mean_output = df.mean()
    print(mean_output)
    print(expected_output)

    assert mean_output.all() == expected_output.all()
Beispiel #5
0
def test_input_mixed_in_dict_of_np_mean():
    obj = {
        "age": np.array([30.1, 53.1, 31.1, 47.1, 32.1]),
        "albums": np.array([4, 10, 2, 5, 4]),
        "C": np.array(["a", "b", "c", "d", "e"]),
        "D": np.array([True, False, True, True, False]),
    }
    df = DataFrame(
        obj,
        colindex=["AGE", "ALBUMS", "C", "D"],
        rowindex=["A", "B", "C", "D", "E"],
    )

    expected_output = [38.7, 5.0, 0.6]

    actual_output = df.mean()

    assert actual_output == expected_output
def test_input_mixed_in_list_of_lists_mean():
    obj = [
        [30.1, 53.1, 31.1, 47.1, 32.1],
        [4, 10, 2, 5, 4],
        ["a", "b", "c", "d", "e"],
        [True, False, True, True, False],
    ]
    df = DataFrame(
        obj,
        colindex=["AGE", "ALBUMS", "C", "D"],
        rowindex=["A", "B", "C", "D", "E"],
    )

    expected_output = [38.7, 5.0, 0.6]

    actual_output = df.mean()

    assert actual_output == expected_output
Beispiel #7
0
def test_mean(dictionary, expected):
    myDF = DataFrame(dictionary)
    assert myDF.mean() == expected