BUG #10228: segfault due to out-of-bounds in binning
Closes #10228.   I also deleted some duplicated code while I was at it.

So, I wasn't sure if I should be including a unit test for this.  This issue was a segfault, which was happening when you do:

```
s = pd.Series([], index=pd.DatetimeIndex([]), dtype=np.object)
s.resample('d', how='count')
```

so I suppose I could add this code into a test, and just verify it doesn't segfault, but that seemed like a bad idea.  It would be testing for something that's undefined behavior and therefore be a non-deterministic test.

of course you need a test, otherwise how can you tell if your fix works? The test can be as simple as asserting that it runs.
 @jreback, sure I'll write a test.  I have a piece of code that reliably segfaults for me:

```
ss = pd.Series([], index=pd.DatetimeIndex([]), dtype=np.object)
ss.resample('d', how='count')
```

That being said, this doesn't mean it'll reliably segfault for other machines since out-of-bounds access are undefined behavior.  One way would be to re-enable the bounds-checking on these Cython functions just for the unit tests.  (I actually posed [this question](http://programmers.stackexchange.com/a/286726/134794) on Programmers Stack Exchange and they seemed surprised that the disabling of bounds-checking was hard-coded rather than something that can be switched on and off)
 @Garrett-R then that is a reasonable test. Even if it doesn't segfault on some platforms that is ok. Note that you _can_ change the directive at run-time, see [here](http://docs.cython.org/src/reference/compilation.html#how-to-set-directives), e.g. you would have a flag that is passed in to re-enable this. But to be honest it is overkill, and not necessary to tests with that. Since you have an example that fails, that can serve as a smoke tests (e.g. the test is simply running that code, if it doesn't segfault then the test passes). 
 @Garrett-R No objection to a separate PR for adding a warning to `generated.pyx` (and more importantly prob a note in `internals.rst` about how/what to change. thanks!
 @jreback, good call about adding more comprehensive testing.  This helped me find some more out-of-bounds bugs (which were in `algos.pyx`).

I'll send a PR soon to supply a "DO NOT EDIT THIS GENERATED FILE...." warning for other fellow noobs.
 merged via https://github.com/pydata/pandas/commit/25fc49d975d74c5cb969089dcb3efeda15c3262f

thanks!

nice fix.

btw if you'd like to update the docs w.r.t. the `generate_code.pyx` would be gr8. pls put in `internals.rst`
