1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

[Python] Trying to exclude blank entries on pandas dataframe.loc command

Discussão em 'Python' iniciado por Stack, Setembro 12, 2024.

  1. Stack

    Stack Membro Participativo

    I have two lists of people in two separate systems. One is our data warehouse, and the other is an autodialer. We recently had an issue where some of the data got duplicated in the dialer. We are trying to identify the problem records and I'm trying to create two lists, one that is a priority list with only active people, and the other is a complete list with everybody. I have two DataFrames that I merged into a single DataFrame and then substituted a blank string for the NaN's so it's more readable for the end users. However, now I'm trying to remove the blank records for the "priority" list (the ID gets blanked out as part of the process when the person is made inactive). However when I try it's not working. Here is what I've got:

    results.loc[(results['ID'] != results['SSID']) & (results['number1'] != '8888888888') & (results['number1'] != '9999999999') & (results['ID'] != '') & (results['SSID'] != '')].to_excel(writer, sheet_name = 'Priority', startrow=1)


    However, when the list comes out it still gives me the blanks. It removes the '888' and '999' phone numbers from the list but not the blanks

    I have also tried using != 0 and != NaN but neither of those work. Can someone point me in the right direction? Thanks!

    Continue reading...

Compartilhe esta Página