Q035 - Partecipi a una o piú comunitá online dedicate al making?


In [1]:
# -*- 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 [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]:
%%capture output

# Save the output as a variable that can be saved to a file
# Get the distribution of contract type
contract = data["Q035"].value_counts(dropna=False)
print "Data:"
print contract
print ""
print "Data %:"
print data["Q035"].value_counts(normalize=True,dropna=False) * 100

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


The following commands were written to file `Q035-PartecipiOnline.py`:
Data:
Si, sono membro           56
No                        46
Si, ma non sono membro    32
NaN                        0
dtype: int64

Data %:
Si, sono membro           41.791045
No                        34.328358
Si, ma non sono membro    23.880597
NaN                        0.000000
dtype: float64


In [6]:
# Plot the data
plt.figure(figsize=(8,6))
plt.xlabel(u'Partecipazione', fontsize=16)
plt.ylabel('Persone', fontsize=16)
plt.title(u"Partecipi a una o piú comunitá online dedicate al making?", fontsize=18, y=1.02)
my_colors = seaborn.color_palette("husl", len(contract)) # Set color palette
contract.plot(kind="bar",color=my_colors)
plt.savefig("svg/Q035-PartecipiOnline.svg")
plt.savefig("png/Q035-PartecipiOnline.png")
plt.savefig("pdf/Q035-PartecipiOnline.pdf")



In [6]: