Skip to content

Instantly share code, notes, and snippets.

View sebastianmurillonader's full-sized avatar

sebastianmurillonader

View GitHub Profile
#Group data by one variable.
df_group = df.groupby('Proceso').agg(
UX = ('UX', sum),
Impacto = ('Impacto', sum),
Uso = ('Uso', sum),
Implementación = ('Implementación', sum),
Prioridad = ('Prioridad', sum)
).reset_index()
df_group.head(20)
#Define scope of API.
scope = ['https://spreadsheets.google.com/feeds',
'https://www.googleapis.com/auth/drive']
credentials = ServiceAccountCredentials.from_json_keyfile_name('./insertNameOfYourKeyFile.json', scope) #Get this file by activating the Google Sheets API from your Google account.
gc = gspread.authorize(credentials)
#Define spreadsheet variables.
spreadsheetKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
book = gc.open_by_key(spreadsheetKey)
#Create Pair Grid and assign colors.
g = sns.PairGrid(df_group, hue="Proceso", palette="husl")
g = g.map(plt.scatter, alpha=.5)
g = g.add_legend()
#Only keep columns needed.
df = df[['proceso', 'prioridad#', 'UX#', 'impacto#', 'uso#', 'implementación#']]
#Rename columns for presentation purposes.
df.columns = ['Proceso', 'Prioridad', 'UX', 'Impacto', 'Uso', 'Implementación']
df.head()
#Install modules.
pip install gspread
pip install python-oauth2
pip install --upgrade oauth2client
#Import libraries.
import pandas as pd
import seaborn as sns
import gspread
from oauth2client.service_account import ServiceAccountCredentials