Add isort config
- [x] closes #23048
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
 
Confirming that CI fails when Imports are incorrectly formatted. See here:
https://travis-ci.org/pandas-dev/pandas/jobs/440557769

Sample output:

Doctests top-level reshaping functions DONE
Check import format using isort
ERROR: /home/travis/build/pandas-dev/pandas/pandas/core/series.py Imports are incorrectly sorted.
ERROR: /home/travis/build/pandas-dev/pandas/pandas/core/indexes/range.py Imports are incorrectly sorted.
ERROR: /home/travis/build/pandas-dev/pandas/pandas/io/packers.py Imports are incorrectly sorted.
ERROR: /home/travis/build/pandas-dev/pandas/pandas/io/pytables.py Imports are incorrectly sorted.
Check import format using isort DONE
The command "ci/code_checks.sh" exited with 1.

Hello @alimcmaster1! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/indexes/range.py`](https://github.com/alimcmaster1/pandas/blob/f0c257ea7a90775e1aa46b546b4d628c08c5a49b/pandas/core/indexes/range.py) !

 - There are no PEP8 issues in the file [`pandas/core/series.py`](https://github.com/alimcmaster1/pandas/blob/f0c257ea7a90775e1aa46b546b4d628c08c5a49b/pandas/core/series.py) !

 - There are no PEP8 issues in the file [`pandas/io/packers.py`](https://github.com/alimcmaster1/pandas/blob/f0c257ea7a90775e1aa46b546b4d628c08c5a49b/pandas/io/packers.py) !

 - There are no PEP8 issues in the file [`pandas/io/pytables.py`](https://github.com/alimcmaster1/pandas/blob/f0c257ea7a90775e1aa46b546b4d628c08c5a49b/pandas/io/pytables.py) !

 - There are no PEP8 issues in the file [`pandas/tests/arrays/categorical/test_subclass.py`](https://github.com/alimcmaster1/pandas/blob/f0c257ea7a90775e1aa46b546b4d628c08c5a49b/pandas/tests/arrays/categorical/test_subclass.py) !

 - There are no PEP8 issues in the file [`pandas/tests/tslibs/test_liboffsets.py`](https://github.com/alimcmaster1/pandas/blob/f0c257ea7a90775e1aa46b546b4d628c08c5a49b/pandas/tests/tslibs/test_liboffsets.py) !

 - There are no PEP8 issues in the file [`pandas/tseries/api.py`](https://github.com/alimcmaster1/pandas/blob/f0c257ea7a90775e1aa46b546b4d628c08c5a49b/pandas/tseries/api.py) !

 pls rebase. let's lmit this first push to what you have done. don't add more files here. this will need many small PR's to avoid rebase issues generally. Lint failure: https://travis-ci.org/pandas-dev/pandas/jobs/442319848#L2919

> Confirming that CI fails when Imports are incorrectly formatted.

Did CI fail without it? What did the output look like?

I think things were pretty quiet over in #23048, so just to confirm are any maintainers against doing this (@jorisvandenbossche @WillAyd @jschendel @gfyoung @mroeschke, ...)? @TomAugspurger - thanks for taking a look - below is an example CI failing for files with incorrectly formatted imports:

 https://travis-ci.org/pandas-dev/pandas/jobs/440557769#L2830

Sample output:

Doctests top-level reshaping functions DONE
Check import format using isort
ERROR: /home/travis/build/pandas-dev/pandas/pandas/core/series.py Imports are incorrectly sorted.
ERROR: /home/travis/build/pandas-dev/pandas/pandas/core/indexes/range.py Imports are incorrectly sorted.
ERROR: /home/travis/build/pandas-dev/pandas/pandas/io/packers.py Imports are incorrectly sorted.
ERROR: /home/travis/build/pandas-dev/pandas/pandas/io/pytables.py Imports are incorrectly sorted.
Check import format using isort DONE
The command "ci/code_checks.sh" exited with 1. # [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23096?src=pr&el=h1) Report
> Merging [#23096](https://codecov.io/gh/pandas-dev/pandas/pull/23096?src=pr&el=desc) into [master](https://codecov.io/gh/pandas-dev/pandas/commit/e8d29e73e68630620908eaf28589f0882c294e53?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

[![Impacted file tree graph](https://codecov.io/gh/pandas-dev/pandas/pull/23096/graphs/tree.svg?width=650&token=eZ4WkYLtcO&height=150&src=pr)](https://codecov.io/gh/pandas-dev/pandas/pull/23096?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master   #23096      +/-   ##
==========================================
+ Coverage   92.19%   92.19%   +<.01%     
==========================================
  Files         169      169              
  Lines       50956    50957       +1     
==========================================
+ Hits        46977    46978       +1     
  Misses       3979     3979
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.61% <100%> (ø)` | :arrow_up: |
| #single | `42.29% <100%> (+0.01%)` | :arrow_up: |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23096?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/series.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvc2VyaWVzLnB5) | `93.86% <100%> (ø)` | :arrow_up: |
| [pandas/io/packers.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3BhY2tlcnMucHk=) | `88.01% <100%> (-0.04%)` | :arrow_down: |
| [pandas/io/pytables.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL2lvL3B5dGFibGVzLnB5) | `92.44% <100%> (-0.01%)` | :arrow_down: |
| [pandas/tseries/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL3RzZXJpZXMvYXBpLnB5) | `100% <100%> (ø)` | :arrow_up: |
| [pandas/core/indexes/range.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9yYW5nZS5weQ==) | `95.73% <100%> (ø)` | :arrow_up: |
| [pandas/core/reshape/merge.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvcmVzaGFwZS9tZXJnZS5weQ==) | `93.89% <0%> (-0.05%)` | :arrow_down: |
| [pandas/core/indexes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9iYXNlLnB5) | `96.54% <0%> (-0.01%)` | :arrow_down: |
| [pandas/core/indexes/numeric.py](https://codecov.io/gh/pandas-dev/pandas/pull/23096/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvaW5kZXhlcy9udW1lcmljLnB5) | `97.41% <0%> (+0.14%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23096?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23096?src=pr&el=footer). Last update [e8d29e7...3b5f524](https://codecov.io/gh/pandas-dev/pandas/pull/23096?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).
 I am on board in general, but will isort raise an error if imports are inlined in functions and not at the top of the file? I've seen them used here and there in the code base (maybe for a good reason).

Example:

https://github.com/pandas-dev/pandas/blob/913f71f74709e4d4814e50f21768b97ce2c6ef8d/pandas/core/tools/datetimes.py#L98 It only lints imports at the top of a file. I think it even stops linting if you do an import in a try/except.

________________________________
From: Matthew Roeschke <notifications@github.com>
Sent: Tuesday, October 16, 2018 7:03:54 PM
To: pandas-dev/pandas
Cc: Tom Augspurger; Mention
Subject: Re: [pandas-dev/pandas] Add isort config (#23096)


I am on board in general, but will isort raise an error if imports are inlined in functions and not at the top of the file? I've seen them used here and there in the code base (maybe for a good reason).

Example:

https://github.com/pandas-dev/pandas/blob/913f71f74709e4d4814e50f21768b97ce2c6ef8d/pandas/core/tools/datetimes.py#L98

—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<https://github.com/pandas-dev/pandas/pull/23096#issuecomment-430443139>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ABQHIoFArQpmOwHo-9nMV6IV_zUx_1y0ks5ulnPqgaJpZM4XYfbd>.
 this looks fine. can you rebase, and ping on green. @jreback green aside from the windows 3.6 failure. We should probably merge this before any others. FYI, people may want to check out [pre-commit](https://pre-commit.com) for having these checks run on each commit. I haven't tried isort on a repo as large as pandas though. Thanks @TomAugspurger . We could also use [this](https://pypi.org/project/flake8-isort/), so any issues with imports will be highlighted when developers hopefully run `git diff upstream/master -u -- "*.py" | flake8 --diff` before committing. I can rebase this eve if required. ( this branch is 2 commits behind master ) Maybe merge mater to be safe.

Or you could spot check https://github.com/pandas-dev/pandas/pull/23190 and https://github.com/pandas-dev/pandas/pull/23193 to see if they touch files that are now being linted. @alimcmaster1 yeah why don't you merge master on this and ping when passes travis thanks @alimcmaster1  certainly take followups to remove the non-checked files, but do in smaller batches (doesn't have to be tiny), but not > 20 files Thanks @jreback for sorting, apologies for lack of response from myself, unfortunately I cant push to public repo's on my work machine.. 

I will follow up with PRs for small batches of files. Let me know if there is anything I should be doing to document what's going on here :) @alimcmaster1 if that makes sense, you can get the list of files to update, divide it in chunks, and create an issue for each chunk explaining well what needs to be done. This way you don't need to do all them yourself. Thanks @datapythonista - I've started doing a few PRs myself and created an issue so others can hopefully help #23334. @alimcmaster1 something else: would you like to add a small section to the contributing guideline explaining `isort` and its use? So we have something to point to if contributors on a PR get a red CI with "Imports are incorrectly sorted." (which sort order is expected? how to let isort do this automatically for you? ..) Hey @jorisvandenbossche - sure I can do this, was thinking this might be handy! Thanks @jorisvandenbossche thoughts on something like this #23364 ?