I have a DataFrame, that contains text description and its sub fields column-wise.
like,
<table>
<tr>
<th>Text</th>
<th>Col1</th>
<th>Col2</th>
<th>Col3</th>
</tr>
<tr>
<td>Boy eating apple</td>
<td>boy</td>
<td>eating</td>
<td>apple</td>
</tr>
<tr>
<td>Boy riding bike</td>
<td>boy</td>
<td>riding</td>
<td>bike</td>
</tr>
<tr>
<td>Boy driving car</td>
<td>boy</td>
<td>driving</td>
<td>car</td>
</tr>
</table>
</html>
Here I have code to do fit and transform as below:
le = preprocessing.LabelEncoder()
le.fit(data[['col1','col2','col3']])
data = le.transform(data[['col1','col2','col3']])
The above code gives "['col2'] not in index" exception for multiple columns, whereas code working fine with single column.
What is the solution?