def test_std(dictionary, expected): myDF = DataFrame(dictionary) assert myDF.std() == expected
def test_mean(dictionary, expected): myDF = DataFrame(dictionary) assert myDF.mean() == expected
def test_var(dictionary, expected): myDF = DataFrame(dictionary) assert myDF.var() == expected
def test_get_row_errors(): with pytest.raises(IndexError): myDF = DataFrame(npDict1) x = myDF.get_row(5)
def test_get_row(dictionary, arg, expected): myDF = DataFrame(dictionary) assert myDF.get_row(arg) == expected
def test_set_item(dictionary, arg, value): myDF = DataFrame(dictionary) myDF[arg] = value np.testing.assert_array_equal(myDF[arg], np.array(value))
def test_create_DF_from_list_of_lists(data, expected_df): df = DataFrame(data) assert (df.data == expected_df).all()
def test_create_DF_from_nparray(data, expected_df): df = DataFrame(data) assert (df.data == expected_df).all()
# test_get2 from ie_pandas import DataFrame import numpy as np # Define test to get more than one item def test_get(): dictionary = { "pet": np.array(["cat", "dog", "mouse"]), "age": np.array([1, 2, 3]), "weight": np.array([1.0, 2.0, 3.0]), "sick": np.array([True, True, False]), } group0 = ["cat","dog"] df=DataFrame(dictionary) assert df[["pet"]][0:2] == group0
def test_initialization_No_Params(): with pytest.raises(ValueError) as ValError: # Error on Object Generation so Fail. Data needed df = DataFrame()