I have the following data set. I try to keep only the entries from a certain date range that I give. The probelm we have is that when the start and end date aren't in the dates of my date set, I take a key err exception.
Duration Film Deadline
1777 a 02/04/2018
1777 b 02/04/2018
1777 b 02/04/2018
942 b 03/04/2018
941 c 03/04/2018
start_date = sys.argv[1]
end_date = sys.argv[2]
df_filtered = df_filtered.set_index([5])
df_filtered = df_filtered.dropna(axis=0, how='all')
df_range = df_filtered[start_date:end_date]
df_groupby = df_range.groupby([4])[3].sum()
film = df_groupby.index.values.tolist()
footage = df_groupby.values.astype(int).tolist()
The code is the above. Any ideas?