title: KeyError when extracting data from a pandas.core.series.Series
body: <p>In the following ipython3 session, I read differently-formatted tables and make the sum of the values found in one of the columns:</p>
  
  <pre><code>In [278]: F = pd.read_table("../RNA_Seq_analyses/mapping_worm_number_tests/hisat2/mapped_C_elegans/feature_count/W100_1_on_C_elegans/protein_coding_fwd_counts.txt", skip
       ...: rows=2, usecols=[6]).sum()
  
  In [279]: S = pd.read_table("../RNA_Seq_analyses/mapping_worm_number_tests/hisat2/mapped_C_elegans/intersect_count/W100_1_on_C_elegans/protein_coding_fwd_counts.txt", us
       ...: ecols=[6], header=None).sum()
  
  In [280]: S
  Out[280]: 
  6    3551266
  dtype: int64
  
  In [281]: F
  Out[281]: 
  72    3164181
  dtype: int64
  
  In [282]: type(F)
  Out[282]: pandas.core.series.Series
  
  In [283]: type(S)
  Out[283]: pandas.core.series.Series
  
  In [284]: F[0]
  Out[284]: 3164181
  
  In [285]: S[0]
  ---------------------------------------------------------------------------
  KeyError                                  Traceback (most recent call last)
  &lt;ipython-input-285-5a4339994a41&gt; in &lt;module&gt;()
  ----&gt; 1 S[0]
  
  /home/bli/.local/lib/python3.6/site-packages/pandas/core/series.py in __getitem__(self, key)
      601             result = self.index.get_value(self, key)
      602 
  --&gt; 603             if not is_scalar(result):
      604                 if is_list_like(result) and not isinstance(result, Series):
      605 
  
  /home/bli/.local/lib/python3.6/site-packages/pandas/indexes/base.py in get_value(self, series, key)
  
  pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3323)()
  
  pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3026)()
  
  pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4009)()
  
  pandas/src/hashtable_class_helper.pxi in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:8146)()
  
  pandas/src/hashtable_class_helper.pxi in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:8090)()
  
  KeyError: 0
  </code></pre>
  
  <p><strong>How come the <code>F</code> and <code>S</code> objects have different behaviours if they result from similar operation (<code>sum</code>) and are of the same type (<code>pandas.core.series.Series</code>)?</strong></p>
  
  <p>What is the correct way to extract the value I want (the sum of a column)?</p>
  
  <h3>Edit: Trying solutions:</h3>
  
  <pre><code>In [297]: F["72"]
  Out[297]: 3164181
  
  In [298]: S["6"]
  ---------------------------------------------------------------------------
  TypeError                                 Traceback (most recent call last)
  pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4009)()
  
  pandas/src/hashtable_class_helper.pxi in pandas.hashtable.Int64HashTable.get_item (pandas/hashtable.c:8125)()
  
  TypeError: an integer is required
  
  During handling of the above exception, another exception occurred:
  
  KeyError                                  Traceback (most recent call last)
  &lt;ipython-input-298-0127424036a0&gt; in &lt;module&gt;()
  ----&gt; 1 S["6"]
  
  /home/bli/.local/lib/python3.6/site-packages/pandas/core/series.py in __getitem__(self, key)
      601             result = self.index.get_value(self, key)
      602 
  --&gt; 603             if not is_scalar(result):
      604                 if is_list_like(result) and not isinstance(result, Series):
      605 
  
  /home/bli/.local/lib/python3.6/site-packages/pandas/indexes/base.py in get_value(self, series, key)
  
  pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3323)()
  
  pandas/index.pyx in pandas.index.IndexEngine.get_value (pandas/index.c:3026)()
  
  pandas/index.pyx in pandas.index.IndexEngine.get_loc (pandas/index.c:4075)()
  
  KeyError: '6'
  </code></pre>
  
  <p>Further investigating:</p>
  
  <pre><code>In [306]: print(S.index)
  Int64Index([6], dtype='int64')
  
  In [307]: print(F.index)
  Index(['72'], dtype='object')
  
  In [308]: S[6]
  Out[308]: 3551266
  </code></pre>
  
  <p>So the two objects ended up having different types of indices. This kind of behaviour reminds me of R...</p>
  
  <p>It seems that <code>header=None</code> resulted in columns indexed by numbers for <code>S</code>, whereas the absence of <code>header=None</code> combined with <code>skiprows=2</code> resulted in the index being generated from data read on the third row. (And this revealed a bug in the way I parsed the data in pandas...)</p>