Find the most common pair of Python Pandas



  • There's the next DataFrame:

    Транзакция  Сумма   Товар
    1   500 1
    1   600 2
    1   500 1
    1   548 3
    1   849 1
    2   654 4
    2   654 1
    2   321 2
    2   469 2
    2   465 5
    3   564 1
    3   465 6
    3   444 7
    3   123 6
    3   648 7
    

    A few of the most common products in each transaction must be found and the number of these transactions should be indicated. In this example, the answer must be goods 1, 2 , met in 2 transactions.



  • The vectored Pandas / Numpy decisions, in your case, will fall sharply at the processing speed of specialized libraries that are operating. https://loginom.ru/blog/apriori And he's like that.

    References to modules:

    • https://pypi.org/project/efficient-apriori/
    • https://borgelt.net/doc/fpgrowth/fpgrowth.html


Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2