Created
February 21, 2021 00:33
-
-
Save seisvelas/ac3558d98a79022c62eec355482c8c5e to your computer and use it in GitHub Desktop.
Create pie chart from Clockify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import matplotlib.pyplot as plt | |
import seaborn as sns | |
import pandas as pd | |
from sys import argv | |
sns.set() | |
def load_tasks(dataframe): | |
del dataframe['Project'] | |
del dataframe['Client'] | |
del dataframe['Time (h)'] | |
del dataframe['Amount (USD)'] | |
return dataframe | |
[week_1_data, week_2_data] = [ | |
load_tasks(pd.read_csv(csv)) for csv in argv[1:] | |
] | |
for i, week in enumerate([week_1_data, week_2_data]): | |
data = week.groupby("Description")["Time (decimal)"].sum() | |
#Using matplotlib | |
pie, ax = plt.subplots(figsize=[10,6]) | |
labels = data.keys() | |
plt.pie(x=data, autopct="%.1f%%", explode=[0.05]*len(data), labels=labels, rotatelabels=True) | |
plt.title("Labor Allocation", fontsize=14); | |
pie.savefig(f"week_{i}_pie.png") | |
print(week_1_data.head()) | |
print(week_2_data.head()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment