0

I couldn't find an answer from suggested question Suggested Link

I'm trying to check if the value is NaN(of type numpy.float64).

Sample Df:

 df

        amt
 0      50.0
 1      NaN
 2      25.0

Type is type(df['due amount'][1]) is numpy.float64.

I'm trying to check if this value is NaN or not.

  tnx_final['due amount'][1] == np.nan   #This won't work as type is  numpy.float64

What should be the numpy equivalent for the above code? Is there a way to find without changing column type to str ?

  • Check `tnx_final['due amount'].isna()` – jezrael Nov 18 '20 at 11:03
  • I need to check a particular row like this `tnx_final['due amount'][1] == np.nan` –  Nov 18 '20 at 11:04
  • Sorry, it is wrong link. Added correct. – jezrael Nov 18 '20 at 11:06
  • Thanks but that link also didn't solve the question. `tnx_final['due amount'][1] == np.nan`. Any numpy.float64 equivalent to np.nan? –  Nov 18 '20 at 11:10
  • 1
    Any numpy.float64 equivalent to np.nan? - Not exist. – jezrael Nov 18 '20 at 11:11
  • `df.loc[df['amt'] == np.nan,'amt'] = df['another_column_value']`. So for this case is there a way to check `== np.nan` ? –  Nov 18 '20 at 11:17
  • If need test misisng values in numpy, check second code in accepted answer, use `np.isnan(tnx_final['due amount'][1])` – jezrael Nov 18 '20 at 11:17
  • Yes, then need `df.loc[df['amt'].isnan(),'amt'] = df['another_column_value']` – jezrael Nov 18 '20 at 11:18
  • 1
    Or `df['amt'] = df['amt'].fillna(df['another_column_value'])` – jezrael Nov 18 '20 at 11:18
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/224724/discussion-between-zanthoxylum-piperitum-and-jezrael). –  Nov 18 '20 at 11:23

0 Answers0