title: Filling in missing data Python
body: <p>I have a lot of missing data in between years and months of my dataframe that looks like:</p>
  
  <pre><code>    Year    Month   State        Value  
      1969    12        NJ         5500    
      1969    12        NY         6418     
      1970    8         IL         10093  
      1970    12        WI         6430      
      1970    7         NY         6140           
      1971    10        IL         10093          
      1971    6         MN         6850            
      1971    3         SC         7686          
      1972    12        FL         8772     
      2016    1         NJ         9000
  </code></pre>
  
  <p>For each state I need to fill out all the missing data from the beginning of the year the values began until 2018 but the only data that exists is mostly in between 1969 and 1990 so I just need to fill in the blanks.</p>
  
  <p>The desired output (for NJ but needed for all states) would be:</p>
  
  <pre><code>Year    Month   State        Value  
  1969    12        NJ         5500
  1970    1         NJ         5500
  1970    2         NJ         5500
  1970    3         NJ         5500
  1970    4         NJ         5500
  1970    5         NJ         5500
  1970    6         NJ         5500
  .
  .
  1970    12        NJ         5500
  .
  .
  2010    1         NJ         5500
  2010    2         NJ         5500
  2010    3         NJ         5500
  .
  .
  2018    1         NJ         9000
  </code></pre>
  
  <p>I've tried turning the months into categorical values that range from 1-12 months, regroup and reset the index, and then use ffill to partition through the values into those newly made column indices like:</p>
  
  <pre><code>df['Month'] = pd.Categorical(df['Month'], categories=range(1, 13))
  df = df.groupby(['State', 'Year', 'Month']).first().reset_index()
  df['Value'] = df.groupby('Region')['Value'].ffill()
  </code></pre>
  
  <p>But this method gives me NaN values like:</p>
  
  <pre><code>State   Year    Month   Value
  NJ      1969    12      5500.0
  NJ      1970    1       nan
  NJ      1970    2       nan
  NJ      1970    3       nan
  .
  .
  NJ      2016    1       9000.0
  </code></pre>
  
  <p>I can't understand why this method has worked before as I've tested it on other data with actual results.</p>