0

Hi I created a pivot table using the below code.

table2M = table2M.pivot(index='Shop', columns='Fruit', values='amout_purchased')

And I get a table like this one

 Fruit |    apple        |   orange  |   banana  
 Shop  |                 |           |                     
:--------------------------------------------- -:    
  A    |   None          |  1/3      |   2/5           
  B    |   1/2           |  None     |   1/9            
  C    |   None          |  None     |   1/3  

What I would like to do is replace the Nones with a blank space, any idea on how to do this?

 Fruit |    apple        |   orange  |   banana  
 Shop  |                 |           |                     
:-------------------------------------------------:    
  A    |                 |  1/3      |   2/5           
  B    |   1/2           |           |   1/9            
  C    |                 |           |   1/3      
jtagle
  • 196
  • 8
lmccann
  • 129
  • 1
  • 6
  • Possible duplicate of https://stackoverflow.com/questions/26837998/pandas-replace-nan-with-blank-empty-string. You could try the answer someone gave there. I mean, not exactly the same, but that's kind of what you are looking for – jtagle Feb 14 '18 at 14:05
  • this helped thank you! – lmccann Feb 14 '18 at 14:30
  • Possible duplicate of [Pandas Replace NaN with blank/empty string](https://stackoverflow.com/questions/26837998/pandas-replace-nan-with-blank-empty-string) – jpp Feb 14 '18 at 14:46
  • When using Pandas use the function df.fillna(0) to replace all Nones with a 0. df.fillna("") would leave a blank – matsbauer Feb 14 '18 at 14:49

0 Answers0