Data Management & Visualization: First Program
I'm examining the relationship between urbanization, total employment, and female employment. These are all from the Gapminder dataset and are recorded as rates per country, e.g. 88.23. There were 288 observations (countries/territories) to begin with, but taking only rows with numeric data in them reduced this to 173. I don't think the assignment was written with data like this in mind, as the frequency tables in the console are too long to display. These rates are unique enough that very few of them had frequency > 1, so I rounded them to the nearest integer percentage. The full Python script and its output are included at the bottom of this entry. Here is some output from the first code section:
Urbanization Rates: 10 1 13 3 15 1 17 3 18 2 19 1 20 1 21 1 22 2 24 1 25 2 26 2 27 3 28 3 30 3 31 2 32 1 33 2 34 3 35 1 36 2 37 5 38 2 39 2 40 1 41 2 42 4 43 3 47 3 48 2 .. 66 4 67 4 68 5 69 3 70 2 71 2 72 2 73 4 74 3 75 2 76 1 77 4 78 3 80 1 81 1 82 4 84 1 85 2 86 1 87 3 88 1 89 2 90 1 92 4 93 2 94 1 96 1 97 1 98 2 100 3 Name: urbanrate, dtype: int64
The lowest rate is 10% and there are several countries with rates in the 98%-100% range. There do seem to be more observations for the upper 60s and lower 70s, but it's difficult to say this with any certainty. Because of this, I used the .describe() function on each of the variables of interest.
Urban Rate count 173.000000 mean 56.630058 std 23.242444 min 10.000000 25% 37.000000 50% 59.000000 75% 74.000000 max 100.000000 Name: urbanrate, dtype: float64
From this, we can see that the average urbanization rate is about 57%, which is lower than the median of 59%, meaning there are more countries with a below average rate of urbanization.The lowest rate is 10% and there are several countries with rates in the 98%-100% range.
Total Employment Rate count 173.000000 mean 58.994220 std 10.459499 min 32.000000 25% 52.000000 50% 59.000000 75% 65.000000 max 83.000000Name: EMPLOYRATE, dtype: float64
Data for total employment is a little more homogeneous: the mean and median are roughly equal and more than half of the observations are within ±10% of the average. The lowest employment rate was 32% and the highest was 83%. Note: this is percentage of the population aged 15+, so it tends to include students, the elderly, and the disabled and would only approach 100% under very unusual circumstances.
Female Employment Rate count 173.000000 mean 47.757225 std 14.784067 min 11.000000 25% 39.000000 50% 48.000000 75% 56.000000 max 83.000000 Name: FEMALEEMPLOYRATE, dtype: float64
The mean and median of the female employment rate are likewise similar, roughly 48%, as is the maximum rate, 83%, but the 75th percentile is lower than the total rate (56% vs. 65%) and the lowest rate is significantly lower (11% vs 32%). Note: this data is analogous to the above category, but is female only.
The data show a very broad spectrum of urbanization around the globe, with the average country having a majority of its population in an urban setting. Total employment was far more similar, but it appears that (generally speaking) far more men are employed than women, though some some countries may achieve maximum employment for both.
data = pandas.read_csv('gapminderGHtry.csv', low_memory=False) #print(len(data)) #print(len(data.columns)) #288 rows, 16 columns #converting to numeric values data['urbanrate'] = pandas.to_numeric(data['urbanrate'],errors='coerce') data['EMPLOYRATE'] = pandas.to_numeric(data['EMPLOYRATE'],errors='coerce') data['FEMALEEMPLOYRATE'] = pandas.to_numeric(data['FEMALEEMPLOYRATE'],errors='coerce') print('coerced') #dropping bad data data = data.dropna(subset=['urbanrate','EMPLOYRATE','FEMALEEMPLOYRATE']) #rounding to nearest perent integer data['urbanrate']= data['urbanrate'].round(decimals=0) data['EMPLOYRATE']= data['EMPLOYRATE'].round(decimals=0) data['FEMALEEMPLOYRATE']= data['FEMALEEMPLOYRATE'].round(decimals=0) #sorting variables of interest cUrban = data['urbanrate'].value_counts(sort=False, dropna=False) cEmploy = data['EMPLOYRATE'].value_counts(sort=False, dropna=False) cFemploy = data['FEMALEEMPLOYRATE'].value_counts(sort=False, dropna=False) print("Urbanization Rates:\n",cUrban) ''' Part 2 ''' print("Urban Rate\n", data['urbanrate'].describe() ) print("Total Employment Rate\n", data['EMPLOYRATE'].describe() ) print("Female Employment Rate\n", data['FEMALEEMPLOYRATE'].describe() )
runfile('C:/Users/Owninator/Documents/Python Practice/Coursera Data Specialization/Data Tools/Week 2 Ass Man&Viz.py', wdir='C:/Users/Owninator/Documents/Python Practice/Coursera Data Specialization/Data Tools') coerced Urbanization Rates: 10 1 13 3 15 1 17 3 18 2 19 1 20 1 21 1 22 2 24 1 25 2 26 2 27 3 28 3 30 3 31 2 32 1 33 2 34 3 35 1 36 2 37 5 38 2 39 2 40 1 41 2 42 4 43 3 47 3 48 2 .. 66 4 67 4 68 5 69 3 70 2 71 2 72 2 73 4 74 3 75 2 76 1 77 4 78 3 80 1 81 1 82 4 84 1 85 2 86 1 87 3 88 1 89 2 90 1 92 4 93 2 94 1 96 1 97 1 98 2 100 3 Name: urbanrate, dtype: int64 Urban Rate count 173.000000 mean 56.630058 std 23.242444 min 10.000000 25% 37.000000 50% 59.000000 75% 74.000000 max 100.000000 Name: urbanrate, dtype: float64 Total Employment Rate count 173.000000 mean 58.994220 std 10.459499 min 32.000000 25% 52.000000 50% 59.000000 75% 65.000000 max 83.000000 Name: EMPLOYRATE, dtype: float64 Female Employment Rate count 173.000000 mean 47.757225 std 14.784067 min 11.000000 25% 39.000000 50% 48.000000 75% 56.000000 max 83.000000 Name: FEMALEEMPLOYRATE, dtype: float64 v














