how do i divide a dataframe with another of different size?

First select only int columns using df.select_dtypes. Then use df.div to divide by index:

In [96]: x = tablaFrecuencias.select_dtypes('int').columns.tolist()
In [98]: tablaFrecuencias[x] = tablaFrecuencias.select_dtypes('int').div(totalFrutas.values)

In [99]: tablaFrecuencias
Out[99]: 
   i=gramos  100     120     150    170    190  200
0  Manzanas  0.4  0.2900  0.2000  0.110  0.000  0.0
1     Mango  0.0  0.0625  0.1875  0.500  0.250  0.0
2      Pera  0.0  0.0000  0.0000  0.175  0.325  0.5

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top