Adding a row to an existing Pivot table

Viewed 3004

I have the below pivot table:

  Fruit |                 |  apple |   orange  |   banana  
 Market |   # num bracket |        |           |           
:-----------------------------------------------------------:    
 X      |   100           |   1.2  |   1.0     |     NaN     
 Y      |   50            |   2.0  |   3.5     |     NaN    
 Y      |   100           |   NaN  |   3.6     |     NaN    
 Z      |   50            |   NaN  |     NaN   |     1.6    
 Z      |   100           |   NaN  |     NaN   |     1.3

I want to add in the below row at the bottom

Fruit   |  apple |  orange  |   banana  
Price   |  3.5   | 1.2      |  2

So the new table looks like the below

 Fruit  |      x          |  apple |   orange  |   banana  
 Market |   # num bracket |        |           |           
:-----------------------------------------------------------:    
 X      |   100           |   1.2  |   1.0     |     NaN     
 Y      |   50            |   2.0  |   3.5     |     NaN    
 Y      |   100           |   NaN  |   3.6     |     NaN    
 Z      |   50            |   NaN  |     NaN   |     1.6    
 Z      |   100           |   NaN  |     NaN   |     1.3   
 Price  |                 |  3.5   | 1.2      |      2

Does any one have a quick in easy recommendation on how to do this?

1 Answers
temp_df = pd.DataFrame(data=[{'Fruit Market':'Price',
                              'apple':3.5,
                              'orange':1.2
                              'banana':2}],
                       columns=['Fruit Market','x','apple','orange','banana'])

pd.concat([df, temp_df], axis=0, ignore_index=True)
Related