I dropped the null values in the beginning but after one hot encoding there are null values present

42 Views Asked by At

enter code hereI read the dataset and checked for null values, it showed there were two rows with null values, so I dropped those two rows. then checked for any null values, but it showed no null values, so I proceeded with the next steps. my data set contains a gender column for which I did one hot encoding and converted other categorical features with respective encoders. I changed the index order to bring object columns to one side and integer columns to the other side using indexing. But now, when checking for null values, the now converted gender column has null values in them. how to proceed from here...

dataset link - https://www.kaggle.com/datasets/rkiattisak/salaly-prediction-for-beginer

import pandas as pd
import numpy as np

df[df.isnull().any(axis=1)]
df=df.dropna()

from sklearn.preprocessing import OneHotEncoder
enc=OneHotEncoder()
one_enc_data= pd.get_dummies(df,columns=['Gender'])
enc_data = pd.DataFrame(enc.fit_transform(df[['Gender']]).toarray())

df=df.join(enc_data)
from category_encoders import TargetEncoder
encoder = TargetEncoder()
df['job_title_encoded'] = encoder.fit_transform(df['Job Title'], df['Salary'])

df=df.iloc[:,[1,3,0,6,7,2,4,8,5]]

[null values] enter image description here enter image description here enter image description here tail(2) I wanted to try filling the values but I'm unsure if it is possible.

0

There are 0 best solutions below