[Python] Determine Prime Number in Python DataFrame

Discussão em 'Python' iniciado por Stack, Julho 2, 2025.

  1. Stack

    Stack Membro Participativo

    I have dataframe like this:

    Name Email Trx
    0 John john.doe@gmail.com 30
    1 Sarah sarah@gmail.com 7
    2 Bob bob@yahoo.com 11
    3 Chad chad@outlook.com 21
    4 Karen karen@outlook.com 20
    5 Dmitri dmitri@rocketmail.com 17


    and I need to know whether the respective customer eligible for a voucher or not. The criteria is if the trx is a prime number, the customer is eligible, else it's not eligible. The dataframe should be like this:

    Name Email Trx Voucher
    0 John john.doe@gmail.com 30 not eligible
    1 Sarah sarah@gmail.com 7 eligible
    2 Bob bob@yahoo.com 11 eligible
    3 Chad chad@outlook.com 21 not eligible
    4 Karen karen@outlook.com 20 not eligible
    5 Dmitri dmitri@rocketmail.com 17 eligible


    I know how to determine prime number but not in a dataframe. Thank you in advance

    Continue reading...

Compartilhe esta Página