-1

i have multiple columns and want to see inside them what are the null values. then i want to know if columns that have null values are numeric

df.isnull().sum() -> gives me the sum of null values inside the df (question 2 - in pandas the result are only the top 5 and last 5 colums; How can i see all columns? ) then from the result given i wanted to get only columns with numeric values

esqew
  • 42,425
  • 27
  • 92
  • 132
  • 1
    Welcome to SO! Please post a [minimal reproducible example](https://stackoverflow.com/questions/20109391/how-to-make-good-reproducible-pandas-examples) that would help us help you. :) – medium-dimensional Nov 25 '22 at 17:17
  • BTW, check out the [tour], and if you want more tips, [ask]. – wjandrea Nov 25 '22 at 17:52

1 Answers1

0

1st, you can type 'df.info()'
There is about null data and amount of index.

If it is small data, you can check like this

for i in range(len(df.index)):
    for j in range(len(df.columns)):
        if df.isna().iloc[i][j] == True:
            print(f'index is {i}, column is {df.columns[j]}')

but if it is big data, it can be make a problem.
if you wanna check this on other dataframe,
you can save it.

df_null = {'index':[], 'columns':[]}
for i in range(len(df.index)):
    for j in range(len(df.columns)):
        if df.isna().iloc[i][j] == True:
            df_null['index'].append(i)
            df_null['columns'].append(df.columns[j])

dfna = pd.DataFrame(df_null)

It's working. but it is so slow.
maybe there is more good answer but
I know only this way. then, good day! I hope this answer helps you

k1m2njun
  • 31
  • 5