In [2]:
import pandas as pd
daily_engagements = pd.read_csv('./resources/daily_engagement_full.csv')
len(daily_engagements['acct'].unique())


Out[2]:
1237

In [12]:
import numpy as np

# First 20 countries with employment data
countries = np.array([
    'Afghanistan', 'Albania', 'Algeria', 'Angola', 'Argentina',
    'Armenia', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas',
    'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium',
    'Belize', 'Benin', 'Bhutan', 'Bolivia',
    'Bosnia and Herzegovina'
])

# Employment data in 2007 for those 20 countries
employment = np.array([
    55.70000076,  51.40000153,  50.5       ,  75.69999695,
    58.40000153,  40.09999847,  61.5       ,  57.09999847,
    60.90000153,  66.59999847,  60.40000153,  68.09999847,
    66.90000153,  53.40000153,  48.59999847,  56.79999924,
    71.59999847,  58.40000153,  70.40000153,  41.20000076
])

# Change False to True for each block of code to see what it does

# Accessing elements
if False:
    print( countries[0])
    print( countries[3])

# Slicing
if False:
    print( countries[0:3])
    print( countries[:3])
    print( countries[17:])
    print( countries[:])

# Element types
if False:
    print( countries.dtype)
    print( employment.dtype)
    print( np.array([0, 1, 2, 3]).dtype)
    print( np.array([1.0, 1.5, 2.0, 2.5]).dtype)
    print( np.array([True, False, True]).dtype)
    print( np.array(['AL', 'AK', 'AZ', 'AR', 'CA']).dtype)

# Looping
if False:
    for country in countries:
        print( 'Examining country {}'.format(country))

    for i in range(len(countries)):
        country = countries[i]
        country_employment = employment[i]
        print( 'Country {} has employment {}'.format(country,
                country_employment))

# Numpy functions
if True:
    print( employment.mean())
    print( employment.std())
    print( employment.max())
    print( employment.sum())


58.6850000385
9.33826911369
75.69999695
1173.70000077

In [18]:
def max_employment(countries, employment):
    '''
    Fill in this function to return the name of the country
    with the highest employment in the given employment
    data, and the employment in that country.
    '''
    max_key = employment.argmax()  
    max_value =  employment[max_key]
    max_country = countries[max_key]      

    return (max_country, max_value)

max_employment(countries, employment)


Out[18]:
('Angola', 75.699996949999999)

In [ ]: