<p dir="auto">I have strange results from <code class="notranslate">.equals</code> appearing when DataFrame is written to HDF Store and then read back:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import pandas as pd
df = pd.DataFrame({'B':[1,2], 'A':[str('x'), str('y')]})  # str() - just to be sure this is not linked to unicode 
print 'df:'
print df
df.to_hdf('hdf_file', 'key', format='t', mode='w')
df_out = pd.read_hdf('hdf_file', 'key')
print '\ndf_out:'
print df_out
print '\ndf equals df_out:', df.equals(df_out)
print '\ndf_out equals df:', df_out.equals(df)
print '\ndf.shape == df_out.shape:', df.shape == df_out.shape
print '\narray_equivalent(df.values, df_out.values):', pd.core.common.array_equivalent(df.values, df_out.values)
print '\ndf.index equals df_out.index:', df.index.equals(df_out.index)
print '\ndf.columns equals df_out.columns:', df.columns.equals(df_out.columns)
for col in df.columns:
    print '\ndf.{0} equals df_out.{0}: {1}'.format(col, df[col].equals(df_out[col]))"><pre class="notranslate"><code class="notranslate">import pandas as pd
df = pd.DataFrame({'B':[1,2], 'A':[str('x'), str('y')]})  # str() - just to be sure this is not linked to unicode 
print 'df:'
print df
df.to_hdf('hdf_file', 'key', format='t', mode='w')
df_out = pd.read_hdf('hdf_file', 'key')
print '\ndf_out:'
print df_out
print '\ndf equals df_out:', df.equals(df_out)
print '\ndf_out equals df:', df_out.equals(df)
print '\ndf.shape == df_out.shape:', df.shape == df_out.shape
print '\narray_equivalent(df.values, df_out.values):', pd.core.common.array_equivalent(df.values, df_out.values)
print '\ndf.index equals df_out.index:', df.index.equals(df_out.index)
print '\ndf.columns equals df_out.columns:', df.columns.equals(df_out.columns)
for col in df.columns:
    print '\ndf.{0} equals df_out.{0}: {1}'.format(col, df[col].equals(df_out[col]))
</code></pre></div>
<p dir="auto">output:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df:
   A  B
0  x  1
1  y  2

df_out:
   A  B
0  x  1
1  y  2

df equals df_out: False

df_out equals df: False

df.shape == df_out.shape: True

array_equivalent(df.values, df_out.values): True

df.index equals df_out.index: True

df.columns equals df_out.columns: True

df.A equals df_out.A: True

df.B equals df_out.B: True"><pre class="notranslate"><code class="notranslate">df:
   A  B
0  x  1
1  y  2

df_out:
   A  B
0  x  1
1  y  2

df equals df_out: False

df_out equals df: False

df.shape == df_out.shape: True

array_equivalent(df.values, df_out.values): True

df.index equals df_out.index: True

df.columns equals df_out.columns: True

df.A equals df_out.A: True

df.B equals df_out.B: True
</code></pre></div>
<p dir="auto">The interesting thing is that if DataFrame is initialized with different columns "order" in the dictionary the results are ALL True (i.e. correct):</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df = pd.DataFrame({'A':[1,2], 'B':[str('x'),str('y')]})  # in the code above"><pre class="notranslate"><code class="notranslate">df = pd.DataFrame({'A':[1,2], 'B':[str('x'),str('y')]})  # in the code above
</code></pre></div>
<p dir="auto">will give:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="df equals df_out: True
df_out equals df: True"><pre class="notranslate"><code class="notranslate">df equals df_out: True
df_out equals df: True
</code></pre></div>
<p dir="auto">I have seen similar issues (<a href="https://github.com/pydata/pandas/issues/8437" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/8437/hovercard">#8437</a> and <a href="https://github.com/pydata/pandas/issues/7605" data-hovercard-type="issue" data-hovercard-url="/pandas-dev/pandas/issues/7605/hovercard">#7605</a>), which are marked as closed, but seeing this strange results... might be something different?</p>
<p dir="auto">python 2.7.9, pandas 0.15.2</p>
<p dir="auto">My apologies in advance for potential duplicate.</p>
<p dir="auto">Installed latest version of pandas 0.9.0 in case this was an error<br>
Trying to read Excel file. That part seems ok.<br>
Originally, I was trying iteritems() for each row of the pandas dataframe, as the id_company had to be verified against a mysql database (code not included). Same/similar error message to putting it into a tuple (code is below). Error message follows.</p>
<p dir="auto">Note there is a .reindex() but it didn't work before, either. The reindex() was kind of a hail-mary.</p>
<p dir="auto">As a work-around, I'm probably going to simply import from my target sql and do a join. I'm concerned because of the size of the datasets.</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import pandas as pd
def runNow():
    #identify sheet
    source = 'C:\Users\jlalonde\Desktop\startup_geno\startupgenome_w_id_xl_20121109.xlsx'
    xls_file = pd.ExcelFile(source)
    sd = xls_file.parse('Sheet1')
    source_u = sd.drop_duplicates(cols = 'id_company', take_last=False)
    source_r = source_u[['id_company','id_good','description', 'website','keyword', 'company_name','founded_month', 'founded_year', 'description']]
    source_i = source_r.reindex() #hail mary
    tup_r = [tuple(x) for x in source_i.values]

Traceback (most recent call last):
  File &quot;&lt;pyshell#10&gt;&quot;, line 1, in &lt;module&gt;
    sg_sql_2.runNow()
  File &quot;sg_sql_2.py&quot;, line 31, in runNow
    tup_r = [tuple(x) for x in source_r.values]
  File &quot;C:\Python27\lib\site-packages\pandas\core\frame.py&quot;, line 1443, in as_matrix
    return self._data.as_matrix(columns).T
  File &quot;C:\Python27\lib\site-packages\pandas\core\internals.py&quot;, line 723, in as_matrix
    mat = self._interleave(self.items)
  File &quot;C:\Python27\lib\site-packages\pandas\core\internals.py&quot;, line 743, in _interleave
    indexer = items.get_indexer(block.items)
  File &quot;C:\Python27\lib\site-packages\pandas\core\index.py&quot;, line 748, in get_indexer
    raise Exception('Reindexing only valid with uniquely valued Index '
Exception: Reindexing only valid with uniquely valued Index objects"><pre class="notranslate"><code class="notranslate">import pandas as pd
def runNow():
    #identify sheet
    source = 'C:\Users\jlalonde\Desktop\startup_geno\startupgenome_w_id_xl_20121109.xlsx'
    xls_file = pd.ExcelFile(source)
    sd = xls_file.parse('Sheet1')
    source_u = sd.drop_duplicates(cols = 'id_company', take_last=False)
    source_r = source_u[['id_company','id_good','description', 'website','keyword', 'company_name','founded_month', 'founded_year', 'description']]
    source_i = source_r.reindex() #hail mary
    tup_r = [tuple(x) for x in source_i.values]

Traceback (most recent call last):
  File "&lt;pyshell#10&gt;", line 1, in &lt;module&gt;
    sg_sql_2.runNow()
  File "sg_sql_2.py", line 31, in runNow
    tup_r = [tuple(x) for x in source_r.values]
  File "C:\Python27\lib\site-packages\pandas\core\frame.py", line 1443, in as_matrix
    return self._data.as_matrix(columns).T
  File "C:\Python27\lib\site-packages\pandas\core\internals.py", line 723, in as_matrix
    mat = self._interleave(self.items)
  File "C:\Python27\lib\site-packages\pandas\core\internals.py", line 743, in _interleave
    indexer = items.get_indexer(block.items)
  File "C:\Python27\lib\site-packages\pandas\core\index.py", line 748, in get_indexer
    raise Exception('Reindexing only valid with uniquely valued Index '
Exception: Reindexing only valid with uniquely valued Index objects
</code></pre></div>