<p dir="auto">I am puzzled by the following</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="    logger.debug('Indexes are identical: {}'.format(data_frame.index is categories.index))
    logger.debug('Index is unique: {}'.format(data_frame.index.is_unique))
    logger.debug('All columns are in data_frame: {}'.format(all(map(lambda x: x in data_frame, columns_regression))))
    df_regression = data_frame[columns_regression].join(categories)"><pre class="notranslate"><code class="notranslate">    logger.debug('Indexes are identical: {}'.format(data_frame.index is categories.index))
    logger.debug('Index is unique: {}'.format(data_frame.index.is_unique))
    logger.debug('All columns are in data_frame: {}'.format(all(map(lambda x: x in data_frame, columns_regression))))
    df_regression = data_frame[columns_regression].join(categories)
</code></pre></div>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="2014-06-23 21:02:56,125 DEBUG    pmt.portfolio_analytics.attribution.AlphaData - Indexes are identical: True
2014-06-23 21:02:56,141 DEBUG    pmt.portfolio_analytics.attribution.AlphaData - Index is unique: True
2014-06-23 21:02:56,142 DEBUG    pmt.portfolio_analytics.attribution.AlphaData - All columns are in data_frame: True
Traceback (most recent call last):
  File &quot;C:/Users/BKovtunenko/Perforce/bos-perforce01_1666/bkovtunenko_BKOVTUNENKO-D7/aam/branches/boris/pmt/python/pmt/portfolio_analytics/attribution/AlphaData.py&quot;, line 1782, in &lt;module&gt;
    thresholds_mkt_cap=thresh_mkt_cap)
  File &quot;C:/Users/BKovtunenko/Perforce/bos-perforce01_1666/bkovtunenko_BKOVTUNENKO-D7/aam/branches/boris/pmt/python/pmt/portfolio_analytics/attribution/AlphaData.py&quot;, line 1640, in save_regression_results
    regression_type=regresion_type)
  File &quot;C:/Users/BKovtunenko/Perforce/bos-perforce01_1666/bkovtunenko_BKOVTUNENKO-D7/aam/branches/boris/pmt/python/pmt/portfolio_analytics/attribution/AlphaData.py&quot;, line 1489, in save_regression_decomposition
    df_regression = data_frame[columns_regression].join(categories)
  File &quot;C:\Python27\lib\site-packages\pandas\core\frame.py&quot;, line 3580, in join
    rsuffix=rsuffix, sort=sort)
  File &quot;C:\Python27\lib\site-packages\pandas\core\frame.py&quot;, line 3594, in _join_compat
    suffixes=(lsuffix, rsuffix), sort=sort)
  File &quot;C:\Python27\lib\site-packages\pandas\tools\merge.py&quot;, line 40, in merge
    return op.get_result()
  File &quot;C:\Python27\lib\site-packages\pandas\tools\merge.py&quot;, line 189, in get_result
    ldata, rdata = self._get_merge_data()
  File &quot;C:\Python27\lib\site-packages\pandas\tools\merge.py&quot;, line 284, in _get_merge_data
    copydata=False)
  File &quot;C:\Python27\lib\site-packages\pandas\core\internals.py&quot;, line 3439, in _maybe_rename_join
    to_rename = self.items.intersection(other.items)
  File &quot;C:\Python27\lib\site-packages\pandas\core\index.py&quot;, line 962, in intersection
    indexer = self.get_indexer(other.values)
  File &quot;C:\Python27\lib\site-packages\pandas\core\index.py&quot;, line 1120, in get_indexer
    raise InvalidIndexError('Reindexing only valid with uniquely'
pandas.core.index.InvalidIndexError: Reindexing only valid with uniquely valued Index objects

Process finished with exit code 1"><pre class="notranslate"><code class="notranslate">2014-06-23 21:02:56,125 DEBUG    pmt.portfolio_analytics.attribution.AlphaData - Indexes are identical: True
2014-06-23 21:02:56,141 DEBUG    pmt.portfolio_analytics.attribution.AlphaData - Index is unique: True
2014-06-23 21:02:56,142 DEBUG    pmt.portfolio_analytics.attribution.AlphaData - All columns are in data_frame: True
Traceback (most recent call last):
  File "C:/Users/BKovtunenko/Perforce/bos-perforce01_1666/bkovtunenko_BKOVTUNENKO-D7/aam/branches/boris/pmt/python/pmt/portfolio_analytics/attribution/AlphaData.py", line 1782, in &lt;module&gt;
    thresholds_mkt_cap=thresh_mkt_cap)
  File "C:/Users/BKovtunenko/Perforce/bos-perforce01_1666/bkovtunenko_BKOVTUNENKO-D7/aam/branches/boris/pmt/python/pmt/portfolio_analytics/attribution/AlphaData.py", line 1640, in save_regression_results
    regression_type=regresion_type)
  File "C:/Users/BKovtunenko/Perforce/bos-perforce01_1666/bkovtunenko_BKOVTUNENKO-D7/aam/branches/boris/pmt/python/pmt/portfolio_analytics/attribution/AlphaData.py", line 1489, in save_regression_decomposition
    df_regression = data_frame[columns_regression].join(categories)
  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 3580, in join
    rsuffix=rsuffix, sort=sort)
  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 3594, in _join_compat
    suffixes=(lsuffix, rsuffix), sort=sort)
  File "C:\Python27\lib\site-packages\pandas\tools\merge.py", line 40, in merge
    return op.get_result()
  File "C:\Python27\lib\site-packages\pandas\tools\merge.py", line 189, in get_result
    ldata, rdata = self._get_merge_data()
  File "C:\Python27\lib\site-packages\pandas\tools\merge.py", line 284, in _get_merge_data
    copydata=False)
  File "C:\Python27\lib\site-packages\pandas\core\internals.py", line 3439, in _maybe_rename_join
    to_rename = self.items.intersection(other.items)
  File "C:\Python27\lib\site-packages\pandas\core\index.py", line 962, in intersection
    indexer = self.get_indexer(other.values)
  File "C:\Python27\lib\site-packages\pandas\core\index.py", line 1120, in get_indexer
    raise InvalidIndexError('Reindexing only valid with uniquely'
pandas.core.index.InvalidIndexError: Reindexing only valid with uniquely valued Index objects

Process finished with exit code 1
</code></pre></div>
<p dir="auto">xref <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="251275032" data-permission-text="Title is private" data-url="https://github.com/pandas-dev/pandas/issues/17282" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/17282/hovercard" href="https://github.com/pandas-dev/pandas/issues/17282">#17282</a></p>
<h4 dir="auto">Code Sample</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; x.isnull().sum()
0

&gt;&gt;&gt; x.value_counts()
0.000000     693
12.561725      1
13.568112      1
12.521249      1
13.007628      1
6.993961       1
14.815512      1
6.017280       1
12.944714      1
Name: 0, dtype: int64

&gt;&gt;&gt; categorized = pd.qcut(x, 10, duplicates='drop')
&gt;&gt;&gt; categorized.isnull().sum()
0

&gt;&gt;&gt; categorized.cat.categories  # Notice how all values of x are contained in the only interval
IntervalIndex([(-0.001, 14.816]]
              closed='right',
              dtype='interval[float64]')

&gt;&gt;&gt; res = pd.cut(x, categorized.cat.categories)
&gt;&gt;&gt; res.isnull().sum()
701"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-en">isnull</span>().<span class="pl-en">sum</span>()
<span class="pl-c1">0</span>

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">x</span>.<span class="pl-en">value_counts</span>()
<span class="pl-c1">0.000000</span>     <span class="pl-c1">693</span>
<span class="pl-c1">12.561725</span>      <span class="pl-c1">1</span>
<span class="pl-c1">13.568112</span>      <span class="pl-c1">1</span>
<span class="pl-c1">12.521249</span>      <span class="pl-c1">1</span>
<span class="pl-c1">13.007628</span>      <span class="pl-c1">1</span>
<span class="pl-c1">6.993961</span>       <span class="pl-c1">1</span>
<span class="pl-c1">14.815512</span>      <span class="pl-c1">1</span>
<span class="pl-c1">6.017280</span>       <span class="pl-c1">1</span>
<span class="pl-c1">12.944714</span>      <span class="pl-c1">1</span>
<span class="pl-v">Name</span>: <span class="pl-c1">0</span>, <span class="pl-s1">dtype</span>: <span class="pl-s1">int64</span>

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">categorized</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">qcut</span>(<span class="pl-s1">x</span>, <span class="pl-c1">10</span>, <span class="pl-s1">duplicates</span><span class="pl-c1">=</span><span class="pl-s">'drop'</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">categorized</span>.<span class="pl-en">isnull</span>().<span class="pl-en">sum</span>()
<span class="pl-c1">0</span>

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">categorized</span>.<span class="pl-s1">cat</span>.<span class="pl-s1">categories</span>  <span class="pl-c"># Notice how all values of x are contained in the only interval</span>
<span class="pl-v">IntervalIndex</span>([(<span class="pl-c1">-</span><span class="pl-c1">0.001</span>, <span class="pl-c1">14.816</span>]]
              <span class="pl-s1">closed</span><span class="pl-c1">=</span><span class="pl-s">'right'</span>,
              <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s">'interval[float64]'</span>)

<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">res</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">cut</span>(<span class="pl-s1">x</span>, <span class="pl-s1">categorized</span>.<span class="pl-s1">cat</span>.<span class="pl-s1">categories</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">res</span>.<span class="pl-en">isnull</span>().<span class="pl-en">sum</span>()
<span class="pl-c1">701</span></pre></div>
<p dir="auto">Copy pastable</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="x = pd.read_csv('x.csv', header=None).iloc[:, 0]  # x.csv is provided in a comment below
categorized = pd.qcut(x, 10, duplicates='drop')
res = pd.cut(x, categorized.cat.categories)
res.isnull().sum()"><pre class="notranslate"><span class="pl-s1">x</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">read_csv</span>(<span class="pl-s">'x.csv'</span>, <span class="pl-s1">header</span><span class="pl-c1">=</span><span class="pl-c1">None</span>).<span class="pl-s1">iloc</span>[:, <span class="pl-c1">0</span>]  <span class="pl-c"># x.csv is provided in a comment below</span>
<span class="pl-s1">categorized</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">qcut</span>(<span class="pl-s1">x</span>, <span class="pl-c1">10</span>, <span class="pl-s1">duplicates</span><span class="pl-c1">=</span><span class="pl-s">'drop'</span>)
<span class="pl-s1">res</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-en">cut</span>(<span class="pl-s1">x</span>, <span class="pl-s1">categorized</span>.<span class="pl-s1">cat</span>.<span class="pl-s1">categories</span>)
<span class="pl-s1">res</span>.<span class="pl-en">isnull</span>().<span class="pl-en">sum</span>()</pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">When I use <code class="notranslate">qcut</code> to get the <code class="notranslate">IntervalIndex</code> corresponding to the quantiles of a <code class="notranslate">float64</code> series, and than use this as the <code class="notranslate">bins</code> of <code class="notranslate">cut</code> on the same float64 series, it doesn't work. It produces a new series with a lot of NaN values, while the original series contained no NaN and all of its values are contained at the interval of <code class="notranslate">IntervalIndex</code>.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">The result of both <code class="notranslate">qcut</code> and <code class="notranslate">cut</code> should also be the same, but they are not.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 3.6.1.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 3.10.0-514.26.2.el7.x86_64<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.UTF-8<br>
LOCALE: en_US.UTF-8</p>
<p dir="auto">pandas: 0.20.1<br>
pytest: 3.0.7<br>
pip: 9.0.1<br>
setuptools: 27.2.0<br>
Cython: 0.25.2<br>
numpy: 1.12.1<br>
scipy: 0.19.0<br>
xarray: None<br>
IPython: 5.3.0<br>
sphinx: 1.5.6<br>
patsy: 0.4.1<br>
dateutil: 2.6.0<br>
pytz: 2017.2<br>
blosc: None<br>
bottleneck: 1.2.1<br>
tables: 3.3.0<br>
numexpr: 2.6.2<br>
feather: None<br>
matplotlib: 2.0.2<br>
openpyxl: 2.4.7<br>
xlrd: 1.0.0<br>
xlwt: 1.2.0<br>
xlsxwriter: 0.9.6<br>
lxml: 3.7.3<br>
bs4: 4.6.0<br>
html5lib: 0.9999999<br>
sqlalchemy: 1.1.9<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>