Q022 - Qual è il livello delle tue competenze tecniche e tecnologiche?


In [12]:
# -*- coding: UTF-8 -*-

# Render our plots inline
%matplotlib inline 

import pandas as pd
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import seaborn
import shutil

import math

pd.set_option('display.mpl_style', 'default') # Make the graphs a bit prettier, overridden by seaborn
pd.set_option('display.max_columns', None) # Display all the columns
plt.rcParams['font.family'] = 'sans-serif' # Sans Serif fonts for all the graphs

# Reference for color palettes: http://web.stanford.edu/~mwaskom/software/seaborn/tutorial/color_palettes.html

# Change the font
matplotlib.rcParams.update({'font.family': 'Source Sans Pro'})

In [2]:
# Load csv file first
data = pd.read_csv("data/results-makers-40.csv", encoding="utf-8")

In [3]:
# Check data
#data[0:4] # Equals to data.head()

In [4]:
# Range: Q021[SQ001] - Q021[SQ005]

skills_columns = ['Q022[SQ001]','Q022[SQ002]','Q022[SQ003]','Q022[SQ004]','Q022[SQ005]']
skills_options = ['Informatica','Elettronica','Progettazione CAD/CAM','Fabbricazione Digitale','Fabbricazione Analogica',]
skills = data[skills_columns]
skills.replace(u'“Guru” (geek)', 'Guru', inplace=True) # Simplify text 
skills.replace(np.nan, 'Nessuna risposta', inplace=True) # Simplify text


-c:6: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame
-c:7: SettingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame

In [5]:
#skills

In [6]:
%%capture output

# Save the output as a variable that can be saved to a file
# Gather data
skills_b = {}
for k,i in enumerate(skills_columns):
    skills_b[k] = skills[i].value_counts()
    print "Data:",skills_options[k]
    print skills_b[k]
    print
    print "Data %:",skills_options[k]
    print skills[i].value_counts(normalize=True)*100
    print

In [7]:
# Save+show the output to a text file
%save Q022-MakerQualiCompetenze.py str(output)
shutil.move("Q022-MakerQualiCompetenze.py", "text/Q022-MakerQualiCompetenze.txt")


The following commands were written to file `Q022-MakerQualiCompetenze.py`:
Data: Informatica
Professionale       40
Amatoriale          38
Elementare          24
Nessuno             14
Nessuna risposta     9
Guru                 9
dtype: int64

Data %: Informatica
Professionale       29.850746
Amatoriale          28.358209
Elementare          17.910448
Nessuno             10.447761
Nessuna risposta     6.716418
Guru                 6.716418
dtype: float64

Data: Elettronica
Elementare          52
Amatoriale          29
Nessuno             25
Nessuna risposta    19
Professionale        8
Guru                 1
dtype: int64

Data %: Elettronica
Elementare          38.805970
Amatoriale          21.641791
Nessuno             18.656716
Nessuna risposta    14.179104
Professionale        5.970149
Guru                 0.746269
dtype: float64

Data: Progettazione CAD/CAM
Professionale       58
Amatoriale          30
Elementare          16
Nessuna risposta    11
Guru                10
Nessuno              9
dtype: int64

Data %: Progettazione CAD/CAM
Professionale       43.283582
Amatoriale          22.388060
Elementare          11.940299
Nessuna risposta     8.208955
Guru                 7.462687
Nessuno              6.716418
dtype: float64

Data: Fabbricazione Digitale
Amatoriale          41
Professionale       33
Nessuno             18
Nessuna risposta    16
Elementare          16
Guru                10
dtype: int64

Data %: Fabbricazione Digitale
Amatoriale          30.597015
Professionale       24.626866
Nessuno             13.432836
Nessuna risposta    11.940299
Elementare          11.940299
Guru                 7.462687
dtype: float64

Data: Fabbricazione Analogica
Amatoriale          52
Professionale       33
Elementare          15
Nessuna risposta    13
Guru                12
Nessuno              9
dtype: int64

Data %: Fabbricazione Analogica
Amatoriale          38.805970
Professionale       24.626866
Elementare          11.194030
Nessuna risposta     9.701493
Guru                 8.955224
Nessuno              6.716418
dtype: float64



In [10]:
nessuno = []
elementare = []
amatoriale = []
professionale = []
guru = []  
nanvalue = []

for k,i in enumerate(skills_columns):
    skills_presents = skills_b[k].index.tolist()
    
    # Reassign new list with "NaN"
    skills_b[k].index = skills_presents
    
    # Check for empty values, and put a 0 instead
    if "Nessuno" not in skills_presents:
        nessuno.append(0)
    if "Elementare" not in skills_presents:
        elementare.append(0)
    if "Amatoriale" not in skills_presents:
        amatoriale.append(0)
    if "Professionale" not in skills_presents:
        professionale.append(0)
    if "Guru" not in skills_presents:
        guru.append(0)
    if "Nessuna risposta" not in skills_presents:
        nanvalue.append(0)
    
    for j in skills_presents:
        if j == "Nessuno":
            nessuno.append(skills_b[k].ix[j])
        elif j == "Elementare":
            elementare.append(skills_b[k].ix[j])
        elif j == "Amatoriale":
            amatoriale.append(skills_b[k].ix[j])
        elif j == "Professionale":
            professionale.append(skills_b[k].ix[j])     
        elif j == "Guru":
            guru.append(skills_b[k].ix[j])
        elif j == "Nessuna risposta":
            nanvalue.append(skills_b[k].ix[j])

In [13]:
# Plot the data
plt.figure(figsize=(16,6))
plt.xlabel('Competenze', fontsize=16)
plt.ylabel('Persone', fontsize=16)
plt.title(u'Qual è il livello delle tue competenze tecniche e tecnologiche?', fontsize=18, y=1.02)
plt.xticks(range(len(skills_options)+1),skills_options,rotation=0)
ind = np.arange(len(skills_columns))   # the x locations for the groups
width = 0.15                              # the width of the bars

my_colors = seaborn.color_palette("Set1", 6) # Set color palette
rect1 = plt.bar(ind,nessuno,width,color=my_colors[0],align='center') # Plot Nessuno
rect2 = plt.bar(ind+width,elementare,width,color=my_colors[1],align='center') # Plot Elementare 
rect3 = plt.bar(ind+width*2,amatoriale,width,color=my_colors[2],align='center') # Plot Amatoriale
rect4 = plt.bar(ind+width*3,professionale,width,color=my_colors[3],align='center') # Plot Professionale
rect5 = plt.bar(ind+width*4,guru,width,color=my_colors[4],align='center') # Plot Guru
rect6 = plt.bar(ind+width*5,nanvalue,width,color=my_colors[5],align='center') # Plot NaN
plt.legend( (rect1, rect2, rect3, rect4, rect5, rect6), ('Nessuno', 'Elementare', 'Amatoriale', 'Professionale', 'Guru', 'NaN') )
plt.savefig("svg/Q022-MakerQualiCompetenze.svg")
plt.savefig("png/Q022-MakerQualiCompetenze.png")
plt.savefig("pdf/Q022-MakerQualiCompetenze.pdf")



In [9]: