TST: add test for df.where() with category dtype
State: closed

- [x] xref #16979
- [x] tests added / passed
- [x] passes `black pandas`
- [x] passes `git diff upstream/master -u -- "*.py" | flake8 --diff`
- [ ] whatsnew entry


Labels:
name: Testing
description: pandas testing functions or related to the test suite
name: Categorical
description: Categorical Data Type

Comments:
@ganevgv : Good job with the tests so far!  #16979 is a two-parter, and since both parts have been fixed on `master`, they both need tests.

If you would like, you can add (in this PR) a second test to address the `.astype` error.
@gfyoung, thanks for the guidance up to now! After adding my second test `test_df_where_change_dtype(...)` in this PR, there seems to be some inconsistencies across the different operating systems.

```
df = DataFrame(np.arange(2 * 3).reshape(2, 3), columns=list("ABC"))
mask = np.array([[True, False, True], [False, True, True]])

result = df.where(mask)
expected = DataFrame([[0, np.nan, 2], [np.nan, 4, 5]], columns=list("ABC"))

tm.assert_frame_equal(result, expected)
```

After running the code above, on some operating systems (`linux -- Python 3.6.7`, `win32 -- Python 3.6.7`, `win32 -- Python 3.7.5`) applying the boolean mask changes the dtype of the last column `[2, 5]` from `int64` to `int32`. I cannot reproduce this behaviour locally.

`Output of pd.show_versions()`

<details>
INSTALLED VERSIONS
------------------
commit           : 35e91f9fab6f3a9b3d3523d5935b04de888f6daa
python           : 3.6.5.final.0
python-bits      : 64
OS               : Darwin
OS-release       : 17.7.0
machine          : x86_64
processor        : i386
byteorder        : little
LC_ALL           : None
LANG             : en_GB.UTF-8
LOCALE           : en_GB.UTF-8

pandas           : 0.26.0.dev0+734.g0de99558b.dirty
numpy            : 1.17.3
pytz             : 2019.3
dateutil         : 2.8.0
pip              : 19.3.1
setuptools       : 39.0.1
Cython           : 0.29.14
pytest           : 5.2.2
hypothesis       : 4.42.6
sphinx           : 2.2.1
blosc            : 1.8.1
feather          : None
xlsxwriter       : 1.2.2
lxml.etree       : 4.4.1
html5lib         : 1.0.1
pymysql          : None
psycopg2         : None
jinja2           : 2.10.3
IPython          : 7.9.0
pandas_datareader: None
bs4              : 4.7.1
bottleneck       : 1.2.1
fastparquet      : 0.3.2
gcsfs            : None
lxml.etree       : 4.4.1
matplotlib       : 3.1.1
numexpr          : 2.7.0
odfpy            : None
openpyxl         : 3.0.0
pandas_gbq       : None
pyarrow          : 0.15.1
pytables         : None
s3fs             : 0.3.5
scipy            : 1.3.1
sqlalchemy       : 1.3.10
tables           : 3.6.1
xarray           : 0.14.0
xlrd             : 1.2.0
xlwt             : 1.3.0
xlsxwriter       : 1.2.2
</details>

What would be your suggestion? I'm happy to remove or xfail the `test_df_where_change_dtype(...)` test from this PR (so we can merge it) and raise an issue. I can also force the dtype but that's not ideal.
@ganevgv : Why don't you revert your last commit, and we can focus on it in a separate PR.
@gfyoung thanks - removed the second test in this PR, will create a new issue specifying the problem
Actually, can you comment in the original issue?  I plan on keeping that one open.