I have the following table (Sorry for the format):
Date Service Reference Document
2018-05-14 A Null 3542523
2018-05-15 B 01 6234242
2018-05-16 A 09 2342146
2018-05-16 C Null 2342342
I have a calculated value [Calculated] that is the
Reference.count/Document.count()
I want to create a graph similar to the next one:
Where in the x-axis I have the date, on the y axis the calculated column but shown with different lines representing the different Services.
So far I have this:
def calculate(df):
return df.Reference.count() / df.Document.count()
df1 = df.groupby(['Date']).apply(calculate)
However if I try to add Services to the groupby I cannot plot it using
sns.lineplot()
Is there another way or an easier way to add the Services dimension to the plot?
Thanks
Once you aggregate your data by date and service using:
Then, reset the index to convert to a dataframe (from a series)
and then plot it: