Repository: pandas-dev/pandas

Issue:
Up-sampling and filling while also passing the "how" parameter
I'm up-sampling quarterly data to monthly periods and using a fill method which is working fine, but then when I pass in an argument for "how", it seems to disable the filling feature.

My understanding was that "how" doesn't mean anything in the context of up-sampling, in which case I would expect passing the parameter to have no effect on the output.

Is this a bug or am I missing something about how this is supposed to work?

See below (pandas 0.8.1):

```
In [18]: s = pandas.Series(range(9), index=pandas.date_range('2010-01-01', periods=9, freq='Q'))

In [19]: s
Out[19]: 
2010-03-31    0
2010-06-30    1
2010-09-30    2
2010-12-31    3
2011-03-31    4
2011-06-30    5
2011-09-30    6
2011-12-31    7
2012-03-31    8
Freq: Q-DEC

In [20]: s.resample('M', fill_method='ffill')
Out[20]: 
2010-03-31    0
2010-04-30    0
2010-05-31    0
2010-06-30    1
2010-07-31    1
2010-08-31    1
2010-09-30    2
2010-10-31    2
2010-11-30    2
2010-12-31    3
2011-01-31    3
2011-02-28    3
2011-03-31    4
2011-04-30    4
2011-05-31    4
2011-06-30    5
2011-07-31    5
2011-08-31    5
2011-09-30    6
2011-10-31    6
2011-11-30    6
2011-12-31    7
2012-01-31    7
2012-02-29    7
2012-03-31    8
Freq: M

In [21]: s.resample('M', fill_method='ffill', how='last')
Out[21]: 
2010-03-31     0
2010-04-30   NaN
2010-05-31   NaN
2010-06-30     1
2010-07-31   NaN
2010-08-31   NaN
2010-09-30     2
2010-10-31   NaN
2010-11-30   NaN
2010-12-31     3
2011-01-31   NaN
2011-02-28   NaN
2011-03-31     4
2011-04-30   NaN
2011-05-31   NaN
2011-06-30     5
2011-07-31   NaN
2011-08-31   NaN
2011-09-30     6
2011-10-31   NaN
2011-11-30   NaN
2011-12-31     7
2012-01-31   NaN
2012-02-29   NaN
2012-03-31     8
Freq: M
```



Discussion:

Resolving patch:
diff --git a/pandas/tseries/resample.py b/pandas/tseries/resample.py
--- a/pandas/tseries/resample.py
+++ b/pandas/tseries/resample.py
@@ -252,6 +252,11 @@ def _resample_timestamps(self):
                 # downsample
                 grouped = obj.groupby(grouper, axis=self.axis)
                 result = grouped.aggregate(self._agg_method)
+                # GH2073
+                if self.fill_method is not None:
+                    result = result.fillna(method=self.fill_method,
+                                           limit=self.limit)
+
             else:
                 # upsampling shortcut
                 if self.axis:


Test patch:
diff --git a/pandas/tseries/tests/test_resample.py b/pandas/tseries/tests/test_resample.py
--- a/pandas/tseries/tests/test_resample.py
+++ b/pandas/tseries/tests/test_resample.py
@@ -869,6 +869,14 @@ def test_monthly_upsample(self):
             expected = expected.asfreq(targ, 'ffill').to_period()
             assert_series_equal(result, expected)
 
+    def test_fill_method_and_how_upsample(self):
+        # GH2073
+        s = Series(range(9),
+                   index=date_range('2010-01-01', periods=9, freq='Q'))
+        last = s.resample('M', fill_method='ffill')
+        both = s.resample('M', how='last', fill_method='ffill').astype('int64')
+        assert_series_equal(last, both)
+
     def test_weekly_upsample(self):
         targets = ['D', 'B']