title: How to overcome the Wrong merging When using Pivot_Table?
body: <p>I have Two Dataframes ,What I'm trying to to do , is to create new columns based on the Sensor_Type and add them to DF1 and assign each measurement based on the Sensor.</p>
  
  <p>DF1:</p>
  
  <pre><code>  Weather_Legends.head():
  
    Sensor_ID Sensor_Street_Name  Sensor_Lat  Sensor_Long   Sensor_Type         UOM
   0  6030    Milano - via Brera  45.471192   9.187616    Wind Direction      degree
   1  5897    Milano - via Brera  45.471192   9.187616      Temperature   Celsius degree
   2  6174    Milano - via Brera  45.471192   9.187616    Relative Humidity      %
   3  6120    Milano - via Brera  45.471192   9.187616      Wind Speed         m/s
   4  2006    Milano - via Lambrate  45.490051  9.22559   Precipitation        mm
  </code></pre>
  
  <p>DF2:</p>
  
  <pre><code>  Mi_Meteo.head():
  
    Sensor_ID    Time_Instant     Measurement
  0   14121   2013-11-01 01:00:00   0.8
  1   14121   2013-11-01 02:00:00   0.6
  2   14121   2013-11-01 03:00:00   0.4
  3   14121   2013-11-01 04:00:00   0.4
  4   14121   2013-11-01 05:00:00    0
  </code></pre>
  
  <p>And this is the desired output:</p>
  
  <pre><code>Sensor_Type Sensor_ID   Sensor_Street_Name             Time_Instant      Precipitation     Relative Humidity    Wind Speed  …..
       0      14121     Milano - via Ippolito Rosellini   2013-11-01 01:00:00   0.8              NaN              NaN
       1      14121     Milano - via Ippolito Rosellin    2013-11-01 02:00:00   NaN              0.6              NaN
       2      14121     Milano - via Ippolito Rosellini   2013-11-01 03:00:00   0.4               NaN             NaN
       .
       .
       .
  </code></pre>
  
  <p>And Instead , These Is What I get:</p>
  
  <pre><code> Sensor_Type Sensor_ID  Sensor_Street_Name               Time_Instant     Precipitation
     0          14121    Milano - via Ippolito Rosellini   2013-11-01 01:00:00    0.8
     1          14121    Milano - via Ippolito Rosellini   2013-11-01 02:00:00    0.6
     2          14121    Milano - via Ippolito Rosellini   2013-11-01 03:00:00    0.4
     .
     .
  </code></pre>
  
  <p>The Other Sensor Type are Missing !!!</p>
  
  <p>And Here's The Code That I Used:</p>
  
  <pre><code>    Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].str.rstrip(' Measure').str.strip()
      Mi_Meteo['Measurement'] = pd.to_numeric(Mi_Meteo['Measurement'] ,errors='coerce' )
      Mi_Meteo['Sensor_ID'] = Mi_Meteo['Sensor_ID'].str.rstrip(' ID').str.strip()
      Mi_Meteo['Sensor_ID'] = pd.to_numeric(Mi_Meteo['Sensor_ID'] ,errors='coerce' )
  
      Mi_Meteo['Measurement'] = Mi_Meteo['Measurement'].astype(float)
      Mi_Meteo['Sensor_ID'] = Mi_Meteo['Sensor_ID'].astype(float)
  
      df4 = Mi_Meteo.merge(Weather_Legends, on='Sensor_ID', how='left')\
                    .pivot_table(index=['Sensor_ID' ,'Sensor_Street_Name' , 'Time_Instant' ], 
                                 values= 'Measurement', 
                                 columns='Sensor_Type')\
                    .reset_index()
      df4['Sensor_ID'] = df4['Sensor_ID'].astype(int)
  </code></pre>
  
  <p>Any Suggestion Would Be Much Appreciated , Thank U all.</p>