Data Management and Visualization: Assignment 3
1) My program can be found here:
https://github.com/fsee/DataScienceClass1/blob/master/Assignment3.py
2) These are the data management decisions that I have made:
Classify all missing data as NaN in python so that it will not be used for further downstream data analysis
Create a secondary variable that is the ratio of the female employment rate of a country (defined as the percentage of women in the population in the workforce) divided by the male employment rate of the country (defined by the overall percentage of the male population that is employed). The GapMinder data set only provides information on the female employment rate of a country and the overall employment rate of the country. Based on the assumption that the human sex ration of binary genders is approximately equal to 1, we can estimate the female to male employment rate to be:Female Employment Rate / Male Employment Rate = Female Employment Rate / (2* Overall Employment Rate - Female Employment Rate)
I then added continent information to the data set so that I could group each country into continent groups to find out how the female to male employment ratio differs by geographic location. In order to achieve this I installed and imported
geonamescache to my program. The Geonamescache package contains country-specific information about the language, population size, continent, etc. of a country. I extracted my own dictionary that maps each country in my GapMinder Data set onto one of the seven continents: 'AF’= Africa, ‘NA’=North America, 'OC’=Oceania, 'SA’=South America, 'AN’=Antartica, 'EU’=Europe, 'AS’=Asia.
This is my program output that displays four variables (female employment rate, overall employment rate, life expectancy, and female to male employment rate) as frequency tables:
Female Employment Rate Interval Frequency
min-max range 11.30000019 83.30000305
Variable Bins Frequency
(11, 16] 0.014085
(16, 21] 0.023474
(21, 26] 0.032864
(26, 31] 0.028169
(31, 36] 0.056338
(36, 41] 0.103286
(41, 46] 0.122066
(46, 51] 0.136150
(51, 56] 0.117371
(56, 61] 0.075117
(61, 66] 0.032864
(66, 71] 0.042254
(71, 76] 0.014085
(76, 81] 0.028169
(81, 86] 0.009390
dtype: float64
Overall Employment Rate Interval Frequency
min-max range 32.0 83.19999695
Variable Bins Frequency
(32, 37] 0.004695
(37, 42] 0.037559
(42, 47] 0.075117
(47, 52] 0.098592
(52, 57] 0.136150
(57, 62] 0.192488
(62, 67] 0.136150
(67, 72] 0.061033
(72, 77] 0.042254
(77, 82] 0.032864
(82, 87] 0.014085
dtype: float64
Life Expectancy Interval Frequency
min-max range 47.794 83.394
Variable Bins Frequency
(47, 52] 0.084507
(52, 57] 0.051643
(57, 62] 0.056338
(62, 67] 0.070423
(67, 72] 0.122066
(72, 77] 0.314554
(77, 82] 0.183099
(82, 87] 0.014085
dtype: float64
Female To Male Employment Rate Interval Frequency
min-max range 19.8717931673 114.484670555
Variable Bins Frequency
(19, 24] 0.028169
(24, 29] 0.009390
(29, 34] 0.028169
(34, 39] 0.018779
(39, 44] 0.018779
(44, 49] 0.042254
(49, 54] 0.032864
(54, 59] 0.037559
(59, 64] 0.070423
(64, 69] 0.065728
(69, 74] 0.061033
(74, 79] 0.117371
(79, 84] 0.131455
(84, 89] 0.084507
(89, 94] 0.042254
(94, 99] 0.028169
(99, 104] 0.014085
(104, 109] 0.000000
(109, 114] 0.000000
dtype: float64
this is my program output that groups the female to male employment rate by continent and shows frequency tables for the same bin range and size:
Female to male employment rate ordered by continent
overall min-max range 19.8717931673 114.484670555
Female to male employment rate distrib for OC
Variable Bins Frequency
(19, 24] 0.000000
(24, 29] 0.000000
(29, 34] 0.000000
(34, 39] 0.000000
(39, 44] 0.000000
(44, 49] 0.050000
(49, 54] 0.000000
(54, 59] 0.000000
(59, 64] 0.000000
(64, 69] 0.100000
(69, 74] 0.000000
(74, 79] 0.000000
(79, 84] 0.100000
(84, 89] 0.000000
(89, 94] 0.000000
(94, 99] 0.050000
(99, 104] 0.000000
(104, 109] 0.000000
(109, 114] 0.000000
dtype: float64
Female to male employment rate distrib for AS
Variable Bins Frequency
(19, 24] 0.122449
(24, 29] 0.020408
(29, 34] 0.081633
(34, 39] 0.061224
(39, 44] 0.040816
(44, 49] 0.020408
(49, 54] 0.020408
(54, 59] 0.081633
(59, 64] 0.020408
(64, 69] 0.061224
(69, 74] 0.040816
(74, 79] 0.122449
(79, 84] 0.102041
(84, 89] 0.122449
(89, 94] 0.040816
(94, 99] 0.020408
(99, 104] 0.020408
(104, 109] 0.000000
(109, 114] 0.000000
dtype: float64
Female to male employment rate distrib for AF
Variable Bins Frequency
(19, 24] 0.000000
(24, 29] 0.018519
(29, 34] 0.037037
(34, 39] 0.018519
(39, 44] 0.018519
(44, 49] 0.074074
(49, 54] 0.018519
(54, 59] 0.018519
(59, 64] 0.111111
(64, 69] 0.074074
(69, 74] 0.055556
(74, 79] 0.111111
(79, 84] 0.092593
(84, 89] 0.074074
(89, 94] 0.111111
(94, 99] 0.055556
(99, 104] 0.037037
(104, 109] 0.000000
(109, 114] 0.000000
dtype: float64
Female to male employment rate distrib for SA
Variable Bins Frequency
(19, 24] 0.000000
(24, 29] 0.000000
(29, 34] 0.000000
(34, 39] 0.000000
(39, 44] 0.000000
(44, 49] 0.000000
(49, 54] 0.166667
(54, 59] 0.083333
(59, 64] 0.166667
(64, 69] 0.166667
(69, 74] 0.083333
(74, 79] 0.250000
(79, 84] 0.083333
(84, 89] 0.000000
(89, 94] 0.000000
(94, 99] 0.000000
(99, 104] 0.000000
(104, 109] 0.000000
(109, 114] 0.000000
dtype: float64
Female to male employment rate distrib for NA
Variable Bins Frequency
(19, 24] 0.000000
(24, 29] 0.000000
(29, 34] 0.000000
(34, 39] 0.000000
(39, 44] 0.032258
(44, 49] 0.064516
(49, 54] 0.096774
(54, 59] 0.064516
(59, 64] 0.096774
(64, 69] 0.064516
(69, 74] 0.032258
(74, 79] 0.032258
(79, 84] 0.161290
(84, 89] 0.032258
(89, 94] 0.000000
(94, 99] 0.000000
(99, 104] 0.000000
(104, 109] 0.000000
(109, 114] 0.000000
dtype: float64
Female to male employment rate distrib for EU
Variable Bins Frequency
(19, 24] 0.000000
(24, 29] 0.000000
(29, 34] 0.000000
(34, 39] 0.000000
(39, 44] 0.000000
(44, 49] 0.021277
(49, 54] 0.000000
(54, 59] 0.000000
(59, 64] 0.063830
(64, 69] 0.021277
(69, 74] 0.127660
(74, 79] 0.191489
(79, 84] 0.212766
(84, 89] 0.148936
(89, 94] 0.021277
(94, 99] 0.021277
(99, 104] 0.000000
(104, 109] 0.000000
(109, 114] 0.000000
dtype: float64
Most of the female to male employment frequency distributions lie between 39% and 84%. However, I noticed that there are three countries in this data set that have a slightly larger female working force than other countries with are largely dominated by a male working force. I was curious which countries these were, here is the result:
Countries in which more women than men work
29 Burundi
131 Mozambique
160 Rwanda
Name: country, dtype: object
This is what I have learned this week:
- Any data frame can be added to any other data frame even if they do not have the same number of rows, be careful when merging raw data with frequency distributions, for instance
- a set() is a built-in Python function that outputs the unique subset of a list and gets rid of multiples that might exist in a list
- importing data dictionaries from the web e.g. country and continent information, curate them to match the unique identifiers of the GapMinder data set and use this additional information to gain geographic knowledge from the provided data
- good data analysis requires careful deliberation before anything gets implemented: suggestion for the future: Think and write the summary before impl