def part1(): """ Calculates various statistics about the Pokemon dataset using the implementation in Part 1. """ print('=== Starting Part 1 ===') data = hw2_pandas.parse(DATA) print('Number of species:', hw2_pandas.species_count(data)) print('Highest level pokemon:', hw2_pandas.max_level(data)) print('Low-level Pokemon', hw2_pandas.filter_range(data, 1, 9)) print('Average attack for fire types', hw2_pandas.mean_attack_for_type(data, 'fire')) print('Count of each Pokemon type:') print(hw2_pandas.count_types(data)) print('Highest stage for each Pokemon type') print(hw2_pandas.highest_stage_per_type(data)) print('Average attack for each Pokemon type') print(hw2_pandas.mean_attack_per_type(data))
from cse163_utils import assert_equals # Don't worry about this import syntax, we will talk about it later import hw2_manual import hw2_pandas data1 = hw2_manual.parse('pokemon_test.csv', ['id', 'level', 'atk', 'def', 'hp', 'stage']) data2 = hw2_pandas.parse('pokemon_test.csv') data3 = hw2_manual.parse('pokemon_box.csv', ['id', 'level', 'atk', 'def', 'hp', 'stage']) data4 = hw2_pandas.parse('pokemon_box.csv') data5 = hw2_manual.parse('pokemon_test2.csv', ['id', 'level', 'atk', 'def', 'hp', 'stage']) data6 = hw2_pandas.parse('pokemon_test2.csv') # This file is left blank for you to fill in with your tests! def test_species_count(): """ Test the function species_count """ print('Testing species_count') assert_equals(3, hw2_manual.species_count(data1)) assert_equals(3, hw2_pandas.species_count(data2)) assert_equals(82, hw2_manual.species_count(data3)) assert_equals(82, hw2_pandas.species_count(data4)) assert_equals(8, hw2_manual.species_count(data5)) assert_equals(8, hw2_pandas.species_count(data6))
from cse163_utils import assert_equals # Don't worry about this import syntax, we will talk about it later import hw2_manual import hw2_pandas # Parse .csv files into dataframes using parse function from Part 1 - Pandas NUMERICAL_COLS = ['id', 'level', 'atk', 'def', 'hp', 'stage'] data_m1 = hw2_manual.parse('pokemon_test.csv', NUMERICAL_COLS) data_m2 = hw2_manual.parse('pokemon_box.csv', NUMERICAL_COLS) # Parse .csv files into dataframes using parse function from Part 1 - Pandas data_p1 = hw2_pandas.parse('pokemon_test.csv') data_p2 = hw2_pandas.parse('pokemon_box.csv') def test_species_count(): """ Tests the output of both versions of species_count() function. """ # Test Part 0 - Manual print('Test species_count from Part 0 - Manual') assert_equals(3, hw2_manual.species_count(data_m1)) assert_equals(82, hw2_manual.species_count(data_m2)) # Test Part 1 - Pandas print('Test species_count from Part 1 - Pandas') assert_equals(3, hw2_pandas.species_count(data_p1))
from cse163_utils import assert_equals # Don't worry about this import syntax, we will talk about it later import hw2_manual import hw2_pandas # This file is left blank for you to fill in with your tests! DATA = hw2_pandas.parse('pokemon_test.csv') DATA2 = hw2_pandas.parse('pokemon_jay.csv') NUMERICAL_COLS = ['id', 'level', 'atk', 'def', 'hp', 'stage'] parsed_data = hw2_manual.parse('pokemon_test.csv', NUMERICAL_COLS) parsed_data2 = hw2_manual.parse('pokemon_jay.csv', NUMERICAL_COLS) def test_species_count(): ''' Test spcies_count funciton. ''' print("test_species_count") print('Part0') assert_equals(3, hw2_manual.species_count(parsed_data)) assert_equals(74, hw2_manual.species_count(parsed_data2)) print('Part1') assert_equals(3, hw2_pandas.species_count(DATA)) assert_equals(74, hw2_pandas.species_count(DATA2)) def test_max_level():
from cse163_utils import assert_equals # Don't worry about this import syntax, we will talk about it later import hw2_manual import hw2_pandas # This file is left blank for you to fill in with your tests! DATA1 = 'pokemon_test.csv' DATA2 = 'pokemon_test_by_yw.csv' integer_cols = ['id', 'level', 'atk', 'def', 'hp', 'stage'] data1 = hw2_manual.parse(DATA1, integer_cols) data2 = hw2_pandas.parse(DATA1) data3 = hw2_manual.parse(DATA2, integer_cols) data4 = hw2_pandas.parse(DATA2) def test_species_count(): """ Tests the function: species_count """ print('Testing species_count') # Cases from the made up "spec" for this problem assert_equals(3, hw2_manual.species_count(data1)) assert_equals(3, hw2_pandas.species_count(data2)) # Additional two cases assert_equals(7, hw2_manual.species_count(data3)) assert_equals(7, hw2_pandas.species_count(data4))