-3

How to know if a column is multiple of other? How many registers of column sales are multiple of calls?

|Sales|Calls|
| 8   | 10 |
| 5   |  3 |
| 6   |  3 |
  ... 

Been thinking a true or false solution and then counting how many true and false are

Been thinking about a boolean solution

petezurich
  • 9,280
  • 9
  • 43
  • 57
lalo
  • 21
  • 3
  • 1
    You could calculate a correlation matrix for all your columns to see which have a correlation near 1. The closer it is to 1, the more precisely one column is a multiple of the other. https://stackoverflow.com/a/22282852/6851825 – Jon Spring Jun 05 '23 at 05:26
  • `data$Sales %% data$Calls == 0` ? – neilfws Jun 05 '23 at 05:30
  • Or expanding that, `sum(Sales %% Calls == 0)` will count the number of rows where Calls is evenly divisable into Sales. – Jon Spring Jun 05 '23 at 07:03

1 Answers1

2

Expanding on @neilfws comment try this in Python:

import pandas as pd

df = pd.DataFrame({
    'Sales': [8, 5, 6],
    'Calls': [10, 3, 3]
})

df["multiples"] = df['Sales'] % df['Calls'] == 0
print(df.multiples.sum())

Printout:

1

This only works if your data are integers. If you have zeroes in your counts you need to filter these beforehand.

petezurich
  • 9,280
  • 9
  • 43
  • 57