1

under ileads_address I'm trying to create a DF that only prints out all the rows that don't have 0.0. Is there anyway to code that?

I tried doing this

df5 = df4[~df4['ileads_address'] == 0]

Sample CSV File

jacksojo
  • 63
  • 5
  • added a solution. did it worked for you? – Naveed Jun 24 '22 at 16:40
  • Yes it did thank you. Am I able to ask a different question? – jacksojo Jun 24 '22 at 16:43
  • great! sure go ahead if its related. otherwise you can open another question – Naveed Jun 24 '22 at 16:44
  • Ok so the reason why I wanted to take out all the 0's because I was having trouble turning "ileads_address" into an int representation(take out the .0). IT keeps giving an error "IntCastingNaNError: Cannot convert non-finite values (NA or inf) to integer". It still gives me that error after I do df5['ileads_address'] = df5['ileads_address'].astype(int) – jacksojo Jun 24 '22 at 16:50
  • Cannot convert non-finite values (NA or inf) to integer : It means some of the data is NaN. that result in error. you can convert that to 0 using fillna(0). prior to it check like df4[df4['ileads_address'].isnull()] for such rows – Naveed Jun 24 '22 at 16:55
  • Managed to convert the data that is NaN to 0 but I'm now getting a Value Error, "ValueError: invalid literal for int() with base 10: '5017.0' – jacksojo Jun 24 '22 at 17:01
  • Check this out. Go through all the answers. https://stackoverflow.com/questions/43858595/how-do-i-fix-invalid-literal-for-int-with-base-10-error-in-pandas#43858649 – Naveed Jun 24 '22 at 17:09
  • How would I call upon this code : "pd.Series(['260,327,021']).str.replace(',', '').astype(int)" but with my df5? I tried all the other answers and they didn't work. – jacksojo Jun 24 '22 at 17:24
  • 1
    i suggest you to share the data as text in the question. follow guidelines here https://stackoverflow.com/help/minimal-reproducible-example – Naveed Jun 24 '22 at 18:34

1 Answers1

1

Try this

df4[df4['ileads_address'] != 0]
Naveed
  • 11,495
  • 2
  • 14
  • 21