Conditionnal IF use not working with PD.NOTNA

1 week ago 4
ARTICLE AD BOX

Amateur programmer here, trying to make my working life bette.

I am building a billing program, using selenium webdriver, to facilitate people entering their information into the more complex web-based "official" billing system. The user imports a .csv file containing the pertinent information, that is then used to feed the proper fields in the billing system.

One column in the .csv file is used to determine which path the remainder of the billing needs to be done in ([path_decider]). The goal is that, if left empty, the "regular" path will be taken, but if not, it would go elsewhere. When empty, it is interpreted as "nan" by pandas.

The program iterates through the dataframe, line by line, to bill every line. To check wether this column is empty in the specific row, I wrote this IF statement :

if self.working_df['visit_code'][i] in ctn.acceptedOptions : # ... first special path, where the [path_decider] is not needed elif pd.notna(self.working_df['path_decider'][i]): # subsequent if statement to orient to the other specfic sub-path required else: # go on to the regular billing

I get this error from pylance on the elif statement :

The method __bool__ for type « Series[bool] » returns a type « NoReturn » rather than « bool ».

I understand that pd.notna is a dataframe operation that I am using on a single cell, but is still returning a dataframe/series. Since it is a single cell, can there still be issues ? Otherwise, is there an alternative way to separate with a boolean operator if the cell is not NaN ?

Thanks !

Read Entire Article