<p dir="auto"><a href="http://stackoverflow.com/questions/32553207/values-missing-when-loaded-from-pandas-hdf5-file/32587108?noredirect=1#comment53034458_32587108" rel="nofollow">http://stackoverflow.com/questions/32553207/values-missing-when-loaded-from-pandas-hdf5-file/32587108?noredirect=1#comment53034458_32587108</a></p>
<p dir="auto">e.g.</p>
<p dir="auto">if I</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df.to_hdf('foo.h5','df',encoding='utf-8')"><pre class="notranslate"><code class="notranslate">df.to_hdf('foo.h5','df',encoding='utf-8')
</code></pre></div>
<p dir="auto">then</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="pd.read_hdf('foo.h5','df')"><pre class="notranslate"><code class="notranslate">pd.read_hdf('foo.h5','df')
</code></pre></div>
<p dir="auto">should pick up the encoding for each table (unless the user overrides by passing in <code class="notranslate">encoding=...</code></p>
<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; ser = pd.Series(pd.Categorical([np.nan]))
&gt;&gt;&gt; ser.nunique()
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">ser</span> <span class="pl-c1">=</span> <span class="pl-s1">pd</span>.<span class="pl-v">Series</span>(<span class="pl-s1">pd</span>.<span class="pl-v">Categorical</span>([<span class="pl-s1">np</span>.<span class="pl-s1">nan</span>]))
<span class="pl-c1">&gt;&gt;</span><span class="pl-c1">&gt;</span> <span class="pl-s1">ser</span>.<span class="pl-en">nunique</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">The above code gave 0 in v20.3 and is expected to give 0 also in v0.21. The problem is independent of if I set some categories.</p>
<p dir="auto"><strong>EDIT</strong>: Actually this doesn't give error if I set categories. so this only happens if no categories are set. The use case for no categories in my case is programmatically reading in data, where some columns are empty and of dtype categorical.</p>
<h4 dir="auto">Expected Output</h4>
<p dir="auto">0 (zero)</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: <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/pandas-dev/pandas/commit/81372093f1fdc0c07e4b45ba0f47b0360fabd405/hovercard" href="https://github.com/pandas-dev/pandas/commit/81372093f1fdc0c07e4b45ba0f47b0360fabd405"><tt>8137209</tt></a><br>
python: 3.5.4.final.0<br>
python-bits: 32<br>
OS: Windows<br>
OS-release: 10<br>
machine: AMD64<br>
processor: Intel64 Family 6 Model 78 Stepping 3, GenuineIntel<br>
byteorder: little<br>
LC_ALL: None<br>
LANG: None<br>
LOCALE: None.None</p>
<p dir="auto">pandas: 0.21.0<br>
pytest: 3.2.3<br>
pip: 9.0.1<br>
setuptools: 36.5.0.post20170922<br>
Cython: None<br>
numpy: 1.13.3<br>
scipy: None<br>
pyarrow: None<br>
xarray: None<br>
IPython: 6.1.0<br>
sphinx: None<br>
patsy: None<br>
dateutil: 2.6.1<br>
pytz: 2017.3<br>
blosc: None<br>
bottleneck: None<br>
tables: None<br>
numexpr: None<br>
feather: None<br>
matplotlib: None<br>
openpyxl: 2.4.8<br>
xlrd: None<br>
xlwt: None<br>
xlsxwriter: None<br>
lxml: None<br>
bs4: None<br>
html5lib: None<br>
sqlalchemy: None<br>
pymysql: None<br>
psycopg2: None<br>
jinja2: 2.9.6<br>
s3fs: None<br>
fastparquet: None<br>
pandas_gbq: None<br>
pandas_datareader: None</p>
</details>