I have a dataset where I would like to add or append rows with values listed in dictionary (if these values are missing from original dataset)
Data
ID Date Type Cost
Alpha Q1 2022 ok 1
Alpha Q2 2022 ok 1
Alpha Q3 2022 hi 1
Alpha Q4 2022 hi 2
Desired
ID Date Type Cost
Alpha Q1 2022 ok 1
Alpha Q2 2022 ok 1
Alpha Q3 2022 hi 1
Alpha Q4 2022 hi 2
Gamma Q1 2022 0
Theta Q1 2022 0
Doing
I am using the script below, however, this is not appending, but only maps the value if date matches. Any suggestion is appreciated
#values = {'Alpha': 'Q1 2022', 'Gamma':' Q1 2022', 'Theta': 'Q1 2022'}
df['ID']=out['Date'].map({'Alpha': 'Q1 2022', 'Gamma':' Q1 2022', 'Theta': 'Q1 2022' })
df1 = df1.merge(df, how='left').fillna({'Cost': 0})