I want the code to check if the dataframe has all elements of period_list. If not I want to add that element to the dataframe, the values associated with the element will be zero. I wrote this and it didn't work Dataframe: test_1
Period A B C
0 2018 - Q2 1 0 1
1 2018 - Q3 1 1 1
2 2018 - Q4 0 1 1
3 2019 - Q1 0 0 0
4 2019 - Q2 0 0 1
5 2019 - Q3 1 0 1
6 2019 - Q4 0 1 1
7 2020 - Q1 1 0 1
8 2020 - Q2 0 0 0
my code
period_list = ['2018 - Q1', '2018 - Q2', '2018 - Q3', '2018 - Q4', '2019 - Q1', '2019 - Q2', '2019 - Q3', '2019 - Q4', '2020 - Q1', '2020 - Q2', '2020 - Q3', '2020 - Q4', '2021 - Q1']
for row in period_list:
if row not in test_1.iloc[:, 0]:
test_1.append(row)