Q036 - In quali delle seguenti comunitá online sei coinvolto?


In [13]:
# -*- 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

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 [14]:
# Load csv file first
data = pd.read_csv("data/results-makers-40.csv", encoding="utf-8")

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

In [16]:
# Range: Q036[SQ001] - Q036[SQ012] - Q036[other]

communities_columns = ['Q036[SQ001]','Q036[SQ002]','Q036[SQ003]','Q036[SQ004]','Q036[SQ005]',
                    'Q036[SQ006]','Q036[SQ007]','Q036[SQ008]','Q036[SQ009]','Q036[SQ010]','Q036[SQ011]',
                    'Q036[SQ012]','Q036[SQ013]']
communities_options = ['Fabber in Italia (Facebook)',
                    'Associazione Make in Italy (Facebook/sito)',
                    'Fondazione Make in Italy CDB',
                    'Fablabs.io',
                    'Make Magazine',
                    '3D Hubs',
                    'Instructables',
                    'Thingiverse',
                    'International FabLab Association',
                    'wiki.fablab.is',
                    'Open Manufacturing mailing list',
                    'Open Source Hardware Association',
                    'Open Design Working Group @ Open Knowledge Foundation'
                    ]
communities = data[communities_columns]
communities.replace(u'Sì', 'Si', inplace=True) # Get rid of accented characters 
communities_other = data['Q036[other]'].str.lower().value_counts()

In [17]:
#communities[0:4]

Combinations...


In [18]:
# Create all the possible combinations from the main options
# See http://stackoverflow.com/questions/17176887/python-get-all-permutation-of-a-list-w-o-repetitions

import itertools 

all_combinations = {}
all_combinations_columns = []

for i in range(1, len(communities_columns)+1):
    comb = list(itertools.combinations(communities_columns, i))
    for k in comb:
        # Each combination
        all_combinations[k] = {}
        all_combinations[k]["col_list"] = list(k)
        # Build the string and boolean list of each combination
        comb_list = []
        comb_bool_list = []
        # Put default False value
        for l in communities_columns:
            comb_bool_list.append(False)
        for j in k:
            pos = communities_columns.index(j) # Get position
            comb_list.append(communities_options[pos])
            comb_bool_list[pos] = True
        all_combinations[k]["list"] = comb_list
        all_combinations[k]["bool_list"] = comb_bool_list
        all_combinations[k]["str"] = ", ".join(comb_list)

In [19]:
# Check which combinations correspond each row
str_values = []
for i in communities.index:
    current_bool_list = list(communities.ix[i].isin(["Si"]))
    for i in all_combinations:
        if current_bool_list == all_combinations[i]["bool_list"]:
            str_values.append(all_combinations[i]["str"])

In [20]:
# Add combination column
communities["Combination"] = pd.Series(str_values)

In [21]:
# Gather data
resulting_combinations = communities["Combination"].value_counts(dropna=False)
resulting_combinations_percentage = communities["Combination"].value_counts(normalize=True,dropna=False)*100

In [22]:
# Plotting the first 10 values of the most popular combinations
resulting_combinations[0:10].plot(kind='bar',figsize=(20,10),rot=90)
plt.title(u"In quali delle seguenti comunitá online sei coinvolto? Combinazioni", fontsize=18, y=1.02)
plt.ylabel("Persone", fontsize=16)
plt.xlabel("Combinazioni", fontsize=16)
plt.savefig("svg/Q036-Combinazioni.svg")
plt.savefig("png/Q036-Combinazioni.png")
plt.savefig("pdf/Q036-Combinazioni.pdf")



In [23]:
%%capture output

# Save the output as a variable that can be saved to a file
# Data of the combinations
print "Data:"
print resulting_combinations
print
# Data of the combinations: percentage
print "Data %:"
print resulting_combinations_percentage

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


The following commands were written to file `Q036-Combinazioni.py`:
Data:
NaN                                                             58
Fabber in Italia (Facebook)                                      6
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito)     5
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine     4
Fabber in Italia (Facebook), Make Magazine, Instructables        3
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, 3D Hubs, Instructables, International FabLab Association, Open Design Working Group @ Open Knowledge Foundation     3
Fabber in Italia (Facebook), Fondazione Make in Italy CDB        2
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, 3D Hubs, Instructables     2
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), 3D Hubs, Instructables     2
3D Hubs, Instructables                                           2
Associazione Make in Italy (Facebook/sito), Make Magazine        2
Instructables                                                    2
Fabber in Italia (Facebook), Make Magazine, 3D Hubs, Instructables     2
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Open Source Hardware Association     1
Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, Thingiverse     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Associazione Make in Italy (Facebook/sito), Make Magazine, 3D Hubs     1
Associazione Make in Italy (Facebook/sito), Make Magazine, Instructables, International FabLab Association     1
Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Instructables, Thingiverse     1
Fabber in Italia (Facebook), Fondazione Make in Italy CDB, International FabLab Association     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, Thingiverse, International FabLab Association     1
Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Open Manufacturing mailing list, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), 3D Hubs, wiki.fablab.is     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, International FabLab Association, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, International FabLab Association, wiki.fablab.is, Open Manufacturing mailing list, Open Source Hardware Association, Open Design Working Group @ Open Knowledge Foundation     1
3D Hubs                                                          1
Fabber in Italia (Facebook), Open Manufacturing mailing list     1
Instructables, Open Source Hardware Association                  1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, Thingiverse     1
Fabber in Italia (Facebook), Fablabs.io, wiki.fablab.is, Open Source Hardware Association     1
3D Hubs, Instructables, Open Manufacturing mailing list          1
Make Magazine, Instructables                                     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Open Manufacturing mailing list     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, 3D Hubs, Instructables, Thingiverse, International FabLab Association, wiki.fablab.is     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, Thingiverse, International FabLab Association, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io, 3D Hubs, Instructables     1
Associazione Make in Italy (Facebook/sito), Fablabs.io, Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, Instructables, Thingiverse, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io, 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Fabber in Italia (Facebook), Fondazione Make in Italy CDB, Fablabs.io, 3D Hubs, Instructables     1
Fabber in Italia (Facebook), Fondazione Make in Italy CDB, Make Magazine, Instructables, Thingiverse, International FabLab Association     1
3D Hubs, Instructables, Thingiverse                              1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     1
Fablabs.io, 3D Hubs, Instructables                               1
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io, Make Magazine, 3D Hubs, Instructables     1
Thingiverse                                                      1
Make Magazine                                                    1
Length: 54, dtype: int64

Data %:
NaN                                                             43.283582
Fabber in Italia (Facebook)                                      4.477612
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito)     3.731343
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine     2.985075
Fabber in Italia (Facebook), Make Magazine, Instructables        2.238806
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, 3D Hubs, Instructables, International FabLab Association, Open Design Working Group @ Open Knowledge Foundation     2.238806
Fabber in Italia (Facebook), Fondazione Make in Italy CDB        1.492537
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, 3D Hubs, Instructables     1.492537
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), 3D Hubs, Instructables     1.492537
3D Hubs, Instructables                                           1.492537
Associazione Make in Italy (Facebook/sito), Make Magazine        1.492537
Instructables                                                    1.492537
Fabber in Italia (Facebook), Make Magazine, 3D Hubs, Instructables     1.492537
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Open Source Hardware Association     0.746269
Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, Thingiverse     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Associazione Make in Italy (Facebook/sito), Make Magazine, 3D Hubs     0.746269
Associazione Make in Italy (Facebook/sito), Make Magazine, Instructables, International FabLab Association     0.746269
Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Instructables, Thingiverse     0.746269
Fabber in Italia (Facebook), Fondazione Make in Italy CDB, International FabLab Association     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, Thingiverse, International FabLab Association     0.746269
Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Open Manufacturing mailing list, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), 3D Hubs, wiki.fablab.is     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, International FabLab Association, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, International FabLab Association, wiki.fablab.is, Open Manufacturing mailing list, Open Source Hardware Association, Open Design Working Group @ Open Knowledge Foundation     0.746269
3D Hubs                                                          0.746269
Fabber in Italia (Facebook), Open Manufacturing mailing list     0.746269
Instructables, Open Source Hardware Association                  0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Make Magazine, Thingiverse     0.746269
Fabber in Italia (Facebook), Fablabs.io, wiki.fablab.is, Open Source Hardware Association     0.746269
3D Hubs, Instructables, Open Manufacturing mailing list          0.746269
Make Magazine, Instructables                                     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Open Manufacturing mailing list     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, 3D Hubs, Instructables, Thingiverse, International FabLab Association, wiki.fablab.is     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, 3D Hubs, Instructables, Thingiverse, International FabLab Association, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io, 3D Hubs, Instructables     0.746269
Associazione Make in Italy (Facebook/sito), Fablabs.io, Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Make Magazine, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fondazione Make in Italy CDB, Fablabs.io, Make Magazine, Instructables, Thingiverse, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io, 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fabber in Italia (Facebook), Fondazione Make in Italy CDB, Fablabs.io, 3D Hubs, Instructables     0.746269
Fabber in Italia (Facebook), Fondazione Make in Italy CDB, Make Magazine, Instructables, Thingiverse, International FabLab Association     0.746269
3D Hubs, Instructables, Thingiverse                              0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), 3D Hubs, Instructables, Open Design Working Group @ Open Knowledge Foundation     0.746269
Fablabs.io, 3D Hubs, Instructables                               0.746269
Fabber in Italia (Facebook), Associazione Make in Italy (Facebook/sito), Fablabs.io, Make Magazine, 3D Hubs, Instructables     0.746269
Thingiverse                                                      0.746269
Make Magazine                                                    0.746269
Length: 54, dtype: float64