CLN/BUG/TST: Fix and test multiple places using undefined names.
Pyflakes revealed that there are a number of places using undefined
names. I've tried to fix them where I can; however, those parts of the
code are also clearly untested (or tested with
`assertRaises(Exception,...)`) so they need some love.

The PyTables code had a bunch of places with undefined `TermValue`, as
did stats/misc.

Finally, I've also noted (or removed) various places where variables
were assigned but then not used.

cc @jreback

@jtratner when you have a chance rebase this....and can put it in
 Well, the main goal here was to point out where we don't have test coverage
(and could even be unreachable code, depending on how long the code has
been around). Going to see which areas are fixed after rebasing and which
still need to be fixed.
 @jtratner looks ok to put in...?
 I don't expect this PR to be merged, goal was to find places where there's untested code (so eventually everything here should be addressed separately). I recall waiting to hear back on the date start/stop stuff, I'll take another look and see. You covered the pytables elements already, which is good.
 Actually can you check that all the pytables code referenced with comments, (i.e., the TODOs or not used parts) are either removed or now have tests in master?  Last I checked, the issues with `data` and `self.data` being wrong still weren't fixed. And we really need to add tests that hit those branches (and then fail because of the NameErrors)
 @jtratner so....let's just move to 0.14...(or you can create an issue to remind to do this kind of analysis )
 If they're legacy code, then I guess we can just fix the NameErrors (didn't
realize that was what was going on) and move on. That said, unless we
introduced those changes since v0.12, no one is using those branches.
On Oct 11, 2013 8:28 AM, "jreback" notifications@github.com wrote:

> @jtratner https://github.com/jtratner so....let's just move to
> 0.14...(or you can create an issue to remind to do this kind of analysis )
> 
> —
> Reply to this email directly or view it on GitHubhttps://github.com/pydata/pandas/pull/5045#issuecomment-26133245
> .
 yep....it was actually pretty tricky to come up with a case where the original code failed...you actually have to reset the timezone in python to do it. Bottom line is that these guys are using `datetime.date` which is pretty much unsupported, so wasn't a big deal.
 Okay, sounds good. A couple more things that need fixing and I'll take a
look and ping the appropriate people :)

Maybe leave a note on the tests that they're testing deprecated  behavior
and can be removed after some version you specify?
 well..its not really deprecated per se, just generated differently in current version that prior version (in theory I should actually bump the version number of the generated HDFStore files, but since it can be handled both ways its not necessary)
 @jtratner anything left on this?
 @jtratner ?
 @jtratner ?
 at this point, I'm assuming this can be closed.
 ok...
