dailylog 9-03-20

1 minute read

Today I made 461 graphs in less than an hour!!

import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt


# VISUALIZATION VARIABLES
from matplotlib.font_manager import FontProperties
font = {'family': 'san-serif','size': 14, 'weight': 'normal'}
labelfont = {'family': 'san-serif', 'size': 18}
labelfont_2 = {'family': 'serif', 'size': 12}
titlefont = {'family': 'serif', 'size': 30}


df = pd.read_csv('VG_TIME_RAW.csv')
dfg = df.groupby(['GL PERIOD','EMPLOYEE_VENDOR_NAME', 'PROJECT_NAME'])['QUANTITY'].sum()
dfg = pd.DataFrame(df.groupby(['GL PERIOD','EMPLOYEE_VENDOR_NAME', 'PROJECT_NAME'])['QUANTITY'].sum())
dfg.reset_index(inplace=True)

df3 = pd.read_csv('VG_JUNE_JULY_AUGUST_sm.csv')

def sort_other(percent, project_name):
    if percent >1.1:
        return project_name
    else:
        return "Other"
df3['PROJECT_NAME_OTHER'] = df3.apply(lambda x: sort_other(x['percent'], x['PROJECT_NAME']),axis=1)
df3

projects = set(df3['PROJECT_NAME_OTHER'])
brewer = '"#A6CEE3" "#1F78B4" "#B2DF8A" "#33A02C" "#FB9A99" "#E31A1C" "#FDBF6F" "#FF7F00" "#CAB2D6" "#6A3D9A" "#FFFF99" "#B15928"'.replace('"', '').split(' ')

color_dict = dict(zip(projects, brewer))
color_dict

df = pd.read_csv('VG_TIME_RAW.csv')
dfg = df.groupby(['GL PERIOD','EMPLOYEE_VENDOR_NAME', 'PROJECT_NAME'])['QUANTITY'].sum()
dfg = pd.DataFrame(df.groupby(['GL PERIOD','EMPLOYEE_VENDOR_NAME', 'PROJECT_NAME'])['QUANTITY'].sum())
dfg.reset_index(inplace=True)

def sort_other_2(project):
    if project not in projects:
        return 'Other'
    else:
        return project

dfg['PROJECT_NAME_OTHER'] = dfg.apply(lambda x: sort_other_2(x['PROJECT_NAME']),axis=1)


# employees = set(dfg['EMPLOYEE_VENDOR_NAME'])
# employees_sorted = list(employees)
# employees_sorted.sort()

# palette = color_dict

# for name in employees_sorted:
#     try:
#         plt.figure(figsize=(10, 6))
#         dfg_sm = dfg[dfg['EMPLOYEE_VENDOR_NAME'] == name]
#         chart = sns.barplot(x="GL PERIOD", hue="PROJECT_NAME_OTHER", y="QUANTITY", data=dfg_sm, order=['JUN-20','JUL-20','AUG-20'], palette=palette)
#         plt.legend(loc='upper right', bbox_to_anchor=(1.5, 1), fontsize=16)
#         plt.title(name)
#         chart.spines['right'].set_visible(False)
#         chart.spines['top'].set_visible(False)
#         plt.title(name, fontdict=titlefont, y=1.1)
#         plt.xlabel('Month',fontdict=labelfont, labelpad=20)
#         plt.ylabel('Hours Worked', fontdict=labelfont, labelpad=20)
#         plt.show()
#     except:
#         print(name)

Tags:

Updated: