In pandas/jupyter notebook with python:
I have a dataframe (df1) with information about the amount of crime per year where each row is a summation of the total amount of crime in that country-year unit. However, df1 does not have rows which contain "0 crime" for the years with 0 crime, and I want to add them.
I thought the easiest way to do this would be to create a blank df, (df2), with the same columns, but with all the country-years in them. Then I could add df1 data through join/merge, and change all the NaN values to 0 in df2 for years with no crime.
df1 looks like this (in excel):
So basically I want to put df1 into the format of df2 so that I have data with all the years with 0 crime as well. I'm new to coding and not really sure how to approach this because I'm not understanding the documentation for .join and .merge. There are 18 countries and years are 2000-2020. Let me know if you have any thoughts!