dsro0918
dsro0918
Data Management and Visualization - Week 2 Assignment
2 posts
Don't wanna be here? Send us removal request.
dsro0918 · 7 years ago
Text
Data Management and Visualization - Week 2 Assignment
Week 2 Assignment Step 1.  Source Code for Python Program: Week2 assignment.py # -*- coding: utf-8 -*- """ Created on Wed Oct 17 18:25:52 2018
@author: David Srode """ # Data Management and Visualization - Week 2 Assignment
import pandas as pd import numpy
data = pd.read_csv('ool_pds.csv', low_memory=False)
# Coerce all data to numeric format to ensure reliable sorting data["W1_C1"]=pd.to_numeric(data["W1_C1"]) data["W1_C1"]=pd.to_numeric(data["W1_C2"]) data["W1_C1"]=pd.to_numeric(data["PPEDUC"]) data["W1_C1"]=pd.to_numeric(data["W1_P2"])
# Produce frequency tables for responses to W1_C1 Party Alignment
print("Frequency Counts for W1_C1 - Party Alignment") c1 = data["W1_C1"].value_counts(sort=True, ascending=False) print(c1)
print("Frequency Percentages for W1_C1 - Party Alignment") p1 = data['W1_C1'].value_counts(sort=True,ascending=False, normalize=True)  print(p1)
# Produce frequency tables for responses to W1_C2 Political Orientation
print("Frequency Counts for W1_C2 - Political Orientation") c2 = data["W1_C2"].value_counts(sort=True, ascending=False) print(c2)
print("Frequency Percentages for W1_C2 - Political Orientation") p2 = data['W1_C2'].value_counts(sort=True, ascending=False, normalize=True) print (p2)
# Produce frequency tables for responses to PPEDUC - Education
print("Frequency Counts for PPEDUC - Education") c3 = data["PPEDUC"].value_counts(sort=True, ascending=False) print(c3)
print("Frequency Percentages for PPEDUC - Education") p3 = data['PPEDUC'].value_counts(sort=True, ascending=False, normalize=True) print (p3)
Step 2.  Output Showing Frequency Distributions for Selected Variables
runfile('C:/Users/dcs/Documents/Training/Coursera/Week2 assignment.py', wdir='C:/Users/dcs/Documents/Training/Coursera')
Frequency Counts for W1_C1 - Party Alignment  2    1251  3     555  1     331  4     108 -1      49 Name: W1_C1, dtype: int64
Frequency Percentages for W1_C1 - Party Alignment  2    0.545336  3    0.241935  1    0.144289  4    0.047079 -1    0.021360 Name: W1_C1, dtype: float64
Frequency Counts for W1_C2 - Political Orientation  4    874  2    312  6    311  5    297  3    286  7     79  1     75 -1     60 Name: W1_C2, dtype: int64
Frequency Percentages for W1_C2 - Political Orientation  4    0.380994  2    0.136007  6    0.135571  5    0.129468  3    0.124673  7    0.034438  1    0.032694 -1    0.026155 Name: W1_C2, dtype: float64
Frequency Counts for PPEDUC - Education 9     700 10    490 12    414 13    215 11    192 8      79 14     64 7      53 6      35 4      22 5      19 1       6 3       4 2       1 Name: PPEDUC, dtype: int64
Frequency Percentages for PPEDUC - Education 9     0.305144 10    0.213601 12    0.180471 13    0.093723 11    0.083697 8     0.034438 14    0.027899 7     0.023104 6     0.015257 4     0.009590 5     0.008282 1     0.002616 3     0.001744 2     0.000436 Name: PPEDUC, dtype: float64
Step 3. Discussion on Frequency Distributions for Selected Variables
The data for this analysis was taken from the Outlook on Life Surveys that were designed to study political and social attitudes in the United States. It consisted of two surveys conducted between August and December 2012 using a random sample from an Internet panel for targeted populations based on race (i.e., White, African-American/Black), age (18 or older) and gender. 2,294 respondents participated in this study; 1,601 were re-interviewed.
There was no missing data for any variable. A definitive response was recorded for each observation of PPEDUC while the value -1 was used to record the refusal to provide a response for variables W1_C1 and/or W1_C2.
  For Party Affiliation (W1_C1), the responses were skewed to 2 - Democrats (54.5%) or 3 - Independents (24.2%) with a smaller share of respondents responding as 1 - Republicans (14.4%).   For Political Orientation (W1_C2), a profile of the responses resembled the bell-shaped curve of a normal distribution. A significant portion of respondents identified as "4 - Moderate, or middle of the road" (38.1%). Responses for 3- Slightly Liberal, 2 - Liberal, 5 - Slightly Conservative and 6 - Conversative followed a similar pattern (12.5%, 13.6%, 12.9% and 13.6%, respectively). At the far ends of this spectrum were 1 - Extremely Liberals (3.3%) and 7 - Extremely Conservatives (3.4%).   The highest education levels achieved (PPEDUC) were those having a 9 - High School Education or GED (30.5%) or some college/college degree(s) (responses 10 - 14 accounting for 60%). A very small percentage of respondents (less than 10% in total) had never graduated High School.
0 notes
dsro0918 · 7 years ago
Text
Data Management and Visualization Week 1 Assignment
Step 1 - Dataset Selection
I am very interested in the current political situation in the United States, particularly since the start of the financial crisis and Great Recession that started in 2008. The Outlook on Life Surveys, and the accompanying ool_pds.csv dataset, is relevent to this interest and many of the variables may help me better understand the political choices many people have been making during the past ten years.
Step 2 - Topic of Interest (Primary)
After reviewing the OOL codebook, I am interested in the associations between levels of educational attainment and an individual’s political orientation, i.e., the degree of conservative or liberal leaning vs. party affiliation.
Step 3 – Codebook (Primary Topic)
W1_C2: We hear a lot of talk these days about liberals and conservatives. Where would you place YOURSELF on this 7 point scale?
Value Label Unweighted
Frequency %
1 Extremely liberal 75 3.3 %
2 Liberal 312 13.6 %
3 Slightly liberal 286 12.5%
4 Moderate; middle of the road 874 38.1 %
5 Slightly conservative 297 12.9 %
6 Conservative 311 13.6 %
7 Extremely conservative 79 3.4 %
Missing Data
-1 Refused 60 2.6 %
Total 2,294 100%
Based upon 2,234 valid cases out of 2,294 total cases.
• Minimum: 1.00
• Maximum: 7.00
PPEDUC: Education (Highest Degree Received)
Value Label Unweighted
Frequency %
 
1 No formal education 6 0.3 %
2 1st, 2nd, 3rd, or 4th grade 1 0.0 %
3 5th or 6th grade 4 0.2 %
4 7th or 8th grade 22 1.0 %
5 9th grade 19 0.8 %
6 10th grade 35 1.5 %
7 11th grade 53 2.3 %
8 12th grade NO DIPLOMA 79 3.4 %
9 HIGH SCHOOL GRADUATE - high school DIPLOMA or the equivalent (GED) 700 30.5 %
10 Some college, no degree 490 21.4 %
11 Associate degree 92 8.4 %
12 Bachelors degree 414 18.0 %
13 Masters degree 215 9.4 %
14 Professional or Doctorate degree 64 2.8 %
Total 2,294 100%
Based upon 2,294 valid cases out of 2,294 total cases.
• Minimum: 1.00
• Maximum: 14.00
Location: 1200-1201 (width: 2; decimal: 0)
Variable Type: numeric
(Range of) Missing Values: -2 , -1
 
Step 4 - Topic of Interest (Secondary)
I also wish to get better insight into any association between social class and political orientation after hearing reports that core supporters of President Donald Trump are not necessarily poor/working class as initially characterized by the media. This will help me understand if social class is a better indicator than educational attainment for political orientation.
Step 5 – Codebook (Secondary Topic)
W1_C2: We hear a lot of talk these days about liberals and conservatives. Where would you place YOURSELF on this 7 point scale?
Value Label Unweighted
Frequency %
1 Extremely liberal 75 3.3 %
2 Liberal 312 13.6 %
3 Slightly liberal 286 12.5%
4 Moderate; middle of the road 874 38.1 %
5 Slightly conservative 297 12.9 %
6 Conservative 311 13.6 %
7 Extremely conservative 79 3.4 %
Missing Data
-1 Refused 60 2.6 %
Total 2,294 100%
Based upon 2,234 valid cases out of 2,294 total cases.
• Minimum: 1.00
• Maximum: 7.00
W1_P2: People talk about social classes such as the poor, the working class, the middle class, the upper-middle class, and the upper class. Which of these classes would you say you
belong to?
Value Label Unweighted
Frequency %
 
1 Poor 258 11.2 %
2 Working class 755 32.9 %
3 Middle class 955 41.6 %
4 Upper-middle class 214 9.3 %
5 Upper class 25 1.1 %
Missing Data
-1 Refused 87 3.8 %
Total 2,294 100%
Based upon 2,207 valid cases out of 2,294 total cases.
• Minimum: 1.00
• Maximum: 5.00
Location: 798-799 (width: 2; decimal: 0)
Variable Type: numeric
(Range of) Missing Values: -1
 
Step 6 – Literature Review
The literature review for my topics has been performed using Google Scholar (http://scholar.google.com)
 
For my primary topic (association between educational attainment and political orientation), I searched using the following terms:
 
 Political orientation and educational level
 Political orientation and educational attainment
 Education predicts political orientation
 Populism and educational attainment
For my secondary topic (association between social class and political orientation), I searched with the following terms:
 social class and political orientation
 social class and political party
Without access to subscriptions for the journals cited, I was limited in my ability to evaluate most potential matches. In a few cases, an abstract was provided that sometimes indicated whether the work consideration associations between educational achievement and political orientation or party affiliation. In the case of studies related to social class and political orientation, there was very little presented in terms of recent literature and the summaries I read suggested the political, economic and social contexts in which these studies were performed bore little resemblance to the current environment and would be of limited relevance.
Elchardus, Mark & Spruyt, Bram (2016). Populism, Persistent Republicanism and Declinism: An Empirical Analysis of Populism as a Thin Ideology. Government and Opposition, 51, 111–133.
Lopreato, Joseph (1967). Upward Social Mobility and Political Orientation. American Sociological Review, 35, 586-592.
Schoon, Ingrid, Cheng, Helen, Gale, Catharine R., Batty, G. David & Deary, Ian J. (2010). Social status, cognitive ability, and educational attainment as predictors of liberal social attitudes and political trust. Intelligence, 38, 144-150.
STEP 7 – Hypothesis
For my primary topic, I wish to examine the association between educational attainment (as expressed by highest level of educational achievement) and political orientation (degree of alignment with conservative or liberal viewpoints). My hypothesis is
Level of educational attainment is a significant indicator of political orientation
For my secondary topic, I wish to examine the association between social class and political orientation (degree of alignment with conservative or liberal viewpoints). My hypothesis is:
Social is a significant indicator of political orientation
0 notes