Skip to content
Advertisement

Why is pandas broadcast formula is skipping rows

I have a dataframe and I’m doing tons (20+) of calculations creating new columns etc. All the calculations work well, including the calculation in question except for 2 rows out of roughly 1,000. The rows are not adjacent to one another and I can’t find anything remarkable about these two specific rows the calculation seems to be skipping. The data is being read from a csv and an xlsx file. The trouble rows are from apart of the data from the csv file.

The calculation is:

JavaScript

The data for the two trouble rows looks like this:

JavaScript

The data for the rest of the df where the calculation works fine looks similar but is processing correctly:

JavaScript

Example code:

JavaScript

Why would the calculation seemingly skip these rows?

Advertisement

Answer

What the issue was I needed to fillnas before my calculations:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement