Home > other >  Find a Dataframe object as a null line index
Find a Dataframe object as a null line index

Time:09-24

Excuse me, if in the Dataframe object df, existence state free values in a column, I use the np, where (df [' state ']=='NaN') carry out results for why (array ([], dtype=int64),)? Why don't show in array line index number? There are no other ways to achieve this requirement?

CodePudding user response:

 
The import pandas as pd
The import numpy as np

Df=pd DataFrame ({' state ': [1, 2, 3, None, 4]})
Print (np) where (df [' state '] isnull ()))


Don't need to use numpy
 
The import pandas as pd

Df=pd DataFrame ({' state ': [1, 2, 3, None, 4]})
Print (list (df [df [' state '] isnull ()]. The index))

CodePudding user response:

Thank you, ok.
  • Related