Repository: pandas-dev/pandas

Issue:
Resampler.__iter__() not working
#### Code Sample, a copy-pastable example if possible

```python
for i, k in df.resample('W-MON'):
    print(i, k)
```
```sh
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-60-5ca9218261db> in <module>()
----> 1 for i, k in df.resample('W-MON'):
      2     print(i, k)
      3     break

/xxx/lib/python3.5/site-packages/pandas/core/groupby.py in __iter__(self)
    629         for each group
    630         """
--> 631         return self.grouper.get_iterator(self.obj, axis=self.axis)
    632
    633     @Substitution(name='groupby')

AttributeError: 'NoneType' object has no attribute 'get_iterator'
```
#### Problem description
can't iterate the resampler's key and grouped dataframe

#### Expected Output
iterate the resampler's key and the grouped dataframe, now workaround
```python
for key in df.resample('W-MON').groups.keys():
  try:
    print(key, df.resample('W-MON').get_group(key))
  except KeyError:
    continue
```

#### Output of ``pd.show_versions()``

<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Darwin
OS-release: 15.6.0
machine: x86_64
processor: i386
byteorder: little
LC_ALL: en_GB.UTF-8
LANG: en_GB.UTF-8
LOCALE: en_GB.UTF-8

pandas: 0.19.2
nose: None
pip: 9.0.1
setuptools: 30.2.0
Cython: 0.25.2
numpy: 1.12.0
scipy: 0.18.1
statsmodels: None
xarray: None
IPython: 5.1.0
sphinx: 1.5.1
patsy: 0.4.1
dateutil: 2.6.0
pytz: 2016.10
blosc: None
bottleneck: None
tables: None
numexpr: None
matplotlib: 1.5.3
openpyxl: 2.4.1
xlrd: None
xlwt: None
xlsxwriter: None
lxml: None
bs4: None
html5lib: 0.9999999
httplib2: None
apiclient: None
sqlalchemy: None
pymysql: None
psycopg2: 2.6.2 (dt dec pq3 ext lo64)
jinja2: 2.8
boto: None
pandas_datareader: None
</details>

----
update the workaround a bit


Discussion:
this was never implemented; I suppose it could for compat. If you'd like to put up a PR would be fine. Needs tests, and the impl described above will not work very well, need to do it similar to how groupby works.
good, will have a try this weekend if I can figure it out

also [the doc](http://pandas.pydata.org/pandas-docs/stable/generated/pandas.tseries.resample.Resampler.__iter__.html#pandas.tseries.resample.Resampler.__iter__) shall be updated, it's pointed to the groupby iter

Resolving patch:
diff --git a/pandas/core/resample.py b/pandas/core/resample.py
--- a/pandas/core/resample.py
+++ b/pandas/core/resample.py
@@ -97,6 +97,23 @@ def __getattr__(self, attr):
 
         return object.__getattribute__(self, attr)
 
+    def __iter__(self):
+        """
+        Resampler iterator
+
+        Returns
+        -------
+        Generator yielding sequence of (name, subsetted object)
+        for each group
+
+        See Also
+        --------
+        GroupBy.__iter__
+
+        """
+        self._set_binner()
+        return super(Resampler, self).__iter__()
+
     @property
     def obj(self):
         return self.groupby.obj


Test patch:
diff --git a/pandas/tests/test_resample.py b/pandas/tests/test_resample.py
--- a/pandas/tests/test_resample.py
+++ b/pandas/tests/test_resample.py
@@ -771,6 +771,17 @@ def test_apply_to_empty_series(self):
 
             assert_series_equal(result, expected, check_dtype=False)
 
+    def test_resampler_is_iterable(self):
+        # GH 15314
+        series = self.create_series()
+        freq = 'H'
+        tg = TimeGrouper(freq, convention='start')
+        grouped = series.groupby(tg)
+        resampled = series.resample(freq)
+        for (rk, rv), (gk, gv) in zip(resampled, grouped):
+            assert rk == gk
+            assert_series_equal(rv, gv)
+
 
 class TestDatetimeIndex(Base):
     _index_factory = lambda x: date_range