0

I cannot find where I can pass logical operations anything that will ID empty "cells" in a dataframe.

example when iterating by rows

for index, row in df.iterrows():
    if row['columnName'] == 'NaN':

I have tried with several variations on null identifiers but cannot find what pandas has in empty entries that logic functions can identify.

not_speshal
  • 22,093
  • 2
  • 15
  • 30
  • Please explain better what you are trying to do? Remove Nulls? – gtomer Jul 26 '23 at 14:43
  • 1
    `if pd.isnull(row["columnName"])`? – not_speshal Jul 26 '23 at 14:49
  • Try df.isna(), this will return True of False for Nan. – jjk Jul 26 '23 at 14:52
  • both pd.isnull and .isna() should do what I need. I did not think to apply them. What is even there? I am trying to understand pandas better but there is nothing at those locations? Is it simply an address that pandas somehow knows points nowhere? – Christopher Zachary Jul 26 '23 at 14:57
  • @gtomer: I am trying to clean some data and have previously written code that checks for empties and am trying to hand that code a way to identify empty pandas entries. But pandas doesnt hand anything interpretable out when there is nothing there? At least I do not know what to tell my code to look for to identify an empty pandas entry. – Christopher Zachary Jul 26 '23 at 15:01
  • please define 'interpretable out ', in my understanding return Ture/False is an 'interpretable out' – jjk Jul 26 '23 at 15:07
  • When iterating through a dataframe, Using again the format in the question: for i, row in df.iterrows(): I need to understand what happans at each step. As this reads the dataframe, what it is being returned when there is nothing at a given step? There is something, as pandas' own funcitons can identify that there is nothing, but when you call an empty outside of pandas' own functions, example .isnull(), What is returned? Is it interpretable? or will any code that tries to reference an empty location in a dataframe that is not pandas' own function simply fail. – Christopher Zachary Jul 26 '23 at 15:30
  • Iterating in Pandas is wrong. To which value do you wish to replace the nulls to? or you just want to remove the rows? – gtomer Jul 26 '23 at 18:11
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Jul 26 '23 at 22:06

0 Answers0