1

I have the following dataframe:

Column A Column B
Lorem NaN
Ipsum NaN
Dolor NaN
Sit 25
Amet 34
Etc NaN
Something else NaN

I would like to count the number of NaNs in Column B until the first non-NaN number (which is 25 here). So, the expected returned value is 3.

I think there is something involving notna() and first_valid_index, but I cannot seem to put the information together. This problem is similar to this one but I want before, not since the first NaN.

Can you help me?

Bogdan Doicin
  • 2,342
  • 5
  • 25
  • 34

0 Answers0