Partialy fix issue #23334 - isort pandas/core/dtypes directory
State: closed

The imports have been sorted with isort in the pandas/core/dtypes directory.

Moving onto sorting the pandas/core/groupby directory.

- [x] partly #23334
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`


Labels:
name: Code Style
description: Code style, linting, code_checks

Comments:
Hello @alexander-ponomaroff! Thanks for updating the PR.

 - There are no PEP8 issues in the file [`pandas/core/dtypes/api.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/api.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/base.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/base.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/cast.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/cast.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/common.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/common.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/concat.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/concat.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/dtypes.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/dtypes.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/inference.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/inference.py) !

 - There are no PEP8 issues in the file [`pandas/core/dtypes/missing.py`](https://github.com/alexander-ponomaroff/pandas/blob/f1160c1236c00d64363e3913756d04462f63c891/pandas/core/dtypes/missing.py) !



##### Comment last updated on October 25, 2018 at 21:04 Hours UTC
Thanks @alexander-ponomaroff ! Lets wait for CI to run then i'm happy to review this.
Thank you @alimcmaster1 . Could you please explain what "passes git diff upstream/master -u -- "*.py" | flake8 --diff" means? I noticed that you have this checked in your pull requests.
Hey - please see the "Python (PEP8)" section in the [contributing guide](https://pandas.pydata.org/pandas-docs/stable/contributing.html) and further info on [flake8 here](http://flake8.pycqa.org/en/latest/) - hope that helps.
@alimcmaster1 How long does the CI usually run for? I would like to wait for the dtypes directory to be all good before starting to work on the groupby directory, but might need to leave soon for a couple hours. So I was wondering it the checks will finish before I have to leave.
> Hey - please see the "Python (PEP8)" section in the [contributing guide](https://pandas.pydata.org/pandas-docs/stable/contributing.html) and further info on [flake8 here](http://flake8.pycqa.org/en/latest/) - hope that helps.

Thanks, just performed the check locally. But I'm assuming the pep8speaks bot, which is the second comment of this pr does the same thing here?
https://travis-ci.org/pandas-dev/pandas/pull_requests , you can look at the CI run off the back of previous PRs to get an idea of how long it will take, feel free to wait till tomorrow there is no rush
# [Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23336?src=pr&el=h1) Report
> :exclamation: No coverage uploaded for pull request base (`master@0d6cb3c`). [Click here to learn what that means](https://docs.codecov.io/docs/error-reference#section-missing-base-commit).
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff            @@
##             master   #23336   +/-   ##
=========================================
  Coverage          ?   92.18%           
=========================================
  Files             ?      161           
  Lines             ?    51186           
  Branches          ?        0           
=========================================
  Hits              ?    47188           
  Misses            ?     3998           
  Partials          ?        0
```

| Flag | Coverage Δ | |
|---|---|---|
| #multiple | `90.62% <100%> (?)` | |
| #single | `42.22% <100%> (?)` | |

| [Impacted Files](https://codecov.io/gh/pandas-dev/pandas/pull/23336?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pandas/core/dtypes/base.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Jhc2UucHk=) | `100% <100%> (ø)` | |
| [pandas/core/dtypes/concat.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbmNhdC5weQ==) | `96.34% <100%> (ø)` | |
| [pandas/core/dtypes/missing.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL21pc3NpbmcucHk=) | `93.1% <100%> (ø)` | |
| [pandas/core/dtypes/dtypes.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2R0eXBlcy5weQ==) | `95.61% <100%> (ø)` | |
| [pandas/core/dtypes/inference.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2luZmVyZW5jZS5weQ==) | `98.38% <100%> (ø)` | |
| [pandas/core/dtypes/cast.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2Nhc3QucHk=) | `88.92% <100%> (ø)` | |
| [pandas/core/dtypes/common.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2NvbW1vbi5weQ==) | `94.37% <100%> (ø)` | |
| [pandas/core/dtypes/api.py](https://codecov.io/gh/pandas-dev/pandas/pull/23336/diff?src=pr&el=tree#diff-cGFuZGFzL2NvcmUvZHR5cGVzL2FwaS5weQ==) | `100% <100%> (ø)` | |

------

[Continue to review full report at Codecov](https://codecov.io/gh/pandas-dev/pandas/pull/23336?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/23336?src=pr&el=footer). Last update [0d6cb3c...a74f2b6](https://codecov.io/gh/pandas-dev/pandas/pull/23336?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).

pls merge master and ping on green.
`from pandas.core.dtypes.generic import ABCPeriodArray` in common.py it looks like you have removed this import? Did isort do this? 
@alimcmaster1 Not sure what happened, I did not remove it on purpose.
@alimcmaster1 I just added ABCPeriodArray back and fixed another conflict. 
@alexander-ponomaroff  You might want to rerun `isort` to fix travis CI. I did on some of my PRs and they are passed now. It might be due to `upstream/merge`. 
@thoo I reran isort, but the CI is still failing. @alimcmaster1 Do you have any suggestions on what I should do?
You can go to the log file and see what goes wrong. For example, this is the first one failed. 

```
[31m[1m_____________ TestDataFrameCombineFirst.test_combine_first_period ______________[0m
[gw1] linux -- Python 3.7.1 /home/travis/miniconda3/envs/pandas/bin/python

self = <pandas.tests.frame.test_combine_concat.TestDataFrameCombineFirst object at 0x7f06cdf74470>

[1m    def test_combine_first_period(self):[0m
[1m        data1 = pd.PeriodIndex(['2011-01', 'NaT', '2011-03',[0m
[1m                                '2011-04'], freq='M')[0m
[1m        df1 = pd.DataFrame({'P': data1}, index=[1, 3, 5, 7])[0m
[1m        data2 = pd.PeriodIndex(['2012-01-01', '2012-02',[0m
[1m                                '2012-03'], freq='M')[0m
[1m        df2 = pd.DataFrame({'P': data2}, index=[2, 4, 5])[0m
[1m    [0m
[1m        res = df1.combine_first(df2)[0m
[1m        exp_dts = pd.PeriodIndex(['2011-01', '2012-01', 'NaT',[0m
[1m                                  '2012-02', '2011-03', '2011-04'],[0m
[1m                                 freq='M')[0m
[1m        exp = pd.DataFrame({'P': exp_dts}, index=[1, 2, 3, 4, 5, 7])[0m
[1m>       tm.assert_frame_equal(res, exp)[0m
[1m[31mE       AssertionError: Attributes are different[0m
[1m[31mE       [0m
[1m[31mE       Attribute "dtype" are different[0m
[1m[31mE       [left]:  int64[0m
[1m[31mE       [right]: period[M][0m

[1m[31mpandas/tests/frame/test_combine_concat.py[0m:775: AssertionError
```
I might rebase :
```
git fetch upstream
git merge upstream/master
```
and after that rerun `isort` to make sure everything is as you wanted. Rebase shouldn't change but it won't hurt.
@jreback Hello Jeff, I cannot seem to identify the cause of CI failing, it recently started failing after I resolved the second conflict with the master branch.
I notice that this was changed a few days ago, and it's now failing here:
https://github.com/pandas-dev/pandas/blame/5d84bc08ea7c45b0d2b3aa021a425b11531336f1/pandas/tests/frame/test_combine_concat.py#L776

@TomAugspurger you worked on this, do you have any advice for me? Or know why this failure was triggered in my pr?
@alimcmaster1 I reran everything from scratch and the previously triggered error doesn't trigger anymore. However there is an error now `KeyError: <class 'pandas._libs.tslibs.timestamps.Timestamp'>`, not sure what this has to do with anything I did. Do you have any suggestions?
You may need to rebuild the C extensions: `python setup.py build_ext
--inplace -j 4`

On Mon, Oct 29, 2018 at 12:19 PM Alexander Ponomaroff <
notifications@github.com> wrote:

> @alimcmaster1 <https://github.com/alimcmaster1> I reran everything from
> scratch and the previously triggered error doesn't trigger anymore. However
> there is an error now KeyError: <class
> 'pandas._libs.tslibs.timestamps.Timestamp'>, not sure what this has to do
> with anything I did. Do you have any suggestions?
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/23336#issuecomment-433997425>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIr_XmDwPuv7hwKzvSdVrOpVI6ZVRks5upziwgaJpZM4X7GYN>
> .
>

@TomAugspurger I get this error: `pandas/_libs/window.cpp:612:10: fatal error: 'ios' file not found`
Others have reported that. What version of MacOS? You may need to update
your command line tools.

On Mon, Oct 29, 2018 at 3:50 PM Alexander Ponomaroff <
notifications@github.com> wrote:

> @TomAugspurger <https://github.com/TomAugspurger> I get this error: pandas/_libs/window.cpp:612:10:
> fatal error: 'ios' file not found
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/23336#issuecomment-434074676>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIj-voYoQqXrfJSYo5Wl_6dQa34mnks5up2oxgaJpZM4X7GYN>
> .
>

@TomAugspurger High Sierra 10.13.6
What does `xcode-select --install` output?

On Mon, Oct 29, 2018 at 3:57 PM Alexander Ponomaroff <
notifications@github.com> wrote:

> @TomAugspurger <https://github.com/TomAugspurger> High Sierra 10.13.6
>
> —
> You are receiving this because you were mentioned.
> Reply to this email directly, view it on GitHub
> <https://github.com/pandas-dev/pandas/pull/23336#issuecomment-434076970>,
> or mute the thread
> <https://github.com/notifications/unsubscribe-auth/ABQHIleq6JpOfNbLbcas2LrfbEkzB3AAks5up2vPgaJpZM4X7GYN>
> .
>

@TomAugspurger Got it, I updated the command line tools and it worked. I rebuilt the C extensions. Where do I go from here? 
@TomAugspurger Btw, the error `KeyError: <class 'pandas._libs.tslibs.timestamps.Timestamp'>` is in one of the tests from Azure Pipelines, in case you thought that it was local. I just noticed that you're replying from an email. That's the only check I fail from the CI checks.
"Btw, the error KeyError: <class 'pandas._libs.tslibs.timestamps.Timestamp'> is in one of the tests from Azure Pipelines"

I don't think the pipeline is failing because of this. [Here](https://github.com/pandas-dev/pandas/pull/23331/checks?check_run_id=27234672) is an example of a pipeline with the same test errors but the pipeline succeeds.

Your [pipeline](https://dev.azure.com/pandas-dev/pandas/_build/results?buildId=2073&view=logs) seems to be failing "WindowsPy27 py36_np121" builds with the error:

2018-10-29T15:30:51.4397165Z Could not find conda environment: pandas
2018-10-29T15:30:51.4398019Z You can list all discoverable environments with `conda info --envs`.
2018-10-29T15:30:56.1307704Z ModuleNotFoundError: No module named 'numpy'

Maybe @TomAugspurger could restart that for you? As i'm really not sure what the issue is there.

^ Ignore that @alexander-ponomaroff has just pushed a change- lets see if the above repeats.
@alimcmaster1 Thank you very much. Hopefully nothing will fail this time. 

Looks like isort on the dtype directory keeps triggering weird behaviours :).
@alimcmaster1 Wow, finally! Everything passed. Thanks for you help.
@jreback Everything passed now, could you please merge if everything is good?