Fill the missing values (NaN to 0)
Get index and locate
kodingwindow@kw:~$ python3 ... >>> import pandas as pd >>> df=pd.read_csv("/home/kodingwindow/kw.csv") >>> df account_no name city dob bank amount 0 25622348989 James Moore Phoenix 1985-05-26 Barclays 5000 1 25622348990 Donald Taylor Irvine 1990-08-20 Citi 7000 2 25622348991 Edward Parkar Irvine 1994-01-29 ICICI 95000 3 25622348992 Ryan Bakshi Mumbai 1982-01-14 Citi 50000 4 25622348993 Marie Peters Ribe 1967-01-05 DZBank 12250 5 25622348994 Aanya Delhi 1975-08-18 SBI 105000 6 25622348995 James Moore NaN 1978-06-26 Citi 97800 >>> df.fillna(0) account_no name city dob bank amount 0 25622348989 James Moore Phoenix 1985-05-26 Barclays 5000 1 25622348990 Donald Taylor Irvine 1990-08-20 Citi 7000 2 25622348991 Edward Parkar Irvine 1994-01-29 ICICI 95000 3 25622348992 Ryan Bakshi Mumbai 1982-01-14 Citi 50000 4 25622348993 Marie Peters Ribe 1967-01-05 DZBank 12250 5 25622348994 Aanya Delhi 1975-08-18 SBI 105000 6 25622348995 James Moore 0 1978-06-26 Citi 97800
Fill actual value instead of 0 (NaN to string)
>>> df.fillna({'city':'City Missing'}) account_no name city dob bank amount 0 25622348989 James Moore Phoenix 1985-05-26 Barclays 5000 1 25622348990 Donald Taylor Irvine 1990-08-20 Citi 7000 2 25622348991 Edward Parkar Irvine 1994-01-29 ICICI 95000 3 25622348992 Ryan Bakshi Mumbai 1982-01-14 Citi 50000 4 25622348993 Marie Peters Ribe 1967-01-05 DZBank 12250 5 25622348994 Aanya Delhi 1975-08-18 SBI 105000 6 25622348995 James Moore City Missing 1978-06-26 Citi 97800
Drop a missing value row
>>> df.dropna() account_no name city dob bank amount 0 25622348989 James Moore Phoenix 1985-05-26 Barclays 5000 1 25622348990 Donald Taylor Irvine 1990-08-20 Citi 7000 2 25622348991 Edward Parkar Irvine 1994-01-29 ICICI 95000 3 25622348992 Ryan Bakshi Mumbai 1982-01-14 Citi 50000 4 25622348993 Marie Peters Ribe 1967-01-05 DZBank 12250 5 25622348994 Aanya Delhi 1975-08-18 SBI 105000
What Next?
Data Visualization
Advertisement