<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; import struct
&gt;&gt;&gt; struct.pack('qq', 1, 2)
'\x01\x00\x00\x00\x00\x00\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00'
&gt;&gt;&gt; buf = struct.pack('qq', 1, 2)
&gt;&gt;&gt; import numpy
&gt;&gt;&gt; ar = numpy.frombuffer(buf, dtype=numpy.int64)
&gt;&gt;&gt; ar
array([1, 2])
&gt;&gt;&gt; import pandas
&gt;&gt;&gt; pandas.MultiIndex.from_arrays([ar, numpy.array([10, 20])])
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;.../.local/lib/python2.7/site-packages/pandas/indexes/multi.py&quot;, line 935, in from_arrays
    labels, levels = _factorize_from_iterables(arrays)
  File &quot;.../.local/lib/python2.7/site-packages/pandas/core/categorical.py&quot;, line 2068, in _factorize_from_iterables
    return map(list, lzip(*[_factorize_from_iterable(it) for it in iterables]))
  File &quot;.../.local/lib/python2.7/site-packages/pandas/core/categorical.py&quot;, line 2040, in _factorize_from_iterable
    cat = Categorical(values, ordered=True)
  File &quot;.../.local/lib/python2.7/site-packages/pandas/core/categorical.py&quot;, line 300, in __init__
    raise NotImplementedError(&quot;&gt; 1 ndim Categorical are not &quot;
NotImplementedError: &gt; 1 ndim Categorical are not supported at this time"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">struct</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">struct</span>.<span class="pl-en">pack</span>(<span class="pl-s">'qq'</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>)
<span class="pl-s">'<span class="pl-cce">\x01</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x02</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span><span class="pl-cce">\x00</span>'</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">buf</span> <span class="pl-c1">=</span> <span class="pl-s1">struct</span>.<span class="pl-en">pack</span>(<span class="pl-s">'qq'</span>, <span class="pl-c1">1</span>, <span class="pl-c1">2</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">numpy</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">ar</span> <span class="pl-c1">=</span> <span class="pl-s1">numpy</span>.<span class="pl-en">frombuffer</span>(<span class="pl-s1">buf</span>, <span class="pl-s1">dtype</span><span class="pl-c1">=</span><span class="pl-s1">numpy</span>.<span class="pl-s1">int64</span>)
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">ar</span>
<span class="pl-en">array</span>([<span class="pl-c1">1</span>, <span class="pl-c1">2</span>])
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-k">import</span> <span class="pl-s1">pandas</span>
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">pandas</span>.<span class="pl-v">MultiIndex</span>.<span class="pl-en">from_arrays</span>([<span class="pl-s1">ar</span>, <span class="pl-s1">numpy</span>.<span class="pl-en">array</span>([<span class="pl-c1">10</span>, <span class="pl-c1">20</span>])])
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">"&lt;stdin&gt;"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
  <span class="pl-v">File</span> <span class="pl-s">".../.local/lib/python2.7/site-packages/pandas/indexes/multi.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">935</span>, <span class="pl-s1">in</span> <span class="pl-s1">from_arrays</span>
    <span class="pl-s1">labels</span>, <span class="pl-s1">levels</span> <span class="pl-c1">=</span> <span class="pl-en">_factorize_from_iterables</span>(<span class="pl-s1">arrays</span>)
  <span class="pl-v">File</span> <span class="pl-s">".../.local/lib/python2.7/site-packages/pandas/core/categorical.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2068</span>, <span class="pl-s1">in</span> <span class="pl-s1">_factorize_from_iterables</span>
    <span class="pl-k">return</span> <span class="pl-en">map</span>(<span class="pl-s1">list</span>, <span class="pl-en">lzip</span>(<span class="pl-c1">*</span>[<span class="pl-en">_factorize_from_iterable</span>(<span class="pl-s1">it</span>) <span class="pl-k">for</span> <span class="pl-s1">it</span> <span class="pl-c1">in</span> <span class="pl-s1">iterables</span>]))
  <span class="pl-v">File</span> <span class="pl-s">".../.local/lib/python2.7/site-packages/pandas/core/categorical.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">2040</span>, <span class="pl-s1">in</span> <span class="pl-s1">_factorize_from_iterable</span>
    <span class="pl-s1">cat</span> <span class="pl-c1">=</span> <span class="pl-v">Categorical</span>(<span class="pl-s1">values</span>, <span class="pl-s1">ordered</span><span class="pl-c1">=</span><span class="pl-c1">True</span>)
  <span class="pl-v">File</span> <span class="pl-s">".../.local/lib/python2.7/site-packages/pandas/core/categorical.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">300</span>, <span class="pl-s1">in</span> <span class="pl-s1">__init__</span>
    <span class="pl-k">raise</span> <span class="pl-v">NotImplementedError</span>(<span class="pl-s">"&gt; 1 ndim Categorical are not "</span>
<span class="pl-v">NotImplementedError</span>: <span class="pl-c1">&gt;</span> <span class="pl-c1">1</span> <span class="pl-s1">ndim</span> <span class="pl-v">Categorical</span> <span class="pl-s1">are</span> <span class="pl-c1">not</span> <span class="pl-s1">supported</span> <span class="pl-s1">at</span> <span class="pl-s1">this</span> <span class="pl-s1">time</span></pre></div>
<p dir="auto">In-depth look:</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="&gt;&gt;&gt; pandas.core.categorical.factorize(ar, sort = True)
Traceback (most recent call last):
  File &quot;&lt;stdin&gt;&quot;, line 1, in &lt;module&gt;
  File &quot;.../.local/lib/python2.7/site-packages/pandas/core/algorithms.py&quot;, line 313, in factorize
    labels = table.get_labels(vals, uniques, 0, na_sentinel, True)
  File &quot;pandas/src/hashtable_class_helper.pxi&quot;, line 485, in pandas.hashtable.Int64HashTable.get_labels (pandas/hashtable.c:9966)
  File &quot;stringsource&quot;, line 644, in View.MemoryView.memoryview_cwrapper (pandas/hashtable.c:32223)
  File &quot;stringsource&quot;, line 345, in View.MemoryView.memoryview.__cinit__ (pandas/hashtable.c:28458)
ValueError: buffer source array is read-only"><pre class="notranslate"><span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">core</span>.<span class="pl-s1">categorical</span>.<span class="pl-en">factorize</span>(<span class="pl-s1">ar</span>, <span class="pl-s1">sort</span> <span class="pl-c1">=</span> <span class="pl-c1">True</span>)
<span class="pl-v">Traceback</span> (<span class="pl-s1">most</span> <span class="pl-s1">recent</span> <span class="pl-s1">call</span> <span class="pl-s1">last</span>):
  <span class="pl-v">File</span> <span class="pl-s">"&lt;stdin&gt;"</span>, <span class="pl-s1">line</span> <span class="pl-c1">1</span>, <span class="pl-s1">in</span> <span class="pl-c1">&lt;</span><span class="pl-s1">module</span><span class="pl-c1">&gt;</span>
  <span class="pl-v">File</span> <span class="pl-s">".../.local/lib/python2.7/site-packages/pandas/core/algorithms.py"</span>, <span class="pl-s1">line</span> <span class="pl-c1">313</span>, <span class="pl-s1">in</span> <span class="pl-s1">factorize</span>
    <span class="pl-s1">labels</span> <span class="pl-c1">=</span> <span class="pl-s1">table</span>.<span class="pl-en">get_labels</span>(<span class="pl-s1">vals</span>, <span class="pl-s1">uniques</span>, <span class="pl-c1">0</span>, <span class="pl-s1">na_sentinel</span>, <span class="pl-c1">True</span>)
  <span class="pl-v">File</span> <span class="pl-s">"pandas/src/hashtable_class_helper.pxi"</span>, <span class="pl-s1">line</span> <span class="pl-c1">485</span>, <span class="pl-s1">in</span> <span class="pl-s1">pandas</span>.<span class="pl-s1">hashtable</span>.<span class="pl-v">Int64HashTable</span>.<span class="pl-en">get_labels</span> (<span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">hashtable</span>.<span class="pl-s1">c</span>:<span class="pl-c1">9966</span>)
  <span class="pl-v">File</span> <span class="pl-s">"stringsource"</span>, <span class="pl-s1">line</span> <span class="pl-c1">644</span>, <span class="pl-s1">in</span> <span class="pl-v">View</span>.<span class="pl-v">MemoryView</span>.<span class="pl-en">memoryview_cwrapper</span> (<span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">hashtable</span>.<span class="pl-s1">c</span>:<span class="pl-c1">32223</span>)
  <span class="pl-v">File</span> <span class="pl-s">"stringsource"</span>, <span class="pl-s1">line</span> <span class="pl-c1">345</span>, <span class="pl-s1">in</span> <span class="pl-v">View</span>.<span class="pl-v">MemoryView</span>.<span class="pl-s1">memoryview</span>.<span class="pl-en">__cinit__</span> (<span class="pl-s1">pandas</span><span class="pl-c1">/</span><span class="pl-s1">hashtable</span>.<span class="pl-s1">c</span>:<span class="pl-c1">28458</span>)
<span class="pl-v">ValueError</span>: <span class="pl-s1">buffer</span> <span class="pl-s1">source</span> <span class="pl-s1">array</span> <span class="pl-c1">is</span> <span class="pl-s1">read</span><span class="pl-c1">-</span><span class="pl-s1">only</span></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">If a <code class="notranslate">NumPy</code> array backed by a read-only buffer is used in <code class="notranslate">MultiInted.from_arrays</code> a confuzsing <code class="notranslate">NotImplementedError: &gt; 1 ndim Categorical are not supported at this time</code> exception is raised.</p>
<p dir="auto">A more in-depth look at the code shows that, when using a <code class="notranslate">NumPy</code> array backed by a read-only buffer, the <code class="notranslate">Categorical</code> constructor (which raises the <code class="notranslate">NotImplementedError</code> exception) calls <code class="notranslate">factorize</code> which raises <code class="notranslate">ValueError: buffer source array is read-only</code>.</p>
<p dir="auto">Maybe the read-only aspect raised by <code class="notranslate">factorize</code> should propagate to the user so the real cause of the exception is known. As currently implemented, the <code class="notranslate">Categorical</code> constructor reinterprets the exception and throws a confusing <code class="notranslate">NotImplementedError: &gt; 1 ndim Categorical are not supported at this time</code></p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto"><code class="notranslate">ValueError: buffer source array is read-only</code></p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
# Paste the output here pd.show_versions() here
&gt;&gt;&gt; pandas.show_versions()
<h2 dir="auto">INSTALLED VERSIONS</h2>
<p dir="auto">commit: None<br>
python: 2.7.13.final.0<br>
python-bits: 64<br>
OS: Linux<br>
OS-release: 4.9.6-100.fc24.x86_64<br>
machine: x86_64<br>
processor: x86_64<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: en_US.utf8<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.19.2<br>
nose: 1.3.7<br>
pip: 9.0.1<br>
setuptools: 20.1.1<br>
Cython: 0.25.2<br>
numpy: 1.11.0<br>
scipy: 0.16.1<br>
statsmodels: None<br>
xarray: None<br>
IPython: 5.3.0<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.0<br>
pytz: 2016.10<br>
blosc: None<br>
bottleneck: 0.6.0<br>
tables: 3.2.2<br>
numexpr: 2.6.1<br>
matplotlib: 1.5.2rc2<br>
openpyxl: None<br>
xlrd: 0.9.4<br>
xlwt: 1.0.0<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: 4.4.0<br>
html5lib: 1.0b7<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.8.1<br>
boto: 2.45.0<br>
pandas_datareader: 0.3.0.post</p>
</details>
<h4 dir="auto">Code Sample, a copy-pastable example if possible</h4>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import numpy as np
import pandas as pd
a = np.array(range(3))
b = ['a', 'b']
# Succeeds, as expected
pd.MultiIndex.from_product([a, b]) 
a.setflags(write=False)
# Raises a ValueError with &quot;buffer source array is read-only&quot;
pd.MultiIndex.from_product([a, b]) "><pre lang="python" class="notranslate"><code class="notranslate">import numpy as np
import pandas as pd
a = np.array(range(3))
b = ['a', 'b']
# Succeeds, as expected
pd.MultiIndex.from_product([a, b]) 
a.setflags(write=False)
# Raises a ValueError with "buffer source array is read-only"
pd.MultiIndex.from_product([a, b]) 
</code></pre></div>
<h4 dir="auto">Problem description</h4>
<p dir="auto">Nothing in the MultiIndex.from_product documentation suggests the inputs need to be mutable.  Moreover, it is surprising that the arguments are being mutated.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">Not raising.</p>
<h4 dir="auto">Output of <code class="notranslate">pd.show_versions()</code></h4>
<details>
INSTALLED VERSIONS
------------------
commit: None
python: 3.5.2.final.0
python-bits: 64
OS: Linux
OS-release: 4.1.17-pv-ts1
machine: x86_64
processor: 
byteorder: little
LC_ALL: en_US.UTF-8
LANG: en_US.UTF-8
LOCALE: en_US.UTF-8
<p dir="auto">pandas: 0.19.2-ts2<br>
nose: 1.3.7<br>
pip: 9.0.1<br>
setuptools: 27.2.0<br>
Cython: None<br>
numpy: 1.11.3<br>
scipy: 0.18.1<br>
statsmodels: None<br>
xarray: None<br>
IPython: 5.1.0<br>
sphinx: 1.5.1<br>
patsy: None<br>
dateutil: 2.6.0<br>
pytz: 2016.10<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
matplotlib: 1.5.3<br>
openpyxl: None<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: None<br>
httplib2: None<br>
apiclient: None<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.4<br>
boto: None<br>
pandas_datareader: None</p>
</details>