I have an excel sheet with below records
Here if you see second and fourth rows having null value, so our objective to remove these rows from process, lets see how we can do with panda package of python
Post Reference: Vikram Aristocratic Elfin Share
Here if you see second and fourth rows having null value, so our objective to remove these rows from process, lets see how we can do with panda package of python
import pandas as pd
import numpy as np
df1 = pd.read_csv("NullFilterExample.csv")
print('Original DF with NULL value in rows \n',df1 , '\n')
for col in df1.columns:
df1=df1[df1[col].notnull()]
print('After removing rows with NULL Value \n',df1)
import numpy as np
df1 = pd.read_csv("NullFilterExample.csv")
print('Original DF with NULL value in rows \n',df1 , '\n')
for col in df1.columns:
df1=df1[df1[col].notnull()]
print('After removing rows with NULL Value \n',df1)
Output:
Original DF with NULL value in rows
account_no branch
city_code customer_name amount
0 2112 3212.0
321.0 Sidhika 19000
1 2119 NaN
215.0 Prayansh 12000
2 2115 4321.0
212.0 Rishika 15000
3 2435 2312.0
NaN Sagarika 13000
After removing rows with NULL Value
account_no branch
city_code customer_name amount
0 2112 3212.0
321.0 Sidhika 19000
2 2115 4321.0
212.0 Rishika 15000
Data Science with…Python J
Post Reference: Vikram Aristocratic Elfin Share
No comments:
Post a Comment