Performance issues with Pandas on compressed dataset
Hello All,

#### Problem description
This question is about boosting Pandas' performance during stacking and unstacking operation. It seems if I convert `object` type to `category` and downgrade `float64`, then stacking and unstacking take a lot of time. If I don't compress the dataframe, this doesn't happen. 

The issue is that I have a large dataframe (~2GB). I followed [this blog](https://www.dataquest.io/blog/pandas-big-data/) to compress it to ~150MB successfully. However, my stacking and unstacking operation take infinite amount of time such that I have to kill the kernel and restart everything. I managed to cut a small feed (5MB) from my dataset for representation purpose here. The feed has been uploaded to http://www.filedropper.com/ddataredact. This file should be able to reproduce the problem.

#### Here's my code

```python
import pandas as pd
ddata_i = pd.read_csv('ddata_redact.csv')

#This will show the result quickly
ddata_i.groupby(["Name","Geo1","Geo2","Model"]).\
    sum().\
    unstack().\
    stack(dropna=False).\
    reset_index()

#Compress our data
ddata = ddata_i.copy()

df_obj = ddata.select_dtypes(include=['object']).copy()
for col in df_obj:
    df_obj.loc[:, col] = df_obj[col].astype('category')
ddata[df_obj.columns] = df_obj

df_obj = ddata.select_dtypes(include=['float']).copy()
for col in df_obj:
    df_obj.loc[:, col] = df_obj[col].astype('float')
ddata[df_obj.columns] = df_obj

#Let's quickly check whether compressed file is same as original file
assert ddata.shape==ddata_i.shape, "Output seems wrong"
assert ddata_i.ANDroid_Margin.sum()==ddata.ANDroid_Margin.sum(),"Sum isn't right"
for col in ["ANDroid_Margin","Name","Geo1","Geo2"]:
    assert sorted(list(ddata_i[col].unique()))==sorted(list(ddata[col].unique()))

#This will run forever
ddata.groupby(["Name","Geo1","Geo2","Model"]).\
    sum().\
    unstack().\
    stack(dropna=False).\
    reset_index()

```
You will note that stacking and unstacking operation on `ddata_i` will run quickly, but not on compressed `ddata`. Why is this?

Also, I noticed that if I compress either `object` or `float`, then `stack()` and `unstack()` will run quickly. It's only when I do both, the problem persists.

--------------------------------------
sys.version_info
`> sys.version_info(major=3, minor=6, micro=7, releaselevel='final', serial=0)`

pandas version
> '0.23.4'`

#### Output of ``pd.show_versions()``
INSTALLED VERSIONS
------------------
commit: None
python: 3.6.7.final.0
python-bits: 64
OS: Windows
OS-release: 10
machine: AMD64
processor: Intel64 Family 6 Model 142 Stepping 9, GenuineIntel
byteorder: little
LC_ALL: None
LANG: None
LOCALE: None.None
pandas: 0.23.4
pytest: 4.0.0
pip: 18.1
setuptools: 40.6.2
Cython: 0.29
numpy: 1.15.4
scipy: 1.1.0
pyarrow: None
xarray: None
IPython: 7.1.1
sphinx: 1.8.2
patsy: 0.5.1
dateutil: 2.7.5
pytz: 2018.7
blosc: None
bottleneck: 1.2.1
tables: 3.4.4
numexpr: 2.6.8
feather: None
matplotlib: 3.0.1
openpyxl: 2.5.9
xlrd: 1.1.0
xlwt: 1.3.0
xlsxwriter: 1.1.2
lxml: 4.2.5
bs4: 4.6.3
html5lib: 1.0.1
sqlalchemy: 1.2.14
pymysql: None
psycopg2: None
jinja2: 2.10
s3fs: None
fastparquet: None
pandas_gbq: None
pandas_datareader: None](url)

Please let me know if anything else is missing.

