Difference between NULL, empty and Python blank

Asked

Viewed 13,093 times

3

I’m making a Data Quality that receives a list with data from a Database and I have two rules:

  1. Null fields: Fields that are filled with the word NULL
  2. White/empty fields: Fields that come blank or empty

For the rule of NULL I’m using:

if (pd.isnull(lista[linha2][linha])):
    print("Alguma coisa")

and recognizes the field as Nan.

How I do for blank or empty fields?

And the field type influences (eg str and float)?

  • "Data Quality" in my day was a beautiful way of speaking of a chuncho.

  • By the way, what are you using to bring back records from the database?

  • I don’t know the syntax of the Python language, but in PHP it would be something like: if (lista[linha2][linha] == '')

  • 1

    I’m using the pyodbc library. I had tried it that way and it hadn’t worked, now it has.. Check it out, right! Thank you! Thank you!

1 answer

4


In Python, if you just do

if variavel:
    ...

Any value that is analyzed as true will pass the test. It was not very clear, at least to me, what this object would be pd that you perform the method isnull, if it is the actual Pandas will be checked if the value is None or NaN. Without Pandas, it could be done:

if lista[linha2][linha] is None:
    ...

For values NaN:

import math

if math.isnan(lista[linha2][linha]):
    ...

For blank fields you may receive an empty string, so:

if lista[linha2][linha] == "":
    ...
  • pd is from the Pandas library! Thank you for the answer!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.