Label Encoder multiple levels
<p>I am using python label encoder to transform my data. Here is my sample data.</p>

<pre><code>                         Database      Target    Market_Description    Brand  \
0            CN_Milk powder_Incl_Others    NaN  Shanghai Hyper total  O.Brand   
1            CN_Milk powder_Incl_Others    NaN  Shanghai Hyper total  O.Brand   
2            CN_Milk powder_Incl_Others    NaN  Shanghai Hyper total  O.Brand   

  Sub_Brand Category                   Class_Category  
0       NaN      NaN  Hi Cal Adult Milk Powders- C1  
1       NaN      NaN  Hi Cal Adult Milk Powders- C1  
2       NaN      NaN  Hi Cal Adult Milk Powders- C1 
</code></pre>

<p>I am applying the transformation across all columns </p>

<pre><code>df3 = CountryDF.apply(preprocessing.LabelEncoder().fit_transform)   
</code></pre>

<p>When I check the unique values for Target column, it says,</p>

<pre><code>&gt;&gt;&gt; print pd.unique(CountryDF.Target.ravel())

&gt;&gt;&gt; [nan 'Elder' 'Others' 'Lady']
</code></pre>

<p>But when i check the same after transformation, I am getting multiple levels.</p>

<pre><code>&gt;&gt;&gt; print pd.unique(df3.Target.ravel())
&gt;&gt;&gt; [ 40749 667723 667725 ...,  43347  43346  43345]
</code></pre>

<p>I am not sure how this works? I expected four unique values as I thought the transform implementation works by getting unique values and assigning sorted numpy on each, can anyone help me understand this.</p>

<p>EDIT :- This dataset is a subset of a big dataset. Does that have any relation to this?</p>

<p>EDIT2 :- @Kevin I tried what you suggested, its weird. see this.
<a href="https://i.stack.imgur.com/Ycgef.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ycgef.png" alt="enter image description here"></a></p>