Select Columns in pandas DF
<p>Below is my data and I am trying to access a column. It was working fine until yesterday, but now I'm not sure if I am doing something wrong:</p>

<pre><code>    DISTRICT;CPE;EQUIPMENT,NR_EQUIPM
0   47;CASTELO BRANCO;17520091VM;101                                                                                                                                                                                                     
1   48;CASTELO BRANCO;17520103VV;160                                                                                                                                                                                                     
2   49;CASTELO BRANCO;17520103VV;160
</code></pre>

<p>When I try this, it gives me an error:</p>

<pre><code>df = pd.read_csv(archiv, sep=",")   
df['EQUIPMENT']  
</code></pre>

<p>ERROR:</p>

<blockquote>
  <p>KeyError: 'EQUIPMENT'</p>
</blockquote>

<p>Also I am trying this, but doesn`t work either:</p>

<pre><code>df.EQUIPMENT
</code></pre>

<p>ERROR:</p>

<blockquote>
  <p>AttributeError: 'DataFrame' object has no attribute 'EQUIPMENT'</p>
</blockquote>

<p>BTW, I am using:</p>

<blockquote>
  <p>Python 2.7.12 |Anaconda 4.1.1 (32-bit)| (default, Jun 29 2016,
  11:42:13) [MSC v.1500 32 bit (Intel)]</p>
</blockquote>

<p>Any idea?</p>

<p>You need change sep to <code>;</code>, because separator is changed in <code>csv</code>:</p>

<pre><code>df = pd.read_csv(archiv, sep=";") 
</code></pre>

<p>If check last separator of columns, there is <code>,</code>, so you can use two separators - <code>;,</code>, but is necessary add parameter <code>engine='python'</code> because warning:</p>

<blockquote>
  <p>ParserWarning: Falling back to the 'python' engine because the 'c' engine does not support regex separators (separators > 1 char and different from '\s+' are interpreted as regex); you can avoid this warning by specifying engine='python'.
    for index, row in df.iterrows():</p>
</blockquote>

<p>Sample:</p>

<pre><code>import pandas as pd
import io

temp=u"""DISTRICT;CPE;EQUIPMENT,NR_EQUIPM
47;CASTELO BRANCO;17520091VM;101
48;CASTELO BRANCO;17520103VV;160
49;CASTELO BRANCO;17520103VV;160"""
#after testing replace io.StringIO(temp) to filename
df = pd.read_csv(io.StringIO(temp), sep="[;,]", engine='python')

print (df)
   DISTRICT             CPE   EQUIPMENT  NR_EQUIPM
0        47  CASTELO BRANCO  17520091VM        101
1        48  CASTELO BRANCO  17520103VV        160
2        49  CASTELO BRANCO  17520103VV        160
</code></pre>

python csv pandas multiple-columns separator