I have the following dataset
Date              Type        Label
2020-03-20         A            1
2020-03-20         A            0
2020-03-19         B            1
2020-03-17         A            1
2020-03-15         C            0
2020-03-19         A            0
2020-03-20         D            1
2020-03-20         A            1
that I would like to plot with normalised values in a multiple lines plot. The code below plots the different lines through time
import matplotlib.pyplot as plt
fig, ax = plt.subplots(1, figsize=[10,6])
(df.loc[df.Label.eq(1),].groupby(["Date","Type"]).agg({"Type":"count"})
 .unstack(1).droplevel(0,axis=1)
 .fillna(method="ffill")
 .plot(ax=ax, kind="line")
)
but when I try to apply normalisation
column_norm=['Type']
df[column_norm] = df[column_norm].apply(lambda x: (x - x.min()) / (x.max() - x.min()))
it fails, returning an error:
TypeError: unsupported operand type(s) for -: 'str' and 'str'
when I calculate min and max.
Can you please tell me how to get a plot with y axis normalised to 1?
 
    




