def test_count_birds_small_table():
    input_df = pd.read_csv('birds_sm.csv', index_col='Species')
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df['2010'], 24.5)
예제 #2
0
import pandas as pd
import analysis_functions as af

birds_df = pd.read_csv('birds_lg.csv', index_col='Species')

results_df = af.count_birds(birds_df)

results_df.to_csv('birds_results.csv')
ax = results_df.T.plot()  # 11
fig = ax.get_figure()
fig.savefig('birds_results.pdf')
def test_count_birds_one_species():
    input_df = pd.DataFrame([[1, 2]], index=['Sp1'], columns=['2010', '2011'])
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df, [[1, 2]])
def test_count_birds_empty_input():
    input_df = pd.DataFrame([[]])
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df, [[]])
def test_count_birds_zero_year():
    input_df = pd.DataFrame([[0, 2], [0, 4]],
                            index=['Sp1', 'Sp2'],
                            columns=['2010', '2011'])
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df['2010'], 0)
def test_count_birds_handles_bad_input():
    input_df = pd.DataFrame([[None, 2], [3, 4]],
                            index=['Sp1', 'Sp2'],
                            columns=['2010', '2011'])
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df, [[3, 3]])
def test_count_birds_simulated_data():
    input_df = pd.DataFrame([[1, 2], [3, 4]],
                            index=['Sp1', 'Sp2'],
                            columns=['2010', '2011'])
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df, [[2, 3]])
def test_count_birds_simulated_data():
    input_df = pd.DataFrame([[1,2],[3,4]],
        index=['Sp1', 'Sp2'], columns=['2010', '2011'])
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df, [[2, 3]])
def test_count_birds_small_table():
    input_df = pd.read_csv('birds_sm.csv', index_col='Species')
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df['2010'], 24.5)
예제 #10
0
def test_count_birds_zero():
    input_df = pd.DataFrame([[0,2],[0,4]],
        index=['Sp1', 'Sp2'], columns=['2010', '2011'])
    results_df = af.count_birds(input_df)
    np.testing.assert_array_equal(results_df, [[0, 3]])
예제 #11
0
import pandas as pd  # 1
import analysis_functions as af

birds_df = pd.read_csv('../data/birds_lg.csv', index_col='Species')  # 2



results_df = af.count_birds(birds_df)  # 9
print(results_df)

results_df.to_csv('../results/birds_results.csv')  # 10

ax = results_df.T.plot()  # 11
fig = ax.get_figure()
fig.savefig('../results/birds_results.pdf')