一樣用這dataframe
import pandas as pd
import numpy as np
data ={'name':['Kevin', 'Jimmy', 'Jame','Ken','Jenny'],
'email':['abc@gmail.com', 'def@gmail.com', 'ghi@gmail.com', 'jkl@gmail.com','mn@gmail.com'],
'salary':[41000, 39000, 53000, 62000,np.nan]}
employee_df = pd.DataFrame(data)
print(employee_df)
output
處理空值
employee_df=employee_df.fillna(0) #設空值為0
print(employee_df)
output
employee_df=employee_df.fillna("Unknown") #設空值為Unknown
print(employee_df)
ouput
欄位條件
filt=employee_df['salary']>45000 #找出salary大於45000
print(employee_df.loc[filt])